diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-23 16:19:29 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-23 16:19:29 +0000 |
commit | c2924d048411f0372ecfa9e8cfc849b07cfd625e (patch) | |
tree | 13fabf752a592b0147313551472eeb3455f875a0 /lib/Analysis/BugReporter.cpp | |
parent | 8f06f84e8be64962cc478e3e8867336768cac79b (diff) |
BugReporter (extensive diagnostics): Ignore parentheses when added control-flow
pieces for location contexts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69895 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BugReporter.cpp')
-rw-r--r-- | lib/Analysis/BugReporter.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index 73029c5af8..e0b1b6540f 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/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); |