[cfe-commits] r91986 - in /cfe/trunk: lib/Analysis/CheckDeadStores.cpp test/Analysis/dead-stores.cpp

Ted Kremenek kremenek at apple.com
Tue Dec 22 20:11:44 PST 2009


Author: kremenek
Date: Tue Dec 22 22:11:44 2009
New Revision: 91986

URL: http://llvm.org/viewvc/llvm-project?rev=91986&view=rev
Log:
Suppress dead store warnings involving objects initialized with CXXExprTemporaries.

Modified:
    cfe/trunk/lib/Analysis/CheckDeadStores.cpp
    cfe/trunk/test/Analysis/dead-stores.cpp

Modified: cfe/trunk/lib/Analysis/CheckDeadStores.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckDeadStores.cpp?rev=91986&r1=91985&r2=91986&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CheckDeadStores.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckDeadStores.cpp Tue Dec 22 22:11:44 2009
@@ -201,6 +201,10 @@
             // constructors/destructors don't have side effects.
             if (isa<CXXConstructExpr>(E))
               return;
+
+            if (isa<CXXExprWithTemporaries>(E))
+              return;
+            
             // A dead initialization is a variable that is dead after it
             // is initialized.  We don't flag warnings for those variables
             // marked 'unused'.

Modified: cfe/trunk/test/Analysis/dead-stores.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dead-stores.cpp?rev=91986&r1=91985&r2=91986&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/dead-stores.cpp (original)
+++ cfe/trunk/test/Analysis/dead-stores.cpp Tue Dec 22 22:11:44 2009
@@ -39,6 +39,32 @@
 }
 
 //===----------------------------------------------------------------------===//
+// Dead store checking involving CXXTemporaryExprs
+//===----------------------------------------------------------------------===//
+
+namespace TestTemp {
+  template<typename _Tp>
+  class pencil {
+  public:
+    ~pencil() throw() {}
+  };
+  template<typename _Tp, typename _Number2> struct _Row_base {
+    _Row_base(const pencil<_Tp>& x) {}
+  };
+  template<typename _Tp, typename _Number2 = TestTemp::pencil<_Tp> >
+  class row : protected _Row_base<_Tp, _Number2>     {
+    typedef _Row_base<_Tp, _Number2> _Base;
+    typedef _Number2 pencil_type;
+  public:
+    explicit row(const pencil_type& __a = pencil_type()) : _Base(__a) {}
+  };
+}
+
+void test2_b() {
+  TestTemp::row<const char*> x; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
 // Test references.
 //===----------------------------------------------------------------------===//
 





More information about the cfe-commits mailing list