Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h =================================================================== --- clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h +++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h @@ -35,6 +35,7 @@ ASTContext &Ctx; Preprocessor &PP; const LangOptions &LangOpts; + const CodeGenOptions &CodeGenOpts; PathDiagnosticConsumers PathConsumers; // Configurable components creators. @@ -51,6 +52,7 @@ StoreManagerCreator storemgr, ConstraintManagerCreator constraintmgr, CheckerManager *checkerMgr, AnalyzerOptions &Options, + const CodeGenOptions &CGOpts, CodeInjector *injector = nullptr); ~AnalysisManager() override; @@ -73,6 +75,8 @@ return options; } + const CodeGenOptions &getCodeGenOptions() const { return CodeGenOpts; } + ConstraintManagerCreator getConstraintManagerCreator() { return CreateConstraintMgr; } Index: clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp +++ clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp @@ -13,32 +13,26 @@ void AnalysisManager::anchor() { } -AnalysisManager::AnalysisManager(ASTContext &ASTCtx, Preprocessor &PP, - const PathDiagnosticConsumers &PDC, - StoreManagerCreator storemgr, - ConstraintManagerCreator constraintmgr, - CheckerManager *checkerMgr, - AnalyzerOptions &Options, - CodeInjector *injector) +AnalysisManager::AnalysisManager( + ASTContext &ASTCtx, Preprocessor &PP, const PathDiagnosticConsumers &PDC, + StoreManagerCreator storemgr, ConstraintManagerCreator constraintmgr, + CheckerManager *checkerMgr, AnalyzerOptions &Options, + const CodeGenOptions &CGOpts, CodeInjector *injector) : AnaCtxMgr( ASTCtx, Options.UnoptimizedCFG, Options.ShouldIncludeImplicitDtorsInCFG, - /*addInitializers=*/true, - Options.ShouldIncludeTemporaryDtorsInCFG, + /*addInitializers=*/true, Options.ShouldIncludeTemporaryDtorsInCFG, Options.ShouldIncludeLifetimeInCFG, // Adding LoopExit elements to the CFG is a requirement for loop // unrolling. - Options.ShouldIncludeLoopExitInCFG || - Options.ShouldUnrollLoops, - Options.ShouldIncludeScopesInCFG, - Options.ShouldSynthesizeBodies, + Options.ShouldIncludeLoopExitInCFG || Options.ShouldUnrollLoops, + Options.ShouldIncludeScopesInCFG, Options.ShouldSynthesizeBodies, Options.ShouldConditionalizeStaticInitializers, /*addCXXNewAllocator=*/true, Options.ShouldIncludeRichConstructorsInCFG, Options.ShouldElideConstructors, - /*addVirtualBaseBranches=*/true, - injector), - Ctx(ASTCtx), PP(PP), LangOpts(ASTCtx.getLangOpts()), + /*addVirtualBaseBranches=*/true, injector), + Ctx(ASTCtx), PP(PP), LangOpts(ASTCtx.getLangOpts()), CodeGenOpts(CGOpts), PathConsumers(PDC), CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr), options(Options) { Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp =================================================================== --- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -88,6 +88,7 @@ Preprocessor &PP; const std::string OutDir; AnalyzerOptionsRef Opts; + const CodeGenOptions &CodeGenOpts; ArrayRef Plugins; CodeInjector *Injector; cross_tu::CrossTranslationUnitContext CTU; @@ -121,11 +122,11 @@ FunctionSummariesTy FunctionSummaries; AnalysisConsumer(CompilerInstance &CI, const std::string &outdir, - AnalyzerOptionsRef opts, ArrayRef plugins, - CodeInjector *injector) + AnalyzerOptionsRef opts, const CodeGenOptions &CGOpts, + ArrayRef plugins, CodeInjector *injector) : RecVisitorMode(0), RecVisitorBR(nullptr), Ctx(nullptr), PP(CI.getPreprocessor()), OutDir(outdir), Opts(std::move(opts)), - Plugins(plugins), Injector(injector), CTU(CI), + CodeGenOpts(CGOpts), Plugins(plugins), Injector(injector), CTU(CI), MacroExpansions(CI.getLangOpts()) { DigestAnalyzerOptions(); if (Opts->AnalyzerDisplayProgress || Opts->PrintStats || @@ -231,9 +232,9 @@ checkerMgr = std::make_unique(*Ctx, *Opts, PP, Plugins, CheckerRegistrationFns); - Mgr = std::make_unique(*Ctx, PP, PathConsumers, - CreateStoreMgr, CreateConstraintMgr, - checkerMgr.get(), *Opts, Injector); + Mgr = std::make_unique( + *Ctx, PP, PathConsumers, CreateStoreMgr, CreateConstraintMgr, + checkerMgr.get(), *Opts, CodeGenOpts, Injector); } /// Store the top level decls in the set to be processed later on. @@ -712,7 +713,7 @@ bool hasModelPath = analyzerOpts->Config.count("model-path") > 0; return std::make_unique( - CI, CI.getFrontendOpts().OutputFile, analyzerOpts, + CI, CI.getFrontendOpts().OutputFile, analyzerOpts, CI.getCodeGenOpts(), CI.getFrontendOpts().Plugins, hasModelPath ? new ModelInjector(CI) : nullptr); }