[cfe-dev] Clang Static Checker Library Detection Problems

Alexandros Tzannes tzannes at cs.umd.edu
Wed Jun 25 12:43:28 PDT 2014


Hey all,
I am writing a custom static checker in Clang and I get an unexpected 
behavior with #include directives. Say I have a simple hello-world 
main.cpp source code that #includes stdio.h. When I compile a source 
file with clang without invoking the checker (e.g., clang++ -std=c++11 
main.cpp), it compiles as expected. But when I call the checker: clang++ 
-cc1 -std=c++11 -analyze -analyzer-checker=myChecker main.cpp I get an 
error  'stdio.h' file not found.

My current work around is to call the first clang++ command above with 
the verbose flag (-v) and copy-paste all the flags the wrapper is 
passing to clang++ -cc1, but I'm wondering if there is a better 
approach. This approach is suboptimal because it prevents me from 
creating custom tests that are platform-independent (because the flags I 
copy-paste have paths that are specific to my computer). Am I for 
example supposed to provide any extra flags when I configure my custom 
LLVM/Clang build? In case this is relevant, I am building on Ubuntu 
14.04 and configure without any additional flags. Interestingly, one of 
my collaborators is having the reverse problem. Library headers are 
automatically located when he calls clang++ -cc1, but not when the -cc1 
flag is missing.

Am I configuring Clang/LLVM improperly? What am I missing?

Cheers!
Alex





More information about the cfe-dev mailing list