[cfe-commits] r141433 - in /cfe/trunk: lib/StaticAnalyzer/Core/ExprEngine.cpp test/Analysis/misc-ps-cxx0x.cpp

Ted Kremenek kremenek at apple.com
Fri Oct 7 15:48:13 PDT 2011


Author: kremenek
Date: Fri Oct  7 17:48:13 2011
New Revision: 141433

URL: http://llvm.org/viewvc/llvm-project?rev=141433&view=rev
Log:
Provide basic static analyzer support for CXXTemporaryObjectExpr.  Patch by Jim Goodnow II.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
    cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=141433&r1=141432&r2=141433&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Oct  7 17:48:13 2011
@@ -455,7 +455,6 @@
     case Stmt::CXXDependentScopeMemberExprClass:
     case Stmt::CXXForRangeStmtClass:
     case Stmt::CXXPseudoDestructorExprClass:
-    case Stmt::CXXTemporaryObjectExprClass:
     case Stmt::CXXThrowExprClass:
     case Stmt::CXXTryStmtClass:
     case Stmt::CXXTypeidExprClass:
@@ -628,6 +627,7 @@
       break;
     }
 
+    case Stmt::CXXTemporaryObjectExprClass:
     case Stmt::CXXConstructExprClass: {
       const CXXConstructExpr *C = cast<CXXConstructExpr>(S);
       // For block-level CXXConstructExpr, we don't have a destination region.

Modified: cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp?rev=141433&r1=141432&r2=141433&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp (original)
+++ cfe/trunk/test/Analysis/misc-ps-cxx0x.cpp Fri Oct  7 17:48:13 2011
@@ -21,3 +21,27 @@
   RDar10243398MemberFn q = &RDar10243398::bar;
   ((*p).*(q))(1);
 }
+
+// Tests for CXXTemporaryObjectExpr.
+struct X {
+    X( int *ip, int );
+};
+
+// Test to see if CXXTemporaryObjectExpr is being handled.
+int tempobj1()
+{
+  int j;
+  int i;
+  X a = X( &j, 1 );
+
+  return i; // expected-warning {{Undefined or garbage value returned to caller}}
+}
+
+// Test to see if CXXTemporaryObjectExpr invalidates arguments.
+int tempobj2()
+{
+  int j;
+  X a = X( &j, 1 );
+
+  return j; // no-warning
+}





More information about the cfe-commits mailing list