From 940abcc574580e454689be801f38a3d4d41ab01f Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 11 Mar 2009 01:41:22 +0000 Subject: [PATCH] Use the BugReports in BugReporter to determine the root nodes for "trim-egraph". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66622 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/GRExprEngine.cpp | 46 ++++++++++++----------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index f2e4b18992..222ef173e8 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -3015,7 +3015,6 @@ struct VISIBILITY_HIDDEN DOTGraphTraits : #endif #ifndef NDEBUG - template GRExprEngine::NodeTy* GetGraphNode(ITERATOR I) { return *I; } @@ -3025,42 +3024,27 @@ GetGraphNode::iterator> (llvm::DenseMap::iterator I) { return I->first; } - -template -static void AddSources(std::vector& Sources, - ITERATOR I, ITERATOR E) { - - llvm::SmallSet CachedSources; - - for ( ; I != E; ++I ) { - GRExprEngine::NodeTy* N = GetGraphNode(I); - ProgramPoint P = N->getLocation(); - - if (CachedSources.count(P)) - continue; - - CachedSources.insert(P); - Sources.push_back(N); - } -} #endif void GRExprEngine::ViewGraph(bool trim) { #ifndef NDEBUG if (trim) { std::vector Src; - - // FIXME: Migrate over to the new way of adding nodes. - AddSources(Src, null_derefs_begin(), null_derefs_end()); - AddSources(Src, undef_derefs_begin(), undef_derefs_end()); - AddSources(Src, explicit_bad_divides_begin(), explicit_bad_divides_end()); - AddSources(Src, undef_results_begin(), undef_results_end()); - AddSources(Src, bad_calls_begin(), bad_calls_end()); - AddSources(Src, undef_arg_begin(), undef_arg_end()); - AddSources(Src, undef_branches_begin(), undef_branches_end()); - - // FIXME: Enhance BugReporter to have a clean way to query if a node - // is involved in an error... and what kind. + + // Flush any outstanding reports to make sure we cover all the nodes. + // This does not cause them to get displayed. + for (BugReporter::iterator I=BR.begin(), E=BR.end(); I!=E; ++I) + const_cast(*I)->FlushReports(BR); + + // Iterate through the reports and get their nodes. + for (BugReporter::iterator I=BR.begin(), E=BR.end(); I!=E; ++I) { + for (BugType::const_iterator I2=(*I)->begin(), E2=(*I)->end(); I2!=E2; ++I2) { + const BugReportEquivClass& EQ = *I2; + const BugReport &R = **EQ.begin(); + NodeTy *N = const_cast(R.getEndNode()); + if (N) Src.push_back(N); + } + } ViewGraph(&Src[0], &Src[0]+Src.size()); } -- 2.40.0