summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/initializer.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-01-26 03:16:31 +0000
committerJordan Rose <jordan_rose@apple.com>2013-01-26 03:16:31 +0000
commit9853371f24c50326c379baeb5e8f8bd6a40b3a96 (patch)
treeeff29e9c85baaca983dde5818fddcac124a78484 /clang/test/Analysis/initializer.cpp
parent9c67267a7bcedd38ceb0b38719f4008f57bb0039 (diff)
downloadbcm5719-llvm-9853371f24c50326c379baeb5e8f8bd6a40b3a96.tar.gz
bcm5719-llvm-9853371f24c50326c379baeb5e8f8bd6a40b3a96.zip
[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. llvm-svn: 173557
Diffstat (limited to 'clang/test/Analysis/initializer.cpp')
-rw-r--r--clang/test/Analysis/initializer.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/Analysis/initializer.cpp b/clang/test/Analysis/initializer.cpp
index d4f336977e3..ab2eb901436 100644
--- a/clang/test/Analysis/initializer.cpp
+++ b/clang/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
+ }
+}
OpenPOWER on IntegriCloud