A compilation database is a database for compile options. It records which compile options are used to build the files in a project. A compilation database can be, but is not limited to, a JSON Compilation Database. Refer to the clang::tooling::CompilationDatabase class for the full interface.

A real-world JSON Compilation Database entry, generated by CMake, looks like this:

{ "directory" : "/home/user/dev/llvm/build" , "file" : "/home/user/dev/llvm/llvm/lib/Support/APFloat.cpp" , "command" : "/usr/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support -I/home/user/dev/llvm/llvm/lib/Support -Iinclude -I/home/user/dev/llvm/llvm/include -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -fcolor-diagnostics -ffunction-sections -fdata-sections -O3 -UNDEBUG -fno-exceptions -fno-rtti -o lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o -c /home/user/dev/llvm/llvm/lib/Support/APFloat.cpp" }

An entry generated by clang -MJ , looks like this:

{ "directory" : "/home/user/dev/llvm/build" , "file" : "/tmp/foo.cpp" , "output" : "foo.o" , "arguments" : [ "/usr/bin/clang-5.0" , "-xc++" , "/tmp/foo.cpp" , "--driver-mode=g++" , "-Wall" , "-I" , "/home/user/dev/libcpp/libcpp/include" , "-c" , "--target=x86_64-unknown-linux-gnu" ] }