]> granicus.if.org Git - clang/commitdiff
Suppress dead store warnings involving objects initialized with CXXExprTemporaries.
authorTed Kremenek <kremenek@apple.com>
Wed, 23 Dec 2009 04:11:44 +0000 (04:11 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 23 Dec 2009 04:11:44 +0000 (04:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91986 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CheckDeadStores.cpp
test/Analysis/dead-stores.cpp

index f081c69c2b13bf8f846e531e1eeb6b8307dc71c9..6e4d8998620d2ed794e1a6d93f1c40daf294652d 100644 (file)
@@ -201,6 +201,10 @@ public:
             // 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'.
index 45f750688f422226f49e374df3a299fb7ac924bf..9778a11c921abf3e929b76b46a2357ddbf4b36cd 100644 (file)
@@ -38,6 +38,32 @@ int test2(int x) {
   return x;
 }
 
+//===----------------------------------------------------------------------===//
+// 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.
 //===----------------------------------------------------------------------===//