Index: include/clang/StaticAnalyzer/Core/CheckerManager.h =================================================================== --- include/clang/StaticAnalyzer/Core/CheckerManager.h +++ include/clang/StaticAnalyzer/Core/CheckerManager.h @@ -115,13 +115,14 @@ }; class CheckerManager { + ASTContext &Context; const LangOptions LangOpts; AnalyzerOptions &AOptions; CheckName CurrentCheckName; public: - CheckerManager(const LangOptions &langOpts, AnalyzerOptions &AOptions) - : LangOpts(langOpts), AOptions(AOptions) {} + CheckerManager(ASTContext &Context, AnalyzerOptions &AOptions) + : Context(Context), LangOpts(Context.getLangOpts()), AOptions(AOptions) {} ~CheckerManager(); @@ -134,6 +135,7 @@ const LangOptions &getLangOpts() const { return LangOpts; } AnalyzerOptions &getAnalyzerOptions() { return AOptions; } + ASTContext &getASTContext() { return Context; } using CheckerRef = CheckerBase *; using CheckerTag = const void *; Index: include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h =================================================================== --- include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h @@ -46,14 +46,12 @@ public: AnalyzerOptions &options; - AnalysisManager(ASTContext &ctx,DiagnosticsEngine &diags, - const LangOptions &lang, + AnalysisManager(ASTContext &ctx, DiagnosticsEngine &diags, const PathDiagnosticConsumers &Consumers, StoreManagerCreator storemgr, ConstraintManagerCreator constraintmgr, - CheckerManager *checkerMgr, - AnalyzerOptions &Options, - CodeInjector* injector = nullptr); + CheckerManager *checkerMgr, AnalyzerOptions &Options, + CodeInjector *injector = nullptr); ~AnalysisManager() override; Index: include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h =================================================================== --- include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h +++ include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h @@ -10,6 +10,7 @@ #ifndef LLVM_CLANG_STATICANALYZER_FRONTEND_CHECKERREGISTRATION_H #define LLVM_CLANG_STATICANALYZER_FRONTEND_CHECKERREGISTRATION_H +#include "clang/AST/ASTContext.h" #include "clang/Basic/LLVM.h" #include #include @@ -25,7 +26,8 @@ class CheckerRegistry; std::unique_ptr createCheckerManager( - AnalyzerOptions &opts, const LangOptions &langOpts, + ASTContext &context, + AnalyzerOptions &opts, ArrayRef plugins, ArrayRef> checkerRegistrationFns, DiagnosticsEngine &diags); Index: lib/StaticAnalyzer/Core/AnalysisManager.cpp =================================================================== --- lib/StaticAnalyzer/Core/AnalysisManager.cpp +++ lib/StaticAnalyzer/Core/AnalysisManager.cpp @@ -14,28 +14,28 @@ void AnalysisManager::anchor() { } -AnalysisManager::AnalysisManager( - ASTContext &ASTCtx, DiagnosticsEngine &diags, const LangOptions &lang, - const PathDiagnosticConsumers &PDC, StoreManagerCreator storemgr, - ConstraintManagerCreator constraintmgr, CheckerManager *checkerMgr, - AnalyzerOptions &Options, CodeInjector *injector) - : AnaCtxMgr(ASTCtx, Options.UnoptimizedCFG, - Options.includeImplicitDtorsInCFG(), - /*AddInitializers=*/true, Options.includeTemporaryDtorsInCFG(), - Options.includeLifetimeInCFG(), - // Adding LoopExit elements to the CFG is a requirement for loop - // unrolling. - Options.includeLoopExitInCFG() || Options.shouldUnrollLoops(), - Options.includeScopesInCFG(), - Options.shouldSynthesizeBodies(), - Options.shouldConditionalizeStaticInitializers(), - /*addCXXNewAllocator=*/true, - Options.includeRichConstructorsInCFG(), - Options.shouldElideConstructors(), - injector), - Ctx(ASTCtx), Diags(diags), LangOpts(lang), PathConsumers(PDC), - CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr), - CheckerMgr(checkerMgr), options(Options) { +AnalysisManager::AnalysisManager(ASTContext &ASTCtx, DiagnosticsEngine &diags, + const PathDiagnosticConsumers &PDC, + StoreManagerCreator storemgr, + ConstraintManagerCreator constraintmgr, + CheckerManager *checkerMgr, + AnalyzerOptions &Options, + CodeInjector *injector) + : AnaCtxMgr( + ASTCtx, Options.UnoptimizedCFG, Options.includeImplicitDtorsInCFG(), + /*AddInitializers=*/true, Options.includeTemporaryDtorsInCFG(), + Options.includeLifetimeInCFG(), + // Adding LoopExit elements to the CFG is a requirement for loop + // unrolling. + Options.includeLoopExitInCFG() || Options.shouldUnrollLoops(), + Options.includeScopesInCFG(), Options.shouldSynthesizeBodies(), + Options.shouldConditionalizeStaticInitializers(), + /*addCXXNewAllocator=*/true, Options.includeRichConstructorsInCFG(), + Options.shouldElideConstructors(), injector), + Ctx(ASTCtx), Diags(diags), LangOpts(ASTCtx.getLangOpts()), + PathConsumers(PDC), CreateStoreMgr(storemgr), + CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr), + options(Options) { AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd(); } Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp =================================================================== --- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -295,13 +295,12 @@ void Initialize(ASTContext &Context) override { Ctx = &Context; - checkerMgr = - createCheckerManager(*Opts, PP.getLangOpts(), Plugins, - CheckerRegistrationFns, PP.getDiagnostics()); + checkerMgr = createCheckerManager( + *Ctx, *Opts, Plugins, CheckerRegistrationFns, PP.getDiagnostics()); Mgr = llvm::make_unique( - *Ctx, PP.getDiagnostics(), PP.getLangOpts(), PathConsumers, - CreateStoreMgr, CreateConstraintMgr, checkerMgr.get(), *Opts, Injector); + *Ctx, PP.getDiagnostics(), PathConsumers, CreateStoreMgr, + CreateConstraintMgr, checkerMgr.get(), *Opts, Injector); } /// Store the top level decls in the set to be processed later on. Index: lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp =================================================================== --- lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp +++ lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp @@ -112,12 +112,12 @@ } std::unique_ptr ento::createCheckerManager( - AnalyzerOptions &opts, const LangOptions &langOpts, + ASTContext &context, + AnalyzerOptions &opts, ArrayRef plugins, ArrayRef> checkerRegistrationFns, DiagnosticsEngine &diags) { - std::unique_ptr checkerMgr( - new CheckerManager(langOpts, opts)); + auto checkerMgr = llvm::make_unique(context, opts); SmallVector checkerOpts = getCheckerOptList(opts);