diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2019-08-21 08:48:24 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2019-08-21 08:48:24 +0000 |
commit | 6b9d7c9da591f5b9c322ca85841ffe1daa3cd7cc (patch) | |
tree | ecf0cb37c56d77dd3acc3e4340621fe637ef0bd0 /clang/lib | |
parent | 9cb317968aad29786b9470722ba0903ca1f7a892 (diff) | |
download | bcm5719-llvm-6b9d7c9da591f5b9c322ca85841ffe1daa3cd7cc.tar.gz bcm5719-llvm-6b9d7c9da591f5b9c322ca85841ffe1daa3cd7cc.zip |
Removed some dead code in BugReporter and related files
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66473
llvm-svn: 369504
Diffstat (limited to 'clang/lib')
5 files changed, 8 insertions, 71 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp b/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp index 1b1ffff5ade..73e1a0d0000 100644 --- a/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp @@ -13,7 +13,7 @@ using namespace ento; void AnalysisManager::anchor() { } -AnalysisManager::AnalysisManager(ASTContext &ASTCtx, DiagnosticsEngine &diags, +AnalysisManager::AnalysisManager(ASTContext &ASTCtx, const PathDiagnosticConsumers &PDC, StoreManagerCreator storemgr, ConstraintManagerCreator constraintmgr, @@ -38,7 +38,7 @@ AnalysisManager::AnalysisManager(ASTContext &ASTCtx, DiagnosticsEngine &diags, 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) { diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index c06e0917824..ccf6dcbf622 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2049,8 +2049,6 @@ void BuiltinBug::anchor() {} // Methods for BugReport and subclasses. //===----------------------------------------------------------------------===// -void BugReport::NodeResolver::anchor() {} - void BugReport::addVisitor(std::unique_ptr<BugReporterVisitor> visitor) { if (!visitor) return; @@ -2218,10 +2216,6 @@ const ExplodedGraph &PathSensitiveBugReporter::getGraph() const { return Eng.getGraph(); } -ProgramStateManager &PathSensitiveBugReporter::getStateManager() { - return Eng.getStateManager(); -} - ProgramStateManager &PathSensitiveBugReporter::getStateManager() const { return Eng.getStateManager(); } @@ -2256,11 +2250,9 @@ void BugReporter::FlushReports() { 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<ExplodedGraph> BugPath; BugReport *Report; const ExplodedNode *ErrorNode; @@ -2271,9 +2263,6 @@ public: class BugPathGetter { std::unique_ptr<ExplodedGraph> TrimmedGraph; - /// Map from the trimmed graph to the original. - InterExplodedGraphMap InverseMap; - using PriorityMapTy = llvm::DenseMap<const ExplodedNode *, unsigned>; /// Assign each node with its distance from the root. @@ -2336,7 +2325,7 @@ BugPathGetter::BugPathGetter(const ExplodedGraph *OriginalGraph, // 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 @@ BugPathInfo *BugPathGetter::getNextBugPath() { // Create a new graph with a single path. This is the graph that will be // returned to the caller. auto GNew = std::make_unique<ExplodedGraph>(); - 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 @@ BugPathInfo *BugPathGetter::getNextBugPath() { 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 @@ PathDiagnosticBuilder::findValidReport(ArrayRef<BugReport *> &bugReports, R->addVisitor(std::make_unique<ConditionBRVisitor>()); R->addVisitor(std::make_unique<TagVisitor>()); - BugReporterContext BRC(Reporter, BugPath->MapToOriginNodes); + BugReporterContext BRC(Reporter); // Run all visitors on a given graph, once. std::unique_ptr<VisitorsDiagnosticsTy> visitorNotes = diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index de5af313bc2..f864098a227 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -1166,41 +1166,6 @@ void FindLastStoreBRVisitor::Profile(llvm::FoldingSetNodeID &ID) const { ID.AddBoolean(EnableNullFPSuppression); } -void FindLastStoreBRVisitor::registerStatementVarDecls( - BugReport &BR, const Stmt *S, bool EnableNullFPSuppression, - TrackingKind TKind) { - - const ExplodedNode *N = BR.getErrorNode(); - std::deque<const Stmt *> 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<DeclRefExpr>(Head)) { - if (const auto *VD = dyn_cast<VarDecl>(DR->getDecl())) { - const VarRegion *R = - StateMgr.getRegionManager().getVarRegion(VD, N->getLocationContext()); - - // What did we load? - SVal V = N->getSVal(S); - - if (V.getAs<loc::ConcreteInt>() || V.getAs<nonloc::ConcreteInt>()) { - // Register a new visitor with the BugReport. - BR.addVisitor(std::make_unique<FindLastStoreBRVisitor>( - V.castAs<KnownSVal>(), 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) { diff --git a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index 54fbd6a5bc4..2d3b50082c7 100644 --- a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/clang/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<PathDiagnosticEventPiece>(*P)) - return true; - if (const auto *MP = dyn_cast<PathDiagnosticMacroPiece>(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] != '.') diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index 4989f85e229..0dcb9db932c 100644 --- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -311,9 +311,9 @@ public: checkerMgr = createCheckerManager( *Ctx, *Opts, Plugins, CheckerRegistrationFns, PP.getDiagnostics()); - Mgr = std::make_unique<AnalysisManager>( - *Ctx, PP.getDiagnostics(), PathConsumers, CreateStoreMgr, - CreateConstraintMgr, checkerMgr.get(), *Opts, Injector); + Mgr = std::make_unique<AnalysisManager>(*Ctx, PathConsumers, CreateStoreMgr, + CreateConstraintMgr, + checkerMgr.get(), *Opts, Injector); } /// Store the top level decls in the set to be processed later on. |