]> granicus.if.org Git - clang/commitdiff
Explicitly handle CXXExprWithTemporaries during CFG construction by just visiting...
authorTed Kremenek <kremenek@apple.com>
Sat, 28 Aug 2010 00:19:02 +0000 (00:19 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 28 Aug 2010 00:19:02 +0000 (00:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112334 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFG.cpp
test/SemaCXX/unreachable-code.cpp

index 3720d20c288bee4395192794ed35dfd12efdf9ca..78979a4feeb4a655b082d957903fe3632dfd51e8 100644 (file)
@@ -390,6 +390,12 @@ tryAgain:
     case Stmt::CXXCatchStmtClass:
       return VisitCXXCatchStmt(cast<CXXCatchStmt>(S));
 
+    case Stmt::CXXExprWithTemporariesClass: {
+      // FIXME: Handle temporaries.  For now, just visit the subexpression
+      // so we don't artificially create extra blocks.
+      return Visit(cast<CXXExprWithTemporaries>(S)->getSubExpr());    
+    }
+
     case Stmt::CXXMemberCallExprClass:
       return VisitCXXMemberCallExpr(cast<CXXMemberCallExpr>(S), asc);
 
index 528bba7d5e15032ebdf5ecacc8fc657afc0ad9b5..40d0c00b9390f30547a6818058592963f6c37761 100644 (file)
@@ -39,3 +39,20 @@ void test3() {
     bar();     // expected-warning {{will never be executed}}
   }
 }
+
+// PR 6130 - Don't warn about bogus unreachable code with throw's and
+// temporary objects.
+class PR6130 {
+public:
+  PR6130();
+  ~PR6130();
+};
+
+int pr6130(unsigned i) {
+  switch(i) {
+    case 0: return 1;
+    case 1: return 2;
+    default:
+      throw PR6130(); // no-warning
+  }
+}