Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -74,16 +74,6 @@ /// individual bug reports. class BugReport : public llvm::ilist_node { public: - class NodeResolver { - virtual void anchor(); - - public: - virtual ~NodeResolver() = default; - - virtual const ExplodedNode* - getOriginalNode(const ExplodedNode *N) = 0; - }; - using ranges_iterator = const SourceRange *; using VisitorList = SmallVector, 8>; using visitor_iterator = VisitorList::iterator; @@ -391,7 +381,6 @@ public: virtual ~BugReporterData() = default; - virtual DiagnosticsEngine& getDiagnostic() = 0; virtual ArrayRef getPathDiagnosticConsumers() = 0; virtual ASTContext &getASTContext() = 0; virtual SourceManager &getSourceManager() = 0; @@ -404,11 +393,7 @@ /// /// The base class is used for generating path-insensitive class BugReporter { -public: - enum Kind { BasicBRKind, PathSensitiveBRKind }; - private: - const Kind kind; BugReporterData& D; /// Generate and flush the diagnostics for the given bug report. @@ -426,23 +411,13 @@ /// A vector of BugReports for tracking the allocated pointers and cleanup. std::vector EQClassesVector; -protected: - BugReporter(BugReporterData& d, Kind k) - : kind(k), D(d) {} - public: - BugReporter(BugReporterData &d) : kind(BasicBRKind), D(d) {} + BugReporter(BugReporterData &d) : D(d) {} virtual ~BugReporter(); /// Generate and flush diagnostics for all bug reports. void FlushReports(); - Kind getKind() const { return kind; } - - DiagnosticsEngine& getDiagnostic() { - return D.getDiagnostic(); - } - ArrayRef getPathDiagnosticConsumers() { return D.getPathDiagnosticConsumers(); } @@ -496,7 +471,7 @@ public: PathSensitiveBugReporter(BugReporterData& d, ExprEngine& eng) - : BugReporter(d, PathSensitiveBRKind), Eng(eng) {} + : BugReporter(d), Eng(eng) {} /// getGraph - Get the exploded graph created by the analysis engine /// for the analyzed method or function. @@ -504,8 +479,6 @@ /// getStateManager - Return the state manager used by the analysis /// engine. - ProgramStateManager &getStateManager(); - ProgramStateManager &getStateManager() const; /// \p bugReports A set of bug reports within a *single* equivalence class @@ -516,50 +489,25 @@ std::unique_ptr generatePathDiagnostics(ArrayRef consumers, ArrayRef &bugReports) override; - - /// classof - Used by isa<>, cast<>, and dyn_cast<>. - static bool classof(const BugReporter* R) { - return R->getKind() == PathSensitiveBRKind; - } }; -class NodeMapClosure : public BugReport::NodeResolver { - InterExplodedGraphMap &M; - -public: - NodeMapClosure(InterExplodedGraphMap &m) : M(m) {} - - const ExplodedNode *getOriginalNode(const ExplodedNode *N) override { - return M.lookup(N); - } -}; - class BugReporterContext { PathSensitiveBugReporter &BR; - NodeMapClosure NMC; virtual void anchor(); public: - BugReporterContext(PathSensitiveBugReporter &br, - InterExplodedGraphMap &Backmap) - : BR(br), NMC(Backmap) {} + BugReporterContext(PathSensitiveBugReporter &br) : BR(br) {} virtual ~BugReporterContext() = default; PathSensitiveBugReporter& getBugReporter() { return BR; } - const ExplodedGraph &getGraph() const { return BR.getGraph(); } - ProgramStateManager& getStateManager() const { return BR.getStateManager(); } - SValBuilder &getSValBuilder() const { - return getStateManager().getSValBuilder(); - } - ASTContext &getASTContext() const { return BR.getContext(); } @@ -571,8 +519,6 @@ const AnalyzerOptions &getAnalyzerOptions() const { return BR.getAnalyzerOptions(); } - - NodeMapClosure& getNodeResolver() { return NMC; } }; Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h @@ -135,12 +135,6 @@ const StackFrameContext *OriginSFC; public: - /// Creates a visitor for every VarDecl inside a Stmt and registers it with - /// the BugReport. - static void registerStatementVarDecls(BugReport &BR, const Stmt *S, - bool EnableNullFPSuppression, - TrackingKind TKind); - /// \param V We're searching for the store where \c R received this value. /// \param R The region we're tracking. /// \param TKind May limit the amount of notes added to the bug report. Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h @@ -735,8 +735,6 @@ PathPieces subPieces; - bool containsEvent() const; - void flattenLocations() override { PathDiagnosticSpotPiece::flattenLocations(); for (const auto &I : subPieces) Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h @@ -32,7 +32,6 @@ AnalysisDeclContextManager AnaCtxMgr; ASTContext &Ctx; - DiagnosticsEngine &Diags; const LangOptions &LangOpts; PathDiagnosticConsumers PathConsumers; @@ -45,7 +44,7 @@ public: AnalyzerOptions &options; - AnalysisManager(ASTContext &ctx, DiagnosticsEngine &diags, + AnalysisManager(ASTContext &ctx, const PathDiagnosticConsumers &Consumers, StoreManagerCreator storemgr, ConstraintManagerCreator constraintmgr, @@ -84,10 +83,6 @@ return getASTContext().getSourceManager(); } - DiagnosticsEngine &getDiagnostic() override { - return Diags; - } - const LangOptions &getLangOpts() const { return LangOpts; } Index: cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp @@ -13,7 +13,7 @@ void AnalysisManager::anchor() { } -AnalysisManager::AnalysisManager(ASTContext &ASTCtx, DiagnosticsEngine &diags, +AnalysisManager::AnalysisManager(ASTContext &ASTCtx, const PathDiagnosticConsumers &PDC, StoreManagerCreator storemgr, ConstraintManagerCreator constraintmgr, @@ -38,7 +38,7 @@ Options.ShouldElideConstructors, /*addVirtualBaseBranches=*/true, injector), - Ctx(ASTCtx), Diags(diags), LangOpts(ASTCtx.getLangOpts()), + Ctx(ASTCtx), LangOpts(ASTCtx.getLangOpts()), PathConsumers(PDC), CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr), options(Options) { Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2049,8 +2049,6 @@ // Methods for BugReport and subclasses. //===----------------------------------------------------------------------===// -void BugReport::NodeResolver::anchor() {} - void BugReport::addVisitor(std::unique_ptr visitor) { if (!visitor) return; @@ -2218,10 +2216,6 @@ return Eng.getGraph(); } -ProgramStateManager &PathSensitiveBugReporter::getStateManager() { - return Eng.getStateManager(); -} - ProgramStateManager &PathSensitiveBugReporter::getStateManager() const { return Eng.getStateManager(); } @@ -2256,11 +2250,9 @@ namespace { /// A wrapper around an ExplodedGraph that contains a single path from the root -/// to the error node, and a map that maps the nodes in this path to the ones in -/// the original ExplodedGraph. +/// to the error node. class BugPathInfo { public: - InterExplodedGraphMap MapToOriginNodes; std::unique_ptr BugPath; BugReport *Report; const ExplodedNode *ErrorNode; @@ -2271,9 +2263,6 @@ class BugPathGetter { std::unique_ptr TrimmedGraph; - /// Map from the trimmed graph to the original. - InterExplodedGraphMap InverseMap; - using PriorityMapTy = llvm::DenseMap; /// Assign each node with its distance from the root. @@ -2336,7 +2325,7 @@ // The trimmed graph is created in the body of the constructor to ensure // that the DenseMaps have been initialized already. InterExplodedGraphMap ForwardMap; - TrimmedGraph = OriginalGraph->trim(Nodes, &ForwardMap, &InverseMap); + TrimmedGraph = OriginalGraph->trim(Nodes, &ForwardMap); // Find the (first) error node in the trimmed graph. We just need to consult // the node map which maps from nodes in the original graph to nodes @@ -2399,7 +2388,6 @@ // Create a new graph with a single path. This is the graph that will be // returned to the caller. auto GNew = std::make_unique(); - CurrentBugPath.MapToOriginNodes.clear(); // Now walk from the error node up the BFS path, always taking the // predeccessor with the lowest number. @@ -2410,11 +2398,6 @@ ExplodedNode *NewN = GNew->createUncachedNode( OrigN->getLocation(), OrigN->getState(), OrigN->isSink()); - // Store the mapping to the original node. - InterExplodedGraphMap::const_iterator IMitr = InverseMap.find(OrigN); - assert(IMitr != InverseMap.end() && "No mapping to original node."); - CurrentBugPath.MapToOriginNodes[NewN] = IMitr->second; - // Link up the new node with the previous node. if (Succ) Succ->addPredecessor(NewN, *GNew); @@ -2613,7 +2596,7 @@ R->addVisitor(std::make_unique()); R->addVisitor(std::make_unique()); - BugReporterContext BRC(Reporter, BugPath->MapToOriginNodes); + BugReporterContext BRC(Reporter); // Run all visitors on a given graph, once. std::unique_ptr visitorNotes = Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -1166,41 +1166,6 @@ ID.AddBoolean(EnableNullFPSuppression); } -void FindLastStoreBRVisitor::registerStatementVarDecls( - BugReport &BR, const Stmt *S, bool EnableNullFPSuppression, - TrackingKind TKind) { - - const ExplodedNode *N = BR.getErrorNode(); - std::deque WorkList; - WorkList.push_back(S); - - while (!WorkList.empty()) { - const Stmt *Head = WorkList.front(); - WorkList.pop_front(); - - ProgramStateManager &StateMgr = N->getState()->getStateManager(); - - if (const auto *DR = dyn_cast(Head)) { - if (const auto *VD = dyn_cast(DR->getDecl())) { - const VarRegion *R = - StateMgr.getRegionManager().getVarRegion(VD, N->getLocationContext()); - - // What did we load? - SVal V = N->getSVal(S); - - if (V.getAs() || V.getAs()) { - // Register a new visitor with the BugReport. - BR.addVisitor(std::make_unique( - V.castAs(), R, EnableNullFPSuppression, TKind)); - } - } - } - - for (const Stmt *SubStmt : Head->children()) - WorkList.push_back(SubStmt); - } -} - /// Returns true if \p N represents the DeclStmt declaring and initializing /// \p VR. static bool isInitializationOfVar(const ExplodedNode *N, const VarRegion *VR) { Index: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -53,17 +53,6 @@ using namespace clang; using namespace ento; -bool PathDiagnosticMacroPiece::containsEvent() const { - for (const auto &P : subPieces) { - if (isa(*P)) - return true; - if (const auto *MP = dyn_cast(P.get())) - if (MP->containsEvent()) - return true; - } - return false; -} - static StringRef StripTrailingDots(StringRef s) { for (StringRef::size_type i = s.size(); i != 0; --i) if (s[i - 1] != '.') Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -311,9 +311,9 @@ checkerMgr = createCheckerManager( *Ctx, *Opts, Plugins, CheckerRegistrationFns, PP.getDiagnostics()); - Mgr = std::make_unique( - *Ctx, PP.getDiagnostics(), PathConsumers, CreateStoreMgr, - CreateConstraintMgr, checkerMgr.get(), *Opts, Injector); + Mgr = std::make_unique(*Ctx, PathConsumers, CreateStoreMgr, + CreateConstraintMgr, + checkerMgr.get(), *Opts, Injector); } /// Store the top level decls in the set to be processed later on. Index: cfe/trunk/unittests/StaticAnalyzer/Reusables.h =================================================================== --- cfe/trunk/unittests/StaticAnalyzer/Reusables.h +++ cfe/trunk/unittests/StaticAnalyzer/Reusables.h @@ -58,7 +58,7 @@ ExprEngineConsumer(CompilerInstance &C) : C(C), ChkMgr(C.getASTContext(), *C.getAnalyzerOpts()), CTU(C), Consumers(), - AMgr(C.getASTContext(), C.getDiagnostics(), Consumers, + AMgr(C.getASTContext(), Consumers, CreateRegionStoreManager, CreateRangeConstraintManager, &ChkMgr, *C.getAnalyzerOpts()), VisitedCallees(), FS(),