[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / AST / ast-dump-openmp-begin-declare-variant_template_1.cpp
blob5916958b946254faa565fbb9b69f7cce39be9f58
1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s -x c++| FileCheck %s
3 // expected-no-diagnostics
5 int also_before() {
6 return 1;
9 #pragma omp begin declare variant match(implementation={vendor(score(100):llvm)})
10 int also_after(void) {
11 return 2;
13 int also_after(int) {
14 return 3;
16 int also_after(double) {
17 return 0;
19 #pragma omp end declare variant
20 #pragma omp begin declare variant match(implementation={vendor(score(0):llvm)})
21 int also_before() {
22 return 0;
24 #pragma omp end declare variant
26 int also_after(void) {
27 return 4;
29 int also_after(int) {
30 return 5;
32 int also_after(double) {
33 return 6;
36 template<typename T>
37 int test1() {
38 // Should return 0.
39 return also_after(T(0));
42 typedef int(*Ty)();
44 template<Ty fn>
45 int test2() {
46 // Should return 0.
47 return fn();
50 int test() {
51 // Should return 0.
52 return test1<double>() + test2<also_before>();
55 // CHECK: |-FunctionDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:7:1> line:5:5 used also_before 'int ({{.*}})'
56 // CHECK-NEXT: | |-CompoundStmt [[ADDR_1:0x[a-z0-9]*]] <col:19, line:7:1>
57 // CHECK-NEXT: | | `-ReturnStmt [[ADDR_2:0x[a-z0-9]*]] <line:6:3, col:10>
58 // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_3:0x[a-z0-9]*]] <col:10> 'int' 1
59 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_4:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={vendor(score(0): llvm)}
60 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_5:0x[a-z0-9]*]] <line:21:1> 'int ({{.*}})' Function [[ADDR_6:0x[a-z0-9]*]] 'also_before[implementation={vendor(llvm)}]' 'int ({{.*}})'
61 // CHECK-NEXT: |-FunctionDecl [[ADDR_7:0x[a-z0-9]*]] <line:10:1, col:20> col:5 implicit also_after 'int ({{.*}})'
62 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_8:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={vendor(score(100): llvm)}
63 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_9:0x[a-z0-9]*]] <col:1> 'int ({{.*}})' Function [[ADDR_10:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int ({{.*}})'
64 // CHECK-NEXT: |-FunctionDecl [[ADDR_10]] <col:1, line:12:1> line:10:1 also_after[implementation={vendor(llvm)}] 'int ({{.*}})'
65 // CHECK-NEXT: | `-CompoundStmt [[ADDR_11:0x[a-z0-9]*]] <col:22, line:12:1>
66 // CHECK-NEXT: | `-ReturnStmt [[ADDR_12:0x[a-z0-9]*]] <line:11:3, col:10>
67 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_13:0x[a-z0-9]*]] <col:10> 'int' 2
68 // CHECK-NEXT: |-FunctionDecl [[ADDR_14:0x[a-z0-9]*]] <line:13:1, col:19> col:5 implicit also_after 'int (int)'
69 // CHECK-NEXT: | |-ParmVarDecl [[ADDR_15:0x[a-z0-9]*]] <col:16> col:19 'int'
70 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_16:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={vendor(score(100): llvm)}
71 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_17:0x[a-z0-9]*]] <col:1> 'int (int)' Function [[ADDR_18:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int (int)'
72 // CHECK-NEXT: |-FunctionDecl [[ADDR_18]] <col:1, line:15:1> line:13:1 also_after[implementation={vendor(llvm)}] 'int (int)'
73 // CHECK-NEXT: | |-ParmVarDecl [[ADDR_15]] <col:16> col:19 'int'
74 // CHECK-NEXT: | `-CompoundStmt [[ADDR_19:0x[a-z0-9]*]] <col:21, line:15:1>
75 // CHECK-NEXT: | `-ReturnStmt [[ADDR_20:0x[a-z0-9]*]] <line:14:3, col:10>
76 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_21:0x[a-z0-9]*]] <col:10> 'int' 3
77 // CHECK-NEXT: |-FunctionDecl [[ADDR_22:0x[a-z0-9]*]] <line:16:1, col:22> col:5 implicit used also_after 'int (double)'
78 // CHECK-NEXT: | |-ParmVarDecl [[ADDR_23:0x[a-z0-9]*]] <col:16> col:22 'double'
79 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_24:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={vendor(score(100): llvm)}
80 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_25:0x[a-z0-9]*]] <col:1> 'int (double)' Function [[ADDR_26:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int (double)'
81 // CHECK-NEXT: |-FunctionDecl [[ADDR_26]] <col:1, line:18:1> line:16:1 also_after[implementation={vendor(llvm)}] 'int (double)'
82 // CHECK-NEXT: | |-ParmVarDecl [[ADDR_23]] <col:16> col:22 'double'
83 // CHECK-NEXT: | `-CompoundStmt [[ADDR_27:0x[a-z0-9]*]] <col:24, line:18:1>
84 // CHECK-NEXT: | `-ReturnStmt [[ADDR_28:0x[a-z0-9]*]] <line:17:3, col:10>
85 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_29:0x[a-z0-9]*]] <col:10> 'int' 0
86 // CHECK-NEXT: |-FunctionDecl [[ADDR_6]] <line:21:1, line:23:1> line:21:1 also_before[implementation={vendor(llvm)}] 'int ({{.*}})'
87 // CHECK-NEXT: | `-CompoundStmt [[ADDR_30:0x[a-z0-9]*]] <col:19, line:23:1>
88 // CHECK-NEXT: | `-ReturnStmt [[ADDR_31:0x[a-z0-9]*]] <line:22:3, col:10>
89 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_32:0x[a-z0-9]*]] <col:10> 'int' 0
90 // CHECK-NEXT: |-FunctionDecl [[ADDR_33:0x[a-z0-9]*]] prev [[ADDR_7]] <line:26:1, line:28:1> line:26:5 also_after 'int ({{.*}})'
91 // CHECK-NEXT: | |-CompoundStmt [[ADDR_34:0x[a-z0-9]*]] <col:22, line:28:1>
92 // CHECK-NEXT: | | `-ReturnStmt [[ADDR_35:0x[a-z0-9]*]] <line:27:3, col:10>
93 // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_36:0x[a-z0-9]*]] <col:10> 'int' 4
94 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_37:0x[a-z0-9]*]] <<invalid sloc>> Inherited Implicit implementation={vendor(score(100): llvm)}
95 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_9]] <line:10:1> 'int ({{.*}})' Function [[ADDR_10]] 'also_after[implementation={vendor(llvm)}]' 'int ({{.*}})'
96 // CHECK-NEXT: |-FunctionDecl [[ADDR_38:0x[a-z0-9]*]] prev [[ADDR_14]] <line:29:1, line:31:1> line:29:5 also_after 'int (int)'
97 // CHECK-NEXT: | |-ParmVarDecl [[ADDR_39:0x[a-z0-9]*]] <col:16> col:19 'int'
98 // CHECK-NEXT: | |-CompoundStmt [[ADDR_40:0x[a-z0-9]*]] <col:21, line:31:1>
99 // CHECK-NEXT: | | `-ReturnStmt [[ADDR_41:0x[a-z0-9]*]] <line:30:3, col:10>
100 // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_42:0x[a-z0-9]*]] <col:10> 'int' 5
101 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_43:0x[a-z0-9]*]] <<invalid sloc>> Inherited Implicit implementation={vendor(score(100): llvm)}
102 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_17]] <line:13:1> 'int (int)' Function [[ADDR_18]] 'also_after[implementation={vendor(llvm)}]' 'int (int)'
103 // CHECK-NEXT: |-FunctionDecl [[ADDR_44:0x[a-z0-9]*]] prev [[ADDR_22]] <line:32:1, line:34:1> line:32:5 used also_after 'int (double)'
104 // CHECK-NEXT: | |-ParmVarDecl [[ADDR_45:0x[a-z0-9]*]] <col:16> col:22 'double'
105 // CHECK-NEXT: | |-CompoundStmt [[ADDR_46:0x[a-z0-9]*]] <col:24, line:34:1>
106 // CHECK-NEXT: | | `-ReturnStmt [[ADDR_47:0x[a-z0-9]*]] <line:33:3, col:10>
107 // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_48:0x[a-z0-9]*]] <col:10> 'int' 6
108 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_49:0x[a-z0-9]*]] <<invalid sloc>> Inherited Implicit implementation={vendor(score(100): llvm)}
109 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_25]] <line:16:1> 'int (double)' Function [[ADDR_26]] 'also_after[implementation={vendor(llvm)}]' 'int (double)'
110 // CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_50:0x[a-z0-9]*]] <line:36:1, line:40:1> line:37:5 test1
111 // CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_51:0x[a-z0-9]*]] <line:36:10, col:19> col:19 referenced typename depth 0 index 0 T
112 // CHECK-NEXT: | |-FunctionDecl [[ADDR_52:0x[a-z0-9]*]] <line:37:1, line:40:1> line:37:5 test1 'int ({{.*}})'
113 // CHECK-NEXT: | | `-CompoundStmt [[ADDR_53:0x[a-z0-9]*]] <col:13, line:40:1>
114 // CHECK-NEXT: | | `-ReturnStmt [[ADDR_54:0x[a-z0-9]*]] <line:39:3, col:25>
115 // CHECK-NEXT: | | `-CallExpr [[ADDR_55:0x[a-z0-9]*]] <col:10, col:25> '<dependent type>'
116 // CHECK-NEXT: | | |-UnresolvedLookupExpr [[ADDR_56:0x[a-z0-9]*]] <col:10> '<overloaded function type>' {{.*}}(ADL) = 'also_after' [[ADDR_44]] [[ADDR_38]] [[ADDR_33]]
117 // CHECK-NEXT: | | `-CXXUnresolvedConstructExpr [[ADDR_57:0x[a-z0-9]*]] <col:21, col:24> 'T' 'T'
118 // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_58:0x[a-z0-9]*]] <col:23> 'int' 0
119 // CHECK-NEXT: | `-FunctionDecl [[ADDR_59:0x[a-z0-9]*]] <line:37:1, line:40:1> line:37:5 used test1 'int ({{.*}})'
120 // CHECK-NEXT: | |-TemplateArgument type 'double'
121 // CHECK: | `-CompoundStmt [[ADDR_60:0x[a-z0-9]*]] <col:13, line:40:1>
122 // CHECK-NEXT: | `-ReturnStmt [[ADDR_61:0x[a-z0-9]*]] <line:39:3, col:25>
123 // CHECK-NEXT: | `-PseudoObjectExpr [[ADDR_62:0x[a-z0-9]*]] <col:10, col:25> 'int'
124 // CHECK-NEXT: | |-CallExpr [[ADDR_63:0x[a-z0-9]*]] <col:10, col:25> 'int'
125 // CHECK-NEXT: | | |-ImplicitCastExpr [[ADDR_64:0x[a-z0-9]*]] <col:10> 'int (*)(double)' <FunctionToPointerDecay>
126 // CHECK-NEXT: | | | `-DeclRefExpr [[ADDR_65:0x[a-z0-9]*]] <col:10> 'int (double)' {{.*}}Function [[ADDR_44]] 'also_after' 'int (double)'
127 // CHECK-NEXT: | | `-CXXFunctionalCastExpr [[ADDR_66:0x[a-z0-9]*]] <col:21, col:24> 'double':'double' functional cast to double <NoOp>
128 // CHECK-NEXT: | | `-ImplicitCastExpr [[ADDR_67:0x[a-z0-9]*]] <col:23> 'double':'double' <IntegralToFloating> part_of_explicit_cast
129 // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_58]] <col:23> 'int' 0
130 // CHECK-NEXT: | `-CallExpr [[ADDR_68:0x[a-z0-9]*]] <line:16:1, line:39:25> 'int'
131 // CHECK-NEXT: | |-ImplicitCastExpr [[ADDR_69:0x[a-z0-9]*]] <line:16:1> 'int (*)(double)' <FunctionToPointerDecay>
132 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_25]] <col:1> 'int (double)' Function [[ADDR_26]] 'also_after[implementation={vendor(llvm)}]' 'int (double)'
133 // CHECK-NEXT: | `-CXXFunctionalCastExpr [[ADDR_66]] <line:39:21, col:24> 'double':'double' functional cast to double <NoOp>
134 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_67]] <col:23> 'double':'double' <IntegralToFloating> part_of_explicit_cast
135 // CHECK-NEXT: | `-IntegerLiteral [[ADDR_58]] <col:23> 'int' 0
136 // CHECK-NEXT: |-TypedefDecl [[ADDR_70:0x[a-z0-9]*]] <line:42:1, col:18> col:14 referenced Ty 'int (*)({{.*}})'
137 // CHECK-NEXT: | `-PointerType [[ADDR_71:0x[a-z0-9]*]] 'int (*)({{.*}})'
138 // CHECK-NEXT: | `-ParenType [[ADDR_72:0x[a-z0-9]*]] 'int ({{.*}})' sugar
139 // CHECK-NEXT: | `-FunctionProtoType [[ADDR_73:0x[a-z0-9]*]] 'int ({{.*}})' cdecl
140 // CHECK-NEXT: | `-BuiltinType [[ADDR_74:0x[a-z0-9]*]] 'int'
141 // CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_75:0x[a-z0-9]*]] <line:44:1, line:48:1> line:45:5 test2
142 // CHECK-NEXT: | |-NonTypeTemplateParmDecl [[ADDR_76:0x[a-z0-9]*]] <line:44:10, col:13> col:13 referenced 'Ty':'int (*)({{.*}})' depth 0 index 0 fn
143 // CHECK-NEXT: | |-FunctionDecl [[ADDR_77:0x[a-z0-9]*]] <line:45:1, line:48:1> line:45:5 test2 'int ({{.*}})'
144 // CHECK-NEXT: | | `-CompoundStmt [[ADDR_78:0x[a-z0-9]*]] <col:13, line:48:1>
145 // CHECK-NEXT: | | `-ReturnStmt [[ADDR_79:0x[a-z0-9]*]] <line:47:3, col:13>
146 // CHECK-NEXT: | | `-CallExpr [[ADDR_80:0x[a-z0-9]*]] <col:10, col:13> 'int'
147 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_81:0x[a-z0-9]*]] <col:10> 'Ty':'int (*)({{.*}})' NonTypeTemplateParm [[ADDR_76]] 'fn' 'Ty':'int (*)({{.*}})'
148 // CHECK-NEXT: | `-FunctionDecl [[ADDR_82:0x[a-z0-9]*]] <line:45:1, line:48:1> line:45:5 used test2 'int ({{.*}})'
149 // CHECK-NEXT: | |-TemplateArgument decl
150 // CHECK-NEXT: | | `-Function [[ADDR_0]] 'also_before' 'int ({{.*}})'
151 // CHECK-NEXT: | `-CompoundStmt [[ADDR_83:0x[a-z0-9]*]] <col:13, line:48:1>
152 // CHECK-NEXT: | `-ReturnStmt [[ADDR_84:0x[a-z0-9]*]] <line:47:3, col:13>
153 // CHECK-NEXT: | `-PseudoObjectExpr [[ADDR_85:0x[a-z0-9]*]] <col:10, col:13> 'int'
154 // CHECK-NEXT: | |-CallExpr [[ADDR_86:0x[a-z0-9]*]] <col:10, col:13> 'int'
155 // CHECK-NEXT: | | `-SubstNonTypeTemplateParmExpr [[ADDR_87:0x[a-z0-9]*]] <col:10> 'int (*)({{.*}})'
156 // CHECK-NEXT: | | |-NonTypeTemplateParmDecl {{.*}} referenced 'Ty':'int (*)()' depth 0 index 0 fn
157 // CHECK-NEXT: | | `-UnaryOperator [[ADDR_88:0x[a-z0-9]*]] <line:47:10> 'int (*)({{.*}})' prefix '&' cannot overflow
158 // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_89:0x[a-z0-9]*]] <col:10> 'int ({{.*}})' {{.*}}Function [[ADDR_0]] 'also_before' 'int ({{.*}})'
159 // CHECK-NEXT: | `-CallExpr [[ADDR_90:0x[a-z0-9]*]] <line:21:1, line:47:13> 'int'
160 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_91:0x[a-z0-9]*]] <line:21:1> 'int (*)({{.*}})' <FunctionToPointerDecay>
161 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_5]] <col:1> 'int ({{.*}})' Function [[ADDR_6]] 'also_before[implementation={vendor(llvm)}]' 'int ({{.*}})'
162 // CHECK-NEXT: `-FunctionDecl [[ADDR_92:0x[a-z0-9]*]] <line:50:1, line:53:1> line:50:5 test 'int ({{.*}})'
163 // CHECK-NEXT: `-CompoundStmt [[ADDR_93:0x[a-z0-9]*]] <col:12, line:53:1>
164 // CHECK-NEXT: `-ReturnStmt [[ADDR_94:0x[a-z0-9]*]] <line:52:3, col:47>
165 // CHECK-NEXT: `-BinaryOperator [[ADDR_95:0x[a-z0-9]*]] <col:10, col:47> 'int' '+'
166 // CHECK-NEXT: |-CallExpr [[ADDR_96:0x[a-z0-9]*]] <col:10, col:24> 'int'
167 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_97:0x[a-z0-9]*]] <col:10, col:22> 'int (*)({{.*}})' <FunctionToPointerDecay>
168 // CHECK-NEXT: | `-DeclRefExpr [[ADDR_98:0x[a-z0-9]*]] <col:10, col:22> 'int ({{.*}})' {{.*}}Function [[ADDR_59]] 'test1' 'int ({{.*}})' (FunctionTemplate [[ADDR_50]] 'test1')
169 // CHECK-NEXT: `-CallExpr [[ADDR_99:0x[a-z0-9]*]] <col:28, col:47> 'int'
170 // CHECK-NEXT: `-ImplicitCastExpr [[ADDR_100:0x[a-z0-9]*]] <col:28, col:45> 'int (*)({{.*}})' <FunctionToPointerDecay>
171 // CHECK-NEXT: `-DeclRefExpr [[ADDR_101:0x[a-z0-9]*]] <col:28, col:45> 'int ({{.*}})' {{.*}}Function [[ADDR_82]] 'test2' 'int ({{.*}})' (FunctionTemplate [[ADDR_75]] 'test2')