summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/BugReporter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-03-28 03:37:59 +0000
committerTed Kremenek <kremenek@apple.com>2009-03-28 03:37:59 +0000
commitb9411565ea884c668be34fcbfbe81df1b03be8eb (patch)
treeb7be1d3986016fe9583fdd6b9c1e977b327eb4df /clang/lib/Analysis/BugReporter.cpp
parenta0b08dcd6be169d66b4f4f5d6210b3f52f436b49 (diff)
downloadbcm5719-llvm-b9411565ea884c668be34fcbfbe81df1b03be8eb.tar.gz
bcm5719-llvm-b9411565ea884c668be34fcbfbe81df1b03be8eb.zip
Teach PathDiagnosticBuilder::getEnclosingStmtLocation() about while/if/do/for,
etc., so that the "body" is always considered a top-level statement for edge transitions (even if it is an expression). llvm-svn: 67901
Diffstat (limited to 'clang/lib/Analysis/BugReporter.cpp')
-rw-r--r--clang/lib/Analysis/BugReporter.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp
index ac3d96191aa..be666706414 100644
--- a/clang/lib/Analysis/BugReporter.cpp
+++ b/clang/lib/Analysis/BugReporter.cpp
@@ -151,9 +151,37 @@ PathDiagnosticBuilder::getEnclosingStmtLocation(const Stmt *S) {
while (isa<Expr>(S)) {
const Stmt *Parent = P.getParent(S);
- if (!Parent || isa<CompoundStmt>(Parent) || isa<StmtExpr>(Parent))
- return PathDiagnosticLocation(S, SMgr);
+ if (!Parent)
+ break;
+ switch (Parent->getStmtClass()) {
+ case Stmt::CompoundStmtClass:
+ case Stmt::StmtExprClass:
+ return PathDiagnosticLocation(S, SMgr);
+ case Stmt::DoStmtClass:
+ if (cast<DoStmt>(Parent)->getCond() != S)
+ return PathDiagnosticLocation(S, SMgr);
+ break;
+ case Stmt::ForStmtClass:
+ if (cast<ForStmt>(Parent)->getBody() == S)
+ return PathDiagnosticLocation(S, SMgr);
+ break;
+ case Stmt::IfStmtClass:
+ if (cast<IfStmt>(Parent)->getCond() != S)
+ return PathDiagnosticLocation(S, SMgr);
+ break;
+ case Stmt::ObjCForCollectionStmtClass:
+ if (cast<ObjCForCollectionStmt>(Parent)->getBody() == S)
+ return PathDiagnosticLocation(S, SMgr);
+ break;
+ case Stmt::WhileStmtClass:
+ if (cast<WhileStmt>(Parent)->getCond() != S)
+ return PathDiagnosticLocation(S, SMgr);
+ break;
+ default:
+ break;
+ }
+
S = Parent;
}
OpenPOWER on IntegriCloud