Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / cxx2b-deducing-this.cpp
blobd22a897097bec0599e4f3dcdbbcf557390431a07
1 // RUN: %clang_analyze_cc1 -std=c++2b -verify %s \
2 // RUN: -analyzer-checker=core,debug.ExprInspection
4 template <typename T> void clang_analyzer_dump(T);
6 struct S {
7 int num;
8 S *orig;
10 void a(this auto Self) {
11 clang_analyzer_dump(&Self); // expected-warning {{&Self}}
12 clang_analyzer_dump(Self.orig); // expected-warning {{&s}}
13 clang_analyzer_dump(Self.num); // expected-warning {{5 S32b}}
14 clang_analyzer_dump(Self.orig->num); // expected-warning {{5 S32b}}
16 Self.num = 1;
17 clang_analyzer_dump(Self.num); // expected-warning {{1 S32b}}
18 clang_analyzer_dump(Self.orig->num); // expected-warning {{5 S32b}}
21 void b(this auto& Self) {
22 clang_analyzer_dump(&Self); // expected-warning {{&s}}
23 clang_analyzer_dump(Self.orig); // expected-warning {{&s}}
24 clang_analyzer_dump(Self.num); // expected-warning {{5 S32b}}
25 clang_analyzer_dump(Self.orig->num); // expected-warning {{5 S32b}}
27 Self.num = 2;
28 clang_analyzer_dump(Self.num); // expected-warning {{2 S32b}}
29 clang_analyzer_dump(Self.orig->num); // expected-warning {{2 S32b}}
32 void c(this S Self) {
33 clang_analyzer_dump(&Self); // expected-warning {{&Self}}
34 clang_analyzer_dump(Self.orig); // expected-warning {{&s}}
35 clang_analyzer_dump(Self.num); // expected-warning {{2 S32b}}
36 clang_analyzer_dump(Self.orig->num); // expected-warning {{2 S32b}}
38 Self.num = 3;
39 clang_analyzer_dump(Self.num); // expected-warning {{3 S32b}}
40 clang_analyzer_dump(Self.orig->num); // expected-warning {{2 S32b}}
43 void c(this S Self, int I) {
44 clang_analyzer_dump(I); // expected-warning {{11 S32b}}
45 clang_analyzer_dump(&Self); // expected-warning {{&Self}}
46 clang_analyzer_dump(Self.orig); // expected-warning {{&s}}
47 clang_analyzer_dump(Self.num); // expected-warning {{2 S32b}}
48 clang_analyzer_dump(Self.orig->num); // expected-warning {{2 S32b}}
50 Self.num = 4;
51 clang_analyzer_dump(Self.num); // expected-warning {{4 S32b}}
52 clang_analyzer_dump(Self.orig->num); // expected-warning {{2 S32b}}
56 void top() {
57 S s = {/*num=*/5, /*orig=*/&s};
58 s.a();
59 s.b(); // This call changes 's.num' to 2.
60 s.c();
61 s.c(11);