r187133 - [analyzer] Add regression test for the crash in PR16664.

Jordan Rose jordan_rose at apple.com
Thu Jul 25 10:22:05 PDT 2013


Author: jrose
Date: Thu Jul 25 12:22:05 2013
New Revision: 187133

URL: http://llvm.org/viewvc/llvm-project?rev=187133&view=rev
Log:
[analyzer] Add regression test for the crash in PR16664.

This goes with r186925, which reverted Pavel's commit in r186498.

Also, add a correctness test for the future.

Modified:
    cfe/trunk/test/Analysis/temporaries.cpp

Modified: cfe/trunk/test/Analysis/temporaries.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/temporaries.cpp?rev=187133&r1=187132&r2=187133&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/temporaries.cpp (original)
+++ cfe/trunk/test/Analysis/temporaries.cpp Thu Jul 25 12:22:05 2013
@@ -109,3 +109,35 @@ namespace compound_literals {
   }
 }
 
+namespace destructors {
+  void testPR16664Crash() {
+    struct Dtor {
+      ~Dtor();
+    };
+    extern bool coin();
+    extern bool check(const Dtor &);
+
+    // Don't crash here.
+    if (coin() && (coin() || coin() || check(Dtor()))) {
+      Dtor();
+    }
+  }
+
+  void testConsistency(int i) {
+    struct NoReturnDtor {
+      ~NoReturnDtor() __attribute__((noreturn));
+    };
+    extern bool check(const NoReturnDtor &);
+    
+    if (i == 5 && (i == 4 || i == 5 || check(NoReturnDtor())))
+      clang_analyzer_eval(true); // expected-warning{{TRUE}}
+
+    if (i != 5)
+      return;
+    if (i == 5 && (i == 4 || check(NoReturnDtor()) || i == 5)) {
+      // FIXME: Should be no-warning, because the noreturn destructor should
+      // fire on all paths.
+      clang_analyzer_eval(true); // expected-warning{{TRUE}}
+    }
+  }
+}





More information about the cfe-commits mailing list