[cfe-commits] r68216 - /cfe/trunk/lib/Analysis/BugReporter.cpp
Ted Kremenek
kremenek at apple.com
Wed Apr 1 10:18:21 PDT 2009
Author: kremenek
Date: Wed Apr 1 12:18:21 2009
New Revision: 68216
URL: http://llvm.org/viewvc/llvm-project?rev=68216&view=rev
Log:
BugReporter: For the "extensive" PathDiagnostic generation algorithm, elide most
intra-compound statement jumps unless they are between terminators (i.e.,
branches).
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=68216&r1=68215&r2=68216&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Wed Apr 1 12:18:21 2009
@@ -144,6 +144,10 @@
return *PM.get();
}
+ const Stmt *getParent(const Stmt *S) {
+ return getParentMap().getParent(S);
+ }
+
ExplodedGraph<GRState>& getGraph() { return *ReportGraph; }
NodeMapClosure& getNodeMapClosure() { return NMC; }
ASTContext& getContext() { return BR.getContext(); }
@@ -756,7 +760,7 @@
PathDiagnosticBuilder &PDB,
PathDiagnosticLocation NewLoc,
PathDiagnosticLocation &PrevLoc,
- PathDiagnosticLocation UpdateLoc) {
+ bool allowBlockJump = false) {
if (const Stmt *S = NewLoc.asStmt()) {
if (IsControlFlowExpr(S))
@@ -771,9 +775,18 @@
if (NewLoc == PrevLoc)
return;
+
+ // Are we jumping between statements with the same compound statement?
+ if (!allowBlockJump)
+ if (const Stmt *PS = PrevLoc.asStmt())
+ if (const Stmt *NS = NewLoc.asStmt()) {
+ const Stmt *parentPS = PDB.getParent(PS);
+ if (isa<CompoundStmt>(parentPS) && parentPS == PDB.getParent(NS))
+ return;
+ }
PD.push_front(new PathDiagnosticControlFlowPiece(NewLoc, PrevLoc));
- PrevLoc = UpdateLoc;
+ PrevLoc = NewLoc;
}
static bool IsNestedDeclStmt(const Stmt *S, ParentMap &PM) {
@@ -799,13 +812,6 @@
return false;
}
-static void GenExtAddEdge(PathDiagnostic& PD,
- PathDiagnosticBuilder &PDB,
- const PathDiagnosticLocation &NewLoc,
- PathDiagnosticLocation &PrevLoc) {
- GenExtAddEdge(PD, PDB, NewLoc, PrevLoc, NewLoc);
-}
-
static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
PathDiagnosticBuilder &PDB,
const ExplodedNode<GRState> *N) {
@@ -828,7 +834,8 @@
const Stmt *Cond = Blk.getTerminatorCondition();
if (!Cond || !IsControlFlowExpr(Cond)) {
- GenExtAddEdge(PD, PDB, PathDiagnosticLocation(Term, SMgr), PrevLoc);
+ GenExtAddEdge(PD, PDB, PathDiagnosticLocation(Term, SMgr), PrevLoc,
+ true);
continue;
}
}
@@ -851,9 +858,10 @@
if (const BlockEntrance *BE = dyn_cast<BlockEntrance>(&P)) {
if (const Stmt* S = BE->getFirstStmt()) {
if (!IsControlFlowExpr(S) && !IsNestedDeclStmt(S, PDB.getParentMap())) {
- // Are we jumping with the same enclosing statement?
- if (PrevLoc.isValid() && PDB.getEnclosingStmtLocation(S) ==
- PDB.getEnclosingStmtLocation(PrevLoc)) {
+ if (PrevLoc.isValid()) {
+ // Are we jumping with the same enclosing statement?
+ if (PDB.getEnclosingStmtLocation(S) ==
+ PDB.getEnclosingStmtLocation(PrevLoc))
continue;
}
More information about the cfe-commits
mailing list