Author: jkorous Date: Mon Oct 14 13:15:01 2019 New Revision: 374815 URL: http://llvm.org/viewvc/llvm-project?rev=374815&view=rev Log: [clang-scan-deps] Support for clang --analyze in clang-scan-deps
The goal is to have 100% fidelity in clang-scan-deps behavior when --analyze is present in compilation command. At the same time I don't want to break clang-tidy which expects __static_analyzer__ macro defined as built-in. I introduce new cc1 options (-setup-static-analyzer) that controls the macro definition and is conditionally set in driver. Differential Revision: https://reviews.llvm.org/D68093 Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=374815&r1=374814&r2=374815&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Mon Oct 14 13:15:01 2019 @@ -33,6 +33,7 @@ #include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Lex/PreprocessorOptions.h" #include "clang/Rewrite/Frontend/FixItRewriter.h" #include "clang/Rewrite/Frontend/FrontendActions.h" #include "clang/Tooling/Core/Diagnostic.h" @@ -539,10 +540,8 @@ runClangTidy(clang::tidy::ClangTidyConte FileManager *Files, std::shared_ptr<PCHContainerOperations> PCHContainerOps, DiagnosticConsumer *DiagConsumer) override { - // Explicitly set ProgramAction to RunAnalysis to make the preprocessor - // define __clang_analyzer__ macro. The frontend analyzer action will not - // be called here. - Invocation->getFrontendOpts().ProgramAction = frontend::RunAnalysis; + // Explicitly ask to define __clang_analyzer__ macro. + Invocation->getPreprocessorOpts().SetUpStaticAnalyzer = true; return FrontendActionFactory::runInvocation( Invocation, Files, PCHContainerOps, DiagConsumer); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits