Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h =================================================================== --- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -17,12 +17,13 @@ #include "clang/Analysis/PathDiagnostic.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" +#include "clang/Lex/Preprocessor.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/FoldingSet.h" @@ -566,6 +567,7 @@ virtual ASTContext &getASTContext() = 0; virtual SourceManager &getSourceManager() = 0; virtual AnalyzerOptions &getAnalyzerOptions() = 0; + virtual Preprocessor &getPreprocessor() = 0; }; /// BugReporter is a utility class for generating PathDiagnostics for analysis. @@ -608,6 +610,8 @@ const AnalyzerOptions &getAnalyzerOptions() { return D.getAnalyzerOptions(); } + Preprocessor &getPreprocessor() { return D.getPreprocessor(); } + /// Add the given report to the set of reports tracked by BugReporter. /// /// The reports are usually generated by the checkers. Further, they are 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 @@ -16,6 +16,7 @@ #include "clang/Analysis/AnalysisDeclContext.h" #include "clang/Analysis/PathDiagnostic.h" +#include "clang/Lex/Preprocessor.h" #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h" @@ -32,6 +33,7 @@ AnalysisDeclContextManager AnaCtxMgr; ASTContext &Ctx; + Preprocessor &PP; const LangOptions &LangOpts; PathDiagnosticConsumers PathConsumers; @@ -44,7 +46,7 @@ public: AnalyzerOptions &options; - AnalysisManager(ASTContext &ctx, + AnalysisManager(ASTContext &ctx, Preprocessor &PP, const PathDiagnosticConsumers &Consumers, StoreManagerCreator storemgr, ConstraintManagerCreator constraintmgr, @@ -61,6 +63,8 @@ return AnaCtxMgr; } + Preprocessor &getPreprocessor() override { return PP; } + StoreManagerCreator getStoreManagerCreator() { return CreateStoreMgr; } Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h =================================================================== --- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h +++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h @@ -107,6 +107,8 @@ return getBugReporter().getSourceManager(); } + Preprocessor &getPreprocessor() { return getBugReporter().getPreprocessor(); } + SValBuilder &getSValBuilder() { return Eng.getSValBuilder(); } Index: clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp +++ clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp @@ -13,7 +13,7 @@ void AnalysisManager::anchor() { } -AnalysisManager::AnalysisManager(ASTContext &ASTCtx, +AnalysisManager::AnalysisManager(ASTContext &ASTCtx, Preprocessor &PP, const PathDiagnosticConsumers &PDC, StoreManagerCreator storemgr, ConstraintManagerCreator constraintmgr, @@ -38,7 +38,7 @@ Options.ShouldElideConstructors, /*addVirtualBaseBranches=*/true, injector), - Ctx(ASTCtx), LangOpts(ASTCtx.getLangOpts()), + Ctx(ASTCtx), PP(PP), LangOpts(ASTCtx.getLangOpts()), 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 @@ -192,7 +192,7 @@ public: ASTContext *Ctx; - const Preprocessor &PP; + Preprocessor &PP; const std::string OutDir; AnalyzerOptionsRef Opts; ArrayRef Plugins; @@ -335,8 +335,8 @@ checkerMgr = createCheckerManager( *Ctx, *Opts, Plugins, CheckerRegistrationFns, PP.getDiagnostics()); - Mgr = std::make_unique(*Ctx, PathConsumers, CreateStoreMgr, - CreateConstraintMgr, + Mgr = std::make_unique(*Ctx, PP, PathConsumers, + CreateStoreMgr, CreateConstraintMgr, checkerMgr.get(), *Opts, Injector); } Index: clang/unittests/StaticAnalyzer/Reusables.h =================================================================== --- clang/unittests/StaticAnalyzer/Reusables.h +++ clang/unittests/StaticAnalyzer/Reusables.h @@ -58,7 +58,7 @@ ExprEngineConsumer(CompilerInstance &C) : C(C), ChkMgr(C.getASTContext(), *C.getAnalyzerOpts()), CTU(C), Consumers(), - AMgr(C.getASTContext(), Consumers, + AMgr(C.getASTContext(), C.getPreprocessor(), Consumers, CreateRegionStoreManager, CreateRangeConstraintManager, &ChkMgr, *C.getAnalyzerOpts()), VisitedCallees(), FS(),