[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187133 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/temporaries.cpp b/test/Analysis/temporaries.cpp
index efc0825..ebfbfe9 100644
--- a/test/Analysis/temporaries.cpp
+++ b/test/Analysis/temporaries.cpp
@@ -109,3 +109,35 @@
   }
 }
 
+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}}
+    }
+  }
+}