[cfe-dev] Clang Static Checker Library Detection Problems
Anna Zaks
ganna at apple.com
Thu Jun 26 10:04:31 PDT 2014
> On Jun 25, 2014, at 12:43 PM, Alexandros Tzannes <tzannes at cs.umd.edu> wrote:
>
> 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.
The problem is that when you are calling "clang -cc1", you are not going through the driver: http://clang.llvm.org/docs/FAQ.html
You should not call "clang -cc1 -analyze", but instead use either scan-build or "clang -std=c++11 --analyze main.cpp". You can pass "-Xclang -analyzer-checker=myChecker" to the driver to make sure it runs your checker. The main difference would be that it will run the other analyzer checkers as well. (Note that you should ALWAYS run analyzer checkers from core package - they are necessary for the analyzer's path sensitive reasoning.)
Hope this helps,
Anna.
>
> 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
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list