From: Jordan Rose Date: Thu, 25 Jul 2013 17:22:05 +0000 (+0000) Subject: [analyzer] Add regression test for the crash in PR16664. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=062ef6e6d956b8873e33fe84574c7630d2829d3d;p=clang [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 efc0825470..ebfbfe9bee 100644 --- a/test/Analysis/temporaries.cpp +++ b/test/Analysis/temporaries.cpp @@ -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}} + } + } +}