Clang tooling with compilation databases problem "Compile command not found"

Dear list,

I used Clang tooling to build a source code rewriter for a project I’m working on. I notice that some compile commands are not found in my compilation database (while others are). I couldn’t figure out any particular differences between them. For example, the below test case does not work:

./mytool /home/frederico/dev/tests/llvm/httpd/modules/http/http_protocol.c

It returns the message “Skipping /home/frederico/dev/tests/llvm/httpd/modules/http/http_protocol.c. Compile command not found.”

Inside my compile_commands.json, I have the entry:

{
“directory”: “/home/frederico/dev/tests/llvm/httpd/modules/http”,
“command”: “clang -fsanitize=dataflow -mllvm -dfsan-combine-pointer-labels-on-store -I/usr/local/llvm/cmakebuild/lib/clang/3.5.0/include/ -DLINUX -D_REENTRANT -D_GNU_SOURCE -I. -I/home/frederico/dev/tests/llvm/httpd/os/unix -I/home/frederico/dev/tests/llvm/httpd/include -I/home/frederico/dev/tests/llvm/httpd/srclib/apr/include -I/home/frederico/dev/tests/llvm/httpd/srclib/apr-util/include -I/home/frederico/dev/tests/llvm/httpd/srclib/apr-util/xml/expat/lib -I/usr/local/pcre/include -I/home/frederico/dev/tests/llvm/httpd/modules/aaa -I/home/frederico/dev/tests/llvm/httpd/modules/cache -I/home/frederico/dev/tests/llvm/httpd/modules/core -I/home/frederico/dev/tests/llvm/httpd/modules/database -I/home/frederico/dev/tests/llvm/httpd/modules/filters -I/home/frederico/dev/tests/llvm/httpd/modules/ldap -I/home/frederico/dev/tests/llvm/httpd/modules/loggers -I/home/frederico/dev/tests/llvm/httpd/modules/lua -I/home/frederico/dev/tests/llvm/httpd/modules/proxy -I/home/frederico/dev/tests/llvm/httpd/modules/session -I/home/frederico/dev/tests/llvm/httpd/modules/ssl -I/home/frederico/dev/tests/llvm/httpd/modules/test -I/home/frederico/dev/tests/llvm/httpd/server -I/home/frederico/dev/tests/llvm/httpd/modules/arch/unix -I/home/frederico/dev/tests/llvm/httpd/modules/dav/main -I/home/frederico/dev/tests/llvm/httpd/modules/generators -I/home/frederico/dev/tests/llvm/httpd/modules/mappers -c http_protocol.c -o http_protocol.o”,
“file”: “/home/frederico/dev/tests/llvm/httpd/modules/http/http_protocol.c”
}

Any ideas? Could this be a bug in my version (3.5) of clang?

Thanks!

Fred

I found the problem. For some reason there was a compilation database sitting inside the modules/http subdirectory, with missing compile commands. I just removed it and let clang tooling pick the commands from the base directory’s compilation database, which has the complete set of compile commands.

the other compilation database might have been added inside the subdirectory by me for testing and I forgot about it :slight_smile: