Jordan Rose | 3a0a9e3 | 2012-07-26 20:04:21 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -cfg-add-initializers -cfg-add-implicit-dtors -verify %s |
| 2 | |
| 3 | // We don't inline constructors unless we have both initializers and |
| 4 | // implicit destructors turned on. |
Jordy Rose | 43d9f0d | 2012-05-16 16:01:10 +0000 | [diff] [blame] | 5 | |
| 6 | void clang_analyzer_eval(bool); |
Zhongxing Xu | 9dc84c9 | 2010-11-16 07:52:17 +0000 | [diff] [blame] | 7 | |
| 8 | class A { |
| 9 | int x; |
| 10 | public: |
| 11 | A(); |
| 12 | }; |
| 13 | |
| 14 | A::A() : x(0) { |
Jordy Rose | 43d9f0d | 2012-05-16 16:01:10 +0000 | [diff] [blame] | 15 | clang_analyzer_eval(x == 0); // expected-warning{{TRUE}} |
Zhongxing Xu | 9dc84c9 | 2010-11-16 07:52:17 +0000 | [diff] [blame] | 16 | } |
Jordan Rose | 3a0a9e3 | 2012-07-26 20:04:21 +0000 | [diff] [blame] | 17 | |
| 18 | |
| 19 | class DirectMember { |
| 20 | int x; |
| 21 | public: |
| 22 | DirectMember(int value) : x(value) {} |
| 23 | |
| 24 | int getX() { return x; } |
| 25 | }; |
| 26 | |
| 27 | void testDirectMember() { |
| 28 | DirectMember obj(3); |
| 29 | clang_analyzer_eval(obj.getX() == 3); // expected-warning{{TRUE}} |
| 30 | } |
| 31 | |
| 32 | |
| 33 | class IndirectMember { |
| 34 | struct { |
| 35 | int x; |
| 36 | }; |
| 37 | public: |
| 38 | IndirectMember(int value) : x(value) {} |
| 39 | |
| 40 | int getX() { return x; } |
| 41 | }; |
| 42 | |
| 43 | void testIndirectMember() { |
| 44 | IndirectMember obj(3); |
| 45 | clang_analyzer_eval(obj.getX() == 3); // expected-warning{{TRUE}} |
| 46 | } |