Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / default_private_ast_print.cpp
blobb15a76402cca60e2acf5241a1260f4a8c5e922d9
1 // expected-no-diagnostics
3 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
4 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
5 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
6 //RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT
8 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
9 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
10 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
11 //RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP
13 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
14 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
15 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
16 //RUN: -emit-pch -o %t %s
18 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
19 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
20 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
21 //RUN: -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
23 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
24 //RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
25 //RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
26 //RUN: -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
28 #ifndef HEADER
29 #define HEADER
31 struct SomeKernel {
32 int targetDev;
33 float devPtr;
34 SomeKernel();
35 ~SomeKernel();
37 template <unsigned int nRHS>
38 void apply() {
39 #pragma omp parallel default(private)
41 targetDev++;
43 // PRINT: #pragma omp parallel default(private)
44 // PRINT-NEXT: {
45 // PRINT-NEXT: this->targetDev++;
46 // CHECK-NEXT: }
47 // DUMP: -OMPParallelDirective
48 // DUMP->NEXT: -OMPDefaultClause
50 // PRINT: template<> void apply<32U>()
51 // PRINT: #pragma omp parallel default(private)
52 // PRINT-NEXT: {
53 // PRINT-NEXT: this->targetDev++;
54 // CHECK-NEXT: }
55 // DUMP: -OMPParallelDirective
56 // DUMP-NEXT: -OMPDefaultClause
59 void use_template() {
60 SomeKernel aKern;
61 aKern.apply<32>();
64 void foo() {
65 int a;
66 #pragma omp parallel default(private)
67 a++;
68 // PRINT: #pragma omp parallel default(private)
69 // PRINT-NEXT: a++;
70 // DUMP: -OMPParallelDirective
71 // DUMP-NEXT: -OMPDefaultClause
72 // DUMP-NEXT: -OMPPrivateClause {{.*}} <implicit>
73 // DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
76 struct St {
77 int a, b;
78 int y;
79 St() : a(0), b(0) {}
80 ~St() {}
82 void bar() {
83 St a = St();
84 static int yy = 0;
85 #pragma omp parallel default(private)
87 a.a += 1;
88 a.b += 1;
89 a.y++;
90 yy++;
92 // PRINT: #pragma omp parallel default(private)
93 // DUMP: -OMPParallelDirective
94 // DUMP-NEXT: -OMPDefaultClause
95 // DUMP-NEXT: -OMPPrivateClause {{.*}} <implicit>
96 // DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
97 // DUMP-NEXT: -DeclRefExpr {{.*}} 'yy'
100 void zoo(int);
101 struct A {
102 int z;
103 int f;
104 A();
105 ~A();
106 void foo() {
107 #pragma omp parallel private(z) default(private)
109 z++;
110 f++;
111 zoo(z + f);
112 f++;
115 // PRINT: #pragma omp parallel private(this->z) default(private)
116 // DUMP: -OMPParallelDirective
117 // DUMP-NEXT: -OMPPrivateClause
118 // DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
119 // DUMP-NEXT: -OMPDefaultClause
120 // DUMP-NEXT: -OMPPrivateClause
121 // DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
122 // DUMP: -CXXThisExpr {{.*}} 'A *' implicit this
123 void bar() {
124 #pragma omp parallel private(z) default(private)
126 #pragma omp parallel private(z) default(private)
128 z++;
129 f++;
130 zoo(z + f);
131 f++;
135 // PRINT: #pragma omp parallel private(this->z) default(private)
136 // PRINT: #pragma omp parallel private(this->z) default(private)
137 // DUMP: -OMPParallelDirective
138 // DUMP-NEXT: -OMPPrivateClause
139 // DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
140 // DUMP-NEXT: -OMPDefaultClause
141 // DUMP: -OMPParallelDirective
142 // DUMP-NEXT: -OMPPrivateClause
143 // DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
144 // DUMP-NEXT: -OMPDefaultClause
145 // DUMP-NEXT: -OMPPrivateClause {{.*}} <implicit>
146 // DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
147 // DUMP: -CXXThisExpr
148 // DUMP: -MemberExpr
149 // DUMP-NEXT: -CXXThisExpr
150 // DUMP: -CXXThisExpr
152 #endif // HEADER