diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-01-26 03:16:31 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-01-26 03:16:31 +0000 |
commit | 07c52d2813a6b5e4025276d3687bd25f75fd51b9 (patch) | |
tree | fe7371144ff964836c146c0f3dbd280e22c1c6d9 /test/Analysis/initializer.cpp | |
parent | db55c04cb3384b192a418a840a9ba6321941fc0d (diff) |
[analyzer] C++ initializers may require cleanups; look through these.
When the analyzer sees an initializer, it checks if the initializer
contains a CXXConstructExpr. If so, it trusts that the CXXConstructExpr
does the necessary work to initialize the object, and performs no further
initialization.
This patch looks through any implicit wrapping expressions like
ExprWithCleanups to find the CXXConstructExpr inside.
Fixes PR15070.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/initializer.cpp')
-rw-r--r-- | test/Analysis/initializer.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/Analysis/initializer.cpp b/test/Analysis/initializer.cpp index d4f336977e..ab2eb90143 100644 --- a/test/Analysis/initializer.cpp +++ b/test/Analysis/initializer.cpp @@ -80,3 +80,33 @@ class StringWrapper { public: StringWrapper(const char *input) : str(strdup(input)) {} // no-warning }; + + +// PR15070 - Constructing a type containing a non-POD array mistakenly +// tried to perform a bind instead of relying on the CXXConstructExpr, +// which caused a cast<> failure in RegionStore. +namespace DefaultConstructorWithCleanups { + class Element { + public: + int value; + + class Helper { + public: + ~Helper(); + }; + Element(Helper h = Helper()); + }; + class Wrapper { + public: + Element arr[2]; + + Wrapper(); + }; + + Wrapper::Wrapper() /* initializers synthesized */ {} + + int test() { + Wrapper w; + return w.arr[0].value; // no-warning + } +} |