From ead98ea3eb4e207be7ca003b612b68b7dfbb8f7e Mon Sep 17 00:00:00 2001 From: Artem Dergachev Date: Wed, 28 Aug 2019 18:44:42 +0000 Subject: [CFG] Make representation of destructor calls more accurate. Respect C++17 copy elision; previously it would generate destructor calls for elided temporaries, including in initialization and return statements. Don't generate duplicate destructor calls for statement expressions. Fix destructors in initialization lists and comma operators. Improve printing of implicit destructors. Patch by Nicholas Allegra! Differential Revision: https://reviews.llvm.org/D66404 llvm-svn: 370247 --- clang/test/Analysis/temporaries.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'clang/test/Analysis/temporaries.cpp') diff --git a/clang/test/Analysis/temporaries.cpp b/clang/test/Analysis/temporaries.cpp index 6191abfb4d2..012cef52f14 100644 --- a/clang/test/Analysis/temporaries.cpp +++ b/clang/test/Analysis/temporaries.cpp @@ -830,12 +830,7 @@ void test_ternary_temporary_with_copy(int coin) { // On each branch the variable is constructed directly. if (coin) { clang_analyzer_eval(x == 1); // expected-warning{{TRUE}} -#if __cplusplus < 201703L clang_analyzer_eval(y == 1); // expected-warning{{TRUE}} -#else - // FIXME: Destructor called twice in C++17? - clang_analyzer_eval(y == 2); // expected-warning{{TRUE}} -#endif clang_analyzer_eval(z == 0); // expected-warning{{TRUE}} clang_analyzer_eval(w == 0); // expected-warning{{TRUE}} @@ -843,12 +838,7 @@ void test_ternary_temporary_with_copy(int coin) { clang_analyzer_eval(x == 0); // expected-warning{{TRUE}} clang_analyzer_eval(y == 0); // expected-warning{{TRUE}} clang_analyzer_eval(z == 1); // expected-warning{{TRUE}} -#if __cplusplus < 201703L clang_analyzer_eval(w == 1); // expected-warning{{TRUE}} -#else - // FIXME: Destructor called twice in C++17? - clang_analyzer_eval(w == 2); // expected-warning{{TRUE}} -#endif } } } // namespace test_match_constructors_and_destructors @@ -1055,16 +1045,11 @@ void foo(void (*bar4)(S)) { #endif bar2(S(2)); - // FIXME: Why are we losing information in C++17? clang_analyzer_eval(glob == 2); #ifdef TEMPORARY_DTORS -#if __cplusplus < 201703L - // expected-warning@-3{{TRUE}} -#else - // expected-warning@-5{{UNKNOWN}} -#endif + // expected-warning@-2{{TRUE}} #else - // expected-warning@-8{{UNKNOWN}} + // expected-warning@-4{{UNKNOWN}} #endif C *c = new D(); -- cgit v1.2.3