diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-07-26 20:04:21 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-07-26 20:04:21 +0000 |
commit | 3a0a9e3e8bbaa45f3ca22b1e20b3beaac0f5861e (patch) | |
tree | c76bbced794f967cad753fe08df73c3a3ec11fb9 /test/Analysis/initializer.cpp | |
parent | 075f6fbcb4d858c09e9b138f8dc10d8d3d43d935 (diff) |
[analyzer] Handle C++ member initializers and destructors.
This uses CFG to tell if a constructor call is for a member, and uses
the member's region appropriately.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160808 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/initializer.cpp')
-rw-r--r-- | test/Analysis/initializer.cpp | 35 |
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}} +} |