Take a look at llvm/tools/clang/examples/Tooling/ClangCheck.cpp
Thank you Nico!
could you elaborate... would I put the C++ source to be compiled in
the JsonDatabase MemoryBuffer?
Jason
Examining the code from examples/Tooling/ClangCheck.cpp...
int main(int argc, char **argv) {
...
llvm::OwningPtr<llvm::MemoryBuffer> JsonDatabase; # line
llvm::SmallString<1024> JsonDatabasePath(argv[1]);
llvm::sys::path::append(JsonDatabasePath, "compile_commands.json");
llvm::error_code Result =
llvm::MemoryBuffer::getFile(JsonDatabasePath, JsonDatabase);
...
clang::tooling::CompileCommand LookupResult =
clang::tooling::FindCompileArgsInJsonDatabase(
File.str(), JsonDatabase->getBuffer(), ErrorMessage);
...
if (!LookupResult.CommandLine.empty()) {
if (!clang::tooling::RunToolWithFlags(
This function is defined in lib/Tooling/Tooling.cpp. If I'm reading
this file right, the function RunSyntaxOnlyToolOnCode() in the same
file does what you want.