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