]> granicus.if.org Git - clang/commitdiff
Teach the CFGBuilder not do die on CXXBindTemporaryExpr, CXXOperatorCallExpr. Fixes...
authorDouglas Gregor <dgregor@apple.com>
Tue, 31 Aug 2010 05:10:27 +0000 (05:10 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 31 Aug 2010 05:10:27 +0000 (05:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112578 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFG.cpp
test/Analysis/temporaries.cpp [new file with mode: 0644]

index 78979a4feeb4a655b082d957903fe3632dfd51e8..ea30ec01f6e0fdf7c6b61a118e98895a0b867b15 100644 (file)
@@ -370,6 +370,7 @@ tryAgain:
       return VisitBreakStmt(cast<BreakStmt>(S));
 
     case Stmt::CallExprClass:
+    case Stmt::CXXOperatorCallExprClass: // FIXME: handle specially?
       return VisitCallExpr(cast<CallExpr>(S), asc);
 
     case Stmt::CaseStmtClass:
@@ -396,6 +397,12 @@ tryAgain:
       return Visit(cast<CXXExprWithTemporaries>(S)->getSubExpr());    
     }
 
+    case Stmt::CXXBindTemporaryExprClass: {
+      // FIXME: Handle temporary binding.  For now, just visit the subexpression
+      // so we don't artificially create extra blocks.
+      return Visit(cast<CXXBindTemporaryExpr>(S)->getSubExpr());    
+    }
+
     case Stmt::CXXMemberCallExprClass:
       return VisitCXXMemberCallExpr(cast<CXXMemberCallExpr>(S), asc);
 
diff --git a/test/Analysis/temporaries.cpp b/test/Analysis/temporaries.cpp
new file mode 100644 (file)
index 0000000..602948a
--- /dev/null
@@ -0,0 +1,13 @@
+// // RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s
+// FIXME: Super-simple test to make sure we don't die on temporaries.
+
+struct X {
+  X();
+  ~X();
+  X operator++(int);
+};
+
+int f(X x, X y) {
+  for (; ; x++) { }
+}