[cfe-commits] r66622 - /cfe/trunk/lib/Analysis/GRExprEngine.cpp
Ted Kremenek
kremenek at apple.com
Tue Mar 10 18:41:22 PDT 2009
Author: kremenek
Date: Tue Mar 10 20:41:22 2009
New Revision: 66622
URL: http://llvm.org/viewvc/llvm-project?rev=66622&view=rev
Log:
Use the BugReports in BugReporter to determine the root nodes for "trim-egraph".
Modified:
cfe/trunk/lib/Analysis/GRExprEngine.cpp
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=66622&r1=66621&r2=66622&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Tue Mar 10 20:41:22 2009
@@ -3015,7 +3015,6 @@
#endif
#ifndef NDEBUG
-
template <typename ITERATOR>
GRExprEngine::NodeTy* GetGraphNode(ITERATOR I) { return *I; }
@@ -3025,42 +3024,27 @@
(llvm::DenseMap<GRExprEngine::NodeTy*, Expr*>::iterator I) {
return I->first;
}
-
-template <typename ITERATOR>
-static void AddSources(std::vector<GRExprEngine::NodeTy*>& Sources,
- ITERATOR I, ITERATOR E) {
-
- llvm::SmallSet<ProgramPoint,10> 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<NodeTy*> 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<BugType*>(*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<NodeTy*>(R.getEndNode());
+ if (N) Src.push_back(N);
+ }
+ }
ViewGraph(&Src[0], &Src[0]+Src.size());
}
More information about the cfe-commits
mailing list