summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/BugReporter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-05-11 21:42:34 +0000
committerTed Kremenek <kremenek@apple.com>2009-05-11 21:42:34 +0000
commitc0b879b4a7ebabeb6cc6e384e52355e8975411a5 (patch)
tree77af7877e1e7e8f4a4ca45924671c0f8c792e4de /clang/lib/Analysis/BugReporter.cpp
parentdc99ec4ebd5882104f265594bdbf76f8f168cc2c (diff)
downloadbcm5719-llvm-c0b879b4a7ebabeb6cc6e384e52355e8975411a5.tar.gz
bcm5719-llvm-c0b879b4a7ebabeb6cc6e384e52355e8975411a5.zip
EdgeBuilder::cleanUpLocation() should used the PathDiagnosticLocation constructor for a single point, not a range.
llvm-svn: 71477
Diffstat (limited to 'clang/lib/Analysis/BugReporter.cpp')
-rw-r--r--clang/lib/Analysis/BugReporter.cpp47
1 files changed, 31 insertions, 16 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp
index 661043a92d1..5407cea4e2c 100644
--- a/clang/lib/Analysis/BugReporter.cpp
+++ b/clang/lib/Analysis/BugReporter.cpp
@@ -777,36 +777,51 @@ class VISIBILITY_HIDDEN EdgeBuilder {
PathDiagnosticLocation getContextLocation(const PathDiagnosticLocation &L);
- PathDiagnosticLocation cleanUpLocation(const PathDiagnosticLocation &L) {
+ PathDiagnosticLocation cleanUpLocation(PathDiagnosticLocation L,
+ bool firstCharOnly = false) {
if (const Stmt *S = L.asStmt()) {
+ const Stmt *Original = S;
while (1) {
// Adjust the location for some expressions that are best referenced
// by one of their subexpressions.
- if (const ParenExpr *PE = dyn_cast<ParenExpr>(S))
- S = PE->IgnoreParens();
- else if (const ConditionalOperator *CO = dyn_cast<ConditionalOperator>(S))
- S = CO->getCond();
- else if (const ChooseExpr *CE = dyn_cast<ChooseExpr>(S))
- S = CE->getCond();
- else if (const BinaryOperator *BE = dyn_cast<BinaryOperator>(S))
- S = BE->getLHS();
- else
- break;
+ switch (S->getStmtClass()) {
+ default:
+ break;
+ case Stmt::ParenExprClass:
+ S = cast<ParenExpr>(S)->IgnoreParens();
+ firstCharOnly = true;
+ continue;
+ case Stmt::ConditionalOperatorClass:
+ S = cast<ConditionalOperator>(S)->getCond();
+ firstCharOnly = true;
+ continue;
+ case Stmt::ChooseExprClass:
+ S = cast<ChooseExpr>(S)->getCond();
+ firstCharOnly = true;
+ continue;
+ case Stmt::BinaryOperatorClass:
+ S = cast<BinaryOperator>(S)->getLHS();
+ firstCharOnly = true;
+ continue;
+ }
+
+ break;
}
- return PathDiagnosticLocation(S, L.getManager());
+ if (S != Original)
+ L = PathDiagnosticLocation(S, L.getManager());
}
+ if (firstCharOnly)
+ L = PathDiagnosticLocation(L.asLocation());
+
return L;
}
void popLocation() {
if (!CLocs.back().isDead() && CLocs.back().asLocation().isFileID()) {
- PathDiagnosticLocation L = cleanUpLocation(CLocs.back());
-
// For contexts, we only one the first character as the range.
- L = PathDiagnosticLocation(L.asLocation(), L.getManager());
- rawAddEdge(L);
+ rawAddEdge( cleanUpLocation(CLocs.back(), true));
}
CLocs.pop_back();
}
OpenPOWER on IntegriCloud