[cfe-commits] r69895 - /cfe/trunk/lib/Analysis/BugReporter.cpp
Ted Kremenek
kremenek at apple.com
Thu Apr 23 09:19:31 PDT 2009
Author: kremenek
Date: Thu Apr 23 11:19:29 2009
New Revision: 69895
URL: http://llvm.org/viewvc/llvm-project?rev=69895&view=rev
Log:
BugReporter (extensive diagnostics): Ignore parentheses when added control-flow
pieces for location contexts.
Modified:
cfe/trunk/lib/Analysis/BugReporter.cpp
Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=69895&r1=69894&r2=69895&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Thu Apr 23 11:19:29 2009
@@ -789,6 +789,22 @@
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);
More information about the cfe-commits
mailing list