[cfe-commits] r68228 - /cfe/trunk/lib/Analysis/BugReporter.cpp
Ted Kremenek
kremenek at apple.com
Wed Apr 1 11:48:56 PDT 2009
Author: kremenek
Date: Wed Apr 1 13:48:52 2009
New Revision: 68228
URL: http://llvm.org/viewvc/llvm-project?rev=68228&view=rev
Log:
BugReporter: for extensive path diagnostics:
- When processing BlockEdges with terminators, using the condition as the
control-flow point for terminators that are expressions (e.g., '&&', '?')
- When processing events, allow intra-compound statement "jumping"
Modified:
cfe/trunk/lib/Analysis/BugReporter.cpp
Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=68228&r1=68227&r2=68228&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Wed Apr 1 13:48:52 2009
@@ -810,12 +810,8 @@
if (const ForStmt *FS = dyn_cast<ForStmt>(Parent))
return FS->getInit() == DS;
- // FIXME: In the future IfStmt/WhileStmt may contain DeclStmts in their condition.
-// if (const IfStmt *IF = dyn_cast<IfStmt>(Parent))
-// return IF->getCond() == DS;
-//
-// if (const WhileStmt *WS = dyn_cast<WhileStmt>(Parent))
-// return WS->getCond() == DS;
+ // FIXME: In the future IfStmt/WhileStmt may contain DeclStmts in their
+ // condition.
return false;
}
@@ -847,11 +843,13 @@
}
if (const Stmt *Term = Blk.getTerminator()) {
- const Stmt *Cond = Blk.getTerminatorCondition();
-
+ const Stmt *Cond = Blk.getTerminatorCondition();
if (!Cond || !IsControlFlowExpr(Cond)) {
- GenExtAddEdge(PD, PDB, PathDiagnosticLocation(Term, SMgr), PrevLoc,
- true);
+ // For terminators that are control-flow expressions like '&&', '?',
+ // have the condition be the anchor point for the control-flow edge
+ // instead of the terminator.
+ const Stmt *X = isa<Expr>(Term) ? (Cond ? Cond : Term) : Term;
+ GenExtAddEdge(PD, PDB, PathDiagnosticLocation(X, SMgr), PrevLoc,true);
continue;
}
}
@@ -893,7 +891,7 @@
PDB.getBugReporter(), PDB.getNodeMapClosure());
if (p) {
- GenExtAddEdge(PD, PDB, p->getLocation(), PrevLoc);
+ GenExtAddEdge(PD, PDB, p->getLocation(), PrevLoc, true);
PD.push_front(p);
}
}
More information about the cfe-commits
mailing list