diff options
| author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-02-15 19:34:19 +0000 |
|---|---|---|
| committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-02-15 19:34:19 +0000 |
| commit | 543e8af99d8d4d529d89bde398f9eea809c9d712 (patch) | |
| tree | cf4cc9b3568399dcc2effb5a1082081f252cc237 /clang/test | |
| parent | a5e3675bd3bb333257191a0dc37c59e41b418823 (diff) | |
| download | bcm5719-llvm-543e8af99d8d4d529d89bde398f9eea809c9d712.tar.gz bcm5719-llvm-543e8af99d8d4d529d89bde398f9eea809c9d712.zip | |
[analyzer] Suppress temporary destructors for temporary arrays.
Array destructors, like constructors, need to be called for each element of the
array separately. We do not have any mechanisms to do this in the analyzer,
so for now all we do is evaluate a single constructor or destructor
conservatively and give up. It automatically causes the necessary invalidation
and pointer escape for the whole array, because this is how RegionStore works.
Implement this conservative behavior for temporary destructors. This fixes the
crash on the provided test.
Differential Revision: https://reviews.llvm.org/D43149
llvm-svn: 325286
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Analysis/temporaries.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/test/Analysis/temporaries.cpp b/clang/test/Analysis/temporaries.cpp index fb0a0fdd6c4..2587e4ed56a 100644 --- a/clang/test/Analysis/temporaries.cpp +++ b/clang/test/Analysis/temporaries.cpp @@ -6,6 +6,8 @@ extern bool clang_analyzer_eval(bool); extern bool clang_analyzer_warnIfReached(); void clang_analyzer_checkInlined(bool); +#include "Inputs/system-header-simulator-cxx.h"; + struct Trivial { Trivial(int x) : value(x) {} int value; @@ -892,3 +894,17 @@ void test_ternary_temporary_with_copy(int coin) { } } } // namespace test_match_constructors_and_destructors + +#if __cplusplus >= 201103L +namespace temporary_list_crash { +class C { +public: + C() {} + ~C() {} +}; + +void test() { + std::initializer_list<C>{C(), C()}; // no-crash +} +} // namespace temporary_list_crash +#endif // C++11 |

