[PATCH] D87118: Add an explicit toggle for the static analyzer in clang-tidy

Alexander Richardson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 10 10:02:59 PDT 2021


arichardson added inline comments.


================
Comment at: clang/lib/CMakeLists.txt:24
 add_subdirectory(IndexSerialization)
-if(CLANG_ENABLE_STATIC_ANALYZER)
-  add_subdirectory(StaticAnalyzer)
----------------
arichardson wrote:
> thakis wrote:
> > hans wrote:
> > > Why does removing the condition here work?
> > As far as I understand, it just impacts which targets CMake generates. clang/lib/FrontendTool/CMakeLists.txt only adds the dep on clangStaticAnalyzerFrontend if CLANG_ENABLE_STATIC_ANALYZER is set, so this doesn't change what gets built for "clang". If you build all targets, this will now always build the analyzer sources and I suppose it makes it a bit easier to accidentally depend on clangStaticAnalyzerFrontend , but I don't know of another way to be able to link this into clang-tidy when it's not built at all over here.
> I just noticed that my builds (just a plain `ninja`) are compiling all static analyzer sources. I am explicitly passing `-DCLANG_ENABLE_STATIC_ANALYZER=OFF` to cmake (and not building any clang-tools-extra).
> I feel like this was not happening before so it's possible there was some CMake change more recently that is now causing this behaviour.
> 
> I tried setting EXCLUDE_FROM_ALL (https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html) on the directories and targets but that didn't fix the issue for me.
> 
> How about changing the condition to
> `if (CLANG_TIDY_ENABLE_STATIC_ANALYZER OR CLANG_ENABLE_STATIC_ANALYZER)`? Or will that not work since CLANG_TIDY_ENABLE_STATIC_ANALYZER isn't defined yet?
Possible solution: D109611


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87118/new/

https://reviews.llvm.org/D87118



More information about the cfe-commits mailing list