aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/initializer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/initializer.cpp')
-rw-r--r--test/Analysis/initializer.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/test/Analysis/initializer.cpp b/test/Analysis/initializer.cpp
index 6640e1fc49..0580503a44 100644
--- a/test/Analysis/initializer.cpp
+++ b/test/Analysis/initializer.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -cfg-add-initializers -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -cfg-add-initializers -cfg-add-implicit-dtors -verify %s
+
+// We don't inline constructors unless we have both initializers and
+// implicit destructors turned on.
void clang_analyzer_eval(bool);
@@ -11,3 +14,33 @@ public:
A::A() : x(0) {
clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
}
+
+
+class DirectMember {
+ int x;
+public:
+ DirectMember(int value) : x(value) {}
+
+ int getX() { return x; }
+};
+
+void testDirectMember() {
+ DirectMember obj(3);
+ clang_analyzer_eval(obj.getX() == 3); // expected-warning{{TRUE}}
+}
+
+
+class IndirectMember {
+ struct {
+ int x;
+ };
+public:
+ IndirectMember(int value) : x(value) {}
+
+ int getX() { return x; }
+};
+
+void testIndirectMember() {
+ IndirectMember obj(3);
+ clang_analyzer_eval(obj.getX() == 3); // expected-warning{{TRUE}}
+}