summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/BugReporter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-05-05 23:13:38 +0000
committerTed Kremenek <kremenek@apple.com>2009-05-05 23:13:38 +0000
commita8106efce9555e43a58dc98a563c1b2ed44a5c42 (patch)
tree13fa4a7ca78cfc50a33abef698695d56f7715a5d /clang/lib/Analysis/BugReporter.cpp
parentb3c657bbd4b7d95be3278e5533b98e3436d650c7 (diff)
downloadbcm5719-llvm-a8106efce9555e43a58dc98a563c1b2ed44a5c42.tar.gz
bcm5719-llvm-a8106efce9555e43a58dc98a563c1b2ed44a5c42.zip
BugReporter (extensive diagnostics): improve location context generation for the
start of 'do' and '@synchronized' statements. llvm-svn: 71038
Diffstat (limited to 'clang/lib/Analysis/BugReporter.cpp')
-rw-r--r--clang/lib/Analysis/BugReporter.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp
index 8a07cd01e1e..77a83fef8c6 100644
--- a/clang/lib/Analysis/BugReporter.cpp
+++ b/clang/lib/Analysis/BugReporter.cpp
@@ -823,7 +823,7 @@ public:
PrevLoc = PD.begin()->getLocation();
if (const Stmt *S = PrevLoc.asStmt())
- addContext(PDB.getEnclosingStmtLocation(S).asStmt());
+ addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt());
}
}
@@ -851,6 +851,7 @@ public:
void rawAddEdge(PathDiagnosticLocation NewLoc);
void addContext(const Stmt *S);
+ void addExtendedContext(const Stmt *S);
};
} // end anonymous namespace
@@ -992,6 +993,31 @@ bool EdgeBuilder::IsConsumedExpr(const PathDiagnosticLocation &L) {
return false;
}
+void EdgeBuilder::addExtendedContext(const Stmt *S) {
+ if (!S)
+ return;
+
+ const Stmt *Parent = PDB.getParent(S);
+ while (Parent) {
+ if (isa<CompoundStmt>(Parent))
+ Parent = PDB.getParent(Parent);
+ else
+ break;
+ }
+
+ if (Parent) {
+ switch (Parent->getStmtClass()) {
+ case Stmt::DoStmtClass:
+ case Stmt::ObjCAtSynchronizedStmtClass:
+ addContext(Parent);
+ default:
+ break;
+ }
+ }
+
+ addContext(S);
+}
+
void EdgeBuilder::addContext(const Stmt *S) {
if (!S)
return;
@@ -1073,7 +1099,7 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
EB.addContext(S);
}
else
- EB.addContext(PDB.getEnclosingStmtLocation(S).asStmt());
+ EB.addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt());
}
continue;
@@ -1088,7 +1114,7 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
EB.addEdge(Loc, true);
PD.push_front(p);
if (const Stmt *S = Loc.asStmt())
- EB.addContext(PDB.getEnclosingStmtLocation(S).asStmt());
+ EB.addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt());
}
}
}
OpenPOWER on IntegriCloud