[cfe-commits] r68244 - /cfe/trunk/lib/Analysis/BugReporter.cpp
Ted Kremenek
kremenek at apple.com
Wed Apr 1 14:12:07 PDT 2009
Author: kremenek
Date: Wed Apr 1 16:12:06 2009
New Revision: 68244
URL: http://llvm.org/viewvc/llvm-project?rev=68244&view=rev
Log:
BugReporter, extensive path-diagnostics: add an extra control-flow edge to the
enclosing statement when jumping to a subexpression.
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=68244&r1=68243&r2=68244&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Wed Apr 1 16:12:06 2009
@@ -793,6 +793,38 @@
return;
}
+ // Add an extra edge when jumping between contexts.
+ while (1) {
+ if (const Stmt *PS = PrevLoc.asStmt())
+ if (const Stmt *NS = NewLoc.asStmt()) {
+ PathDiagnosticLocation X = PDB.getEnclosingStmtLocation(PS);
+ // FIXME: We need a version of getParent that ignores '()' and casts.
+ const Stmt *parentX = PDB.getParent(X.asStmt());
+
+ const PathDiagnosticLocation &Y = PDB.getEnclosingStmtLocation(NS);
+ // FIXME: We need a version of getParent that ignores '()' and casts.
+ const Stmt *parentY = PDB.getParent(Y.asStmt());
+
+ if (IsControlFlowExpr(parentX)) {
+ if (IsControlFlowExpr(parentY) && parentX == parentY) {
+ break;
+ }
+ else {
+ const PathDiagnosticLocation &W =
+ PDB.getEnclosingStmtLocation(PDB.getParent(parentX));
+
+ if (W != Y) X = W;
+ }
+ }
+
+ if (X != Y && PrevLoc.asLocation() != X.asLocation()) {
+ PD.push_front(new PathDiagnosticControlFlowPiece(X, PrevLoc));
+ PrevLoc = X;
+ }
+ }
+ break;
+ }
+
PD.push_front(new PathDiagnosticControlFlowPiece(NewLoc, PrevLoc));
PrevLoc = NewLoc;
}
More information about the cfe-commits
mailing list