[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / this-pointer.cpp
blobd160a942ef285557e67247bd63ac1e3cf154110a
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config widen-loops=true -analyzer-disable-retry-exhausted -verify %s
3 void clang_analyzer_eval(bool);
4 void clang_analyzer_dump(int);
6 // 'this' pointer is not an lvalue, we should not invalidate it.
7 namespace this_pointer_after_loop_widen {
8 class A {
9 public:
10 A() {
11 int count = 10;
12 do {
13 } while (count--);
17 void goo(A a);
18 void test_temporary_object() {
19 goo(A()); // no-crash
22 struct B {
23 int mem;
24 B() : mem(0) {
25 for (int i = 0; i < 10; ++i) {
27 mem = 0;
31 void test_ctor() {
32 B b;
33 clang_analyzer_eval(b.mem == 0); // expected-warning{{TRUE}}
36 struct C {
37 int mem;
38 C() : mem(0) {}
39 void set() {
40 for (int i = 0; i < 10; ++i) {
42 mem = 10;
46 void test_method() {
47 C c;
48 clang_analyzer_eval(c.mem == 0); // expected-warning{{TRUE}}
49 c.set();
50 clang_analyzer_eval(c.mem == 10); // expected-warning{{TRUE}}
53 struct D {
54 int mem;
55 D() : mem(0) {}
56 void set() {
57 for (int i = 0; i < 10; ++i) {
59 mem = 10;
63 void test_new() {
64 D *d = new D;
65 clang_analyzer_eval(d->mem == 0); // expected-warning{{TRUE}}
66 d->set();
67 clang_analyzer_eval(d->mem == 10); // expected-warning{{TRUE}}
70 struct E {
71 int mem;
72 E() : mem(0) {}
73 void set() {
74 for (int i = 0; i < 10; ++i) {
76 setAux();
78 void setAux() {
79 this->mem = 10;
83 void test_chained_method_call() {
84 E e;
85 e.set();
86 clang_analyzer_eval(e.mem == 10); // expected-warning{{TRUE}}
88 } // namespace this_pointer_after_loop_widen