[llvm-branch-commits] [cfe-branch] r71501 - /cfe/branches/Apple/Dib/lib/Analysis/BugReporter.cpp
Mike Stump
mrs at apple.com
Mon May 11 16:22:01 PDT 2009
Author: mrs
Date: Mon May 11 18:22:00 2009
New Revision: 71501
URL: http://llvm.org/viewvc/llvm-project?rev=71501&view=rev
Log:
Merge in 71477:
EdgeBuilder::cleanUpLocation() should used the PathDiagnosticLocation constructor for a single point, not a range.
Modified:
cfe/branches/Apple/Dib/lib/Analysis/BugReporter.cpp
Modified: cfe/branches/Apple/Dib/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Analysis/BugReporter.cpp?rev=71501&r1=71500&r2=71501&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/lib/Analysis/BugReporter.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Analysis/BugReporter.cpp Mon May 11 18:22:00 2009
@@ -777,36 +777,51 @@
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();
}
More information about the llvm-branch-commits
mailing list