[cfe-commits] r69898 - /cfe/trunk/lib/Analysis/BugReporter.cpp

Ted Kremenek kremenek at apple.com
Thu Apr 23 09:44:23 PDT 2009


Author: kremenek
Date: Thu Apr 23 11:44:22 2009
New Revision: 69898

URL: http://llvm.org/viewvc/llvm-project?rev=69898&view=rev
Log:
BugReporter (extensive diagnostics): Recursively adjust the referred expression
when popping 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=69898&r1=69897&r2=69898&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Thu Apr 23 11:44:22 2009
@@ -790,18 +790,22 @@
     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();
-        
+      if (const Stmt *S = L.asStmt()) {
+        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;
+        }
+
         L = PathDiagnosticLocation(S, L.getManager());        
       }      
       





More information about the cfe-commits mailing list