summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-04-23 16:19:29 +0000
committerTed Kremenek <kremenek@apple.com>2009-04-23 16:19:29 +0000
commite60809c31dd841fb71b03f9d890d4ff3313e672c (patch)
tree50e2a6bd8476633764449de1e9e72dac9b10b674 /clang/lib
parent0cbba990d7f689c90092d86da62ab076aedd3954 (diff)
downloadbcm5719-llvm-e60809c31dd841fb71b03f9d890d4ff3313e672c.tar.gz
bcm5719-llvm-e60809c31dd841fb71b03f9d890d4ff3313e672c.zip
BugReporter (extensive diagnostics): Ignore parentheses when added control-flow
pieces for location contexts. llvm-svn: 69895
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Analysis/BugReporter.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp
index 73029c5af8d..e0b1b6540f1 100644
--- a/clang/lib/Analysis/BugReporter.cpp
+++ b/clang/lib/Analysis/BugReporter.cpp
@@ -789,6 +789,22 @@ class VISIBILITY_HIDDEN EdgeBuilder {
void popLocation() {
PathDiagnosticLocation L = CLocs.back();
if (L.asLocation().isFileID()) {
+
+ if (const Stmt *S = L.asStmt()) {
+ // Adjust the location for some expressions that are best referenced
+ // by one of their subexpressions.
+ if (const ConditionalOperator *CO = dyn_cast<ConditionalOperator>(S))
+ S = CO->getCond();
+ else if (const ChooseExpr *CE = dyn_cast<ChooseExpr>(S))
+ S = CE->getCond();
+
+ // Ignore parentheses.
+ if (const ParenExpr *PE = dyn_cast<ParenExpr>(S))
+ S = PE->IgnoreParens();
+
+ L = PathDiagnosticLocation(S, L.getManager());
+ }
+
// For contexts, we only one the first character as the range.
L = PathDiagnosticLocation(L.asLocation(), L.getManager());
rawAddEdge(L);
OpenPOWER on IntegriCloud