Linking to libclangStaticAnalyzer out-of-tree

Hi,

I plan to implement a stand-alone tool based off of libTooling
infrastructure that includes both AST and Analyzer Frontend actions.
Think of it as a clone of clang-check.

I intend to build this tool outside of the LLVM/Clang source tree.
Naturally, I have added libclangStaticAnalyzer* libraries to the link
section of my tool's cmake file.

Problem is, a handful of clang SA symbols are unresolved at link time.
Most of them have to do with const strings in the
clang::ento::categories namespace. Any ideas why this is happening and
how it can be fixed? FWIW, I tried to build against LLVM source tree
*and* an ubuntu installation of libclang-dev libraries. Both lead to the
following set of (sample) link-time errors.

llvm/tools/clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp:200:
error: undefined reference to
'clang::ento::categories::CoreFoundationObjectiveC'
lvm/tools/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h:70:
error: undefined reference to 'clang::ento::categories::LogicError'
llvm/tools/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:239:
error: undefined reference to 'clang::ento::categories::UnixAPI'

Thanks,
Bhargava

Hi,

I plan to implement a stand-alone tool based off of libTooling
infrastructure that includes both AST and Analyzer Frontend actions.
Think of it as a clone of clang-check.

We have clang-tidy. Have you seen that? It allows to implement your own AST based checks, and comes with analyzer checks out of the box.

It would help to have some easy-to-find information about where clang-tidy lives:

The documentation (Clang-Tidy — Extra Clang Tools 16.0.0git documentation) says that it’s in llvm/tools/clang/tools/extra, but tools/extra doesn’t exist in the cfe repository, so presumably needs to be checked out separately. Digging around in the repo, I find that there’s a top-level clang-tools-extra directory that should presumably be checked out into llvm/tools/clang/tools as extra, but I can’t find anything telling me this explicitly.

David

http://clang.llvm.org/docs/ClangTools.html

covers that, although SEO is not good for that page…