// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s | FileCheck %s // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s -x c++| FileCheck %s // expected-no-diagnostics int also_before() { return 1; } #pragma omp begin declare variant match(implementation={vendor(score(100):llvm)}) int also_after(void) { return 2; } int also_after(int) { return 3; } int also_after(double) { return 0; } #pragma omp end declare variant #pragma omp begin declare variant match(implementation={vendor(score(0):llvm)}) int also_before() { return 0; } #pragma omp end declare variant int also_after(void) { return 4; } int also_after(int) { return 5; } int also_after(double) { return 6; } template int test1() { // Should return 0. return also_after(T(0)); } typedef int(*Ty)(); template int test2() { // Should return 0. return fn(); } int test() { // Should return 0. return test1() + test2(); } // CHECK: |-FunctionDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:7:1> line:5:5 used also_before 'int ({{.*}})' // CHECK-NEXT: | |-CompoundStmt [[ADDR_1:0x[a-z0-9]*]] // CHECK-NEXT: | | `-ReturnStmt [[ADDR_2:0x[a-z0-9]*]] // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_3:0x[a-z0-9]*]] 'int' 1 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_4:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(0): llvm)} // CHECK-NEXT: | `-DeclRefExpr [[ADDR_5:0x[a-z0-9]*]] 'int ({{.*}})' Function [[ADDR_6:0x[a-z0-9]*]] 'also_before[implementation={vendor(llvm)}]' 'int ({{.*}})' // CHECK-NEXT: |-FunctionDecl [[ADDR_7:0x[a-z0-9]*]] col:5 implicit also_after 'int ({{.*}})' // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_8:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)} // CHECK-NEXT: | `-DeclRefExpr [[ADDR_9:0x[a-z0-9]*]] 'int ({{.*}})' Function [[ADDR_10:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int ({{.*}})' // CHECK-NEXT: |-FunctionDecl [[ADDR_10]] line:10:1 also_after[implementation={vendor(llvm)}] 'int ({{.*}})' // CHECK-NEXT: | `-CompoundStmt [[ADDR_11:0x[a-z0-9]*]] // CHECK-NEXT: | `-ReturnStmt [[ADDR_12:0x[a-z0-9]*]] // CHECK-NEXT: | `-IntegerLiteral [[ADDR_13:0x[a-z0-9]*]] 'int' 2 // CHECK-NEXT: |-FunctionDecl [[ADDR_14:0x[a-z0-9]*]] col:5 implicit also_after 'int (int)' // CHECK-NEXT: | |-ParmVarDecl [[ADDR_15:0x[a-z0-9]*]] col:19 'int' // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_16:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)} // CHECK-NEXT: | `-DeclRefExpr [[ADDR_17:0x[a-z0-9]*]] 'int (int)' Function [[ADDR_18:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int (int)' // CHECK-NEXT: |-FunctionDecl [[ADDR_18]] line:13:1 also_after[implementation={vendor(llvm)}] 'int (int)' // CHECK-NEXT: | |-ParmVarDecl [[ADDR_15]] col:19 'int' // CHECK-NEXT: | `-CompoundStmt [[ADDR_19:0x[a-z0-9]*]] // CHECK-NEXT: | `-ReturnStmt [[ADDR_20:0x[a-z0-9]*]] // CHECK-NEXT: | `-IntegerLiteral [[ADDR_21:0x[a-z0-9]*]] 'int' 3 // CHECK-NEXT: |-FunctionDecl [[ADDR_22:0x[a-z0-9]*]] col:5 implicit used also_after 'int (double)' // CHECK-NEXT: | |-ParmVarDecl [[ADDR_23:0x[a-z0-9]*]] col:22 'double' // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_24:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)} // CHECK-NEXT: | `-DeclRefExpr [[ADDR_25:0x[a-z0-9]*]] 'int (double)' Function [[ADDR_26:0x[a-z0-9]*]] 'also_after[implementation={vendor(llvm)}]' 'int (double)' // CHECK-NEXT: |-FunctionDecl [[ADDR_26]] line:16:1 also_after[implementation={vendor(llvm)}] 'int (double)' // CHECK-NEXT: | |-ParmVarDecl [[ADDR_23]] col:22 'double' // CHECK-NEXT: | `-CompoundStmt [[ADDR_27:0x[a-z0-9]*]] // CHECK-NEXT: | `-ReturnStmt [[ADDR_28:0x[a-z0-9]*]] // CHECK-NEXT: | `-IntegerLiteral [[ADDR_29:0x[a-z0-9]*]] 'int' 0 // CHECK-NEXT: |-FunctionDecl [[ADDR_6]] line:21:1 also_before[implementation={vendor(llvm)}] 'int ({{.*}})' // CHECK-NEXT: | `-CompoundStmt [[ADDR_30:0x[a-z0-9]*]] // CHECK-NEXT: | `-ReturnStmt [[ADDR_31:0x[a-z0-9]*]] // CHECK-NEXT: | `-IntegerLiteral [[ADDR_32:0x[a-z0-9]*]] 'int' 0 // CHECK-NEXT: |-FunctionDecl [[ADDR_33:0x[a-z0-9]*]] prev [[ADDR_7]] line:26:5 also_after 'int ({{.*}})' // CHECK-NEXT: | |-CompoundStmt [[ADDR_34:0x[a-z0-9]*]] // CHECK-NEXT: | | `-ReturnStmt [[ADDR_35:0x[a-z0-9]*]] // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_36:0x[a-z0-9]*]] 'int' 4 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_37:0x[a-z0-9]*]] <> Inherited Implicit implementation={vendor(score(100): llvm)} // CHECK-NEXT: | `-DeclRefExpr [[ADDR_9]] 'int ({{.*}})' Function [[ADDR_10]] 'also_after[implementation={vendor(llvm)}]' 'int ({{.*}})' // CHECK-NEXT: |-FunctionDecl [[ADDR_38:0x[a-z0-9]*]] prev [[ADDR_14]] line:29:5 also_after 'int (int)' // CHECK-NEXT: | |-ParmVarDecl [[ADDR_39:0x[a-z0-9]*]] col:19 'int' // CHECK-NEXT: | |-CompoundStmt [[ADDR_40:0x[a-z0-9]*]] // CHECK-NEXT: | | `-ReturnStmt [[ADDR_41:0x[a-z0-9]*]] // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_42:0x[a-z0-9]*]] 'int' 5 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_43:0x[a-z0-9]*]] <> Inherited Implicit implementation={vendor(score(100): llvm)} // CHECK-NEXT: | `-DeclRefExpr [[ADDR_17]] 'int (int)' Function [[ADDR_18]] 'also_after[implementation={vendor(llvm)}]' 'int (int)' // CHECK-NEXT: |-FunctionDecl [[ADDR_44:0x[a-z0-9]*]] prev [[ADDR_22]] line:32:5 used also_after 'int (double)' // CHECK-NEXT: | |-ParmVarDecl [[ADDR_45:0x[a-z0-9]*]] col:22 'double' // CHECK-NEXT: | |-CompoundStmt [[ADDR_46:0x[a-z0-9]*]] // CHECK-NEXT: | | `-ReturnStmt [[ADDR_47:0x[a-z0-9]*]] // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_48:0x[a-z0-9]*]] 'int' 6 // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_49:0x[a-z0-9]*]] <> Inherited Implicit implementation={vendor(score(100): llvm)} // CHECK-NEXT: | `-DeclRefExpr [[ADDR_25]] 'int (double)' Function [[ADDR_26]] 'also_after[implementation={vendor(llvm)}]' 'int (double)' // CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_50:0x[a-z0-9]*]] line:37:5 test1 // CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_51:0x[a-z0-9]*]] col:19 referenced typename depth 0 index 0 T // CHECK-NEXT: | |-FunctionDecl [[ADDR_52:0x[a-z0-9]*]] line:37:5 test1 'int ({{.*}})' // CHECK-NEXT: | | `-CompoundStmt [[ADDR_53:0x[a-z0-9]*]] // CHECK-NEXT: | | `-ReturnStmt [[ADDR_54:0x[a-z0-9]*]] // CHECK-NEXT: | | `-CallExpr [[ADDR_55:0x[a-z0-9]*]] '' // CHECK-NEXT: | | |-UnresolvedLookupExpr [[ADDR_56:0x[a-z0-9]*]] '' {{.*}}(ADL) = 'also_after' [[ADDR_44]] [[ADDR_38]] [[ADDR_33]] // CHECK-NEXT: | | `-CXXUnresolvedConstructExpr [[ADDR_57:0x[a-z0-9]*]] 'T' 'T' // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_58:0x[a-z0-9]*]] 'int' 0 // CHECK-NEXT: | `-FunctionDecl [[ADDR_59:0x[a-z0-9]*]] line:37:5 used test1 'int ({{.*}})' // CHECK-NEXT: | |-TemplateArgument type 'double' // CHECK: | `-CompoundStmt [[ADDR_60:0x[a-z0-9]*]] // CHECK-NEXT: | `-ReturnStmt [[ADDR_61:0x[a-z0-9]*]] // CHECK-NEXT: | `-PseudoObjectExpr [[ADDR_62:0x[a-z0-9]*]] 'int' // CHECK-NEXT: | |-CallExpr [[ADDR_63:0x[a-z0-9]*]] 'int' // CHECK-NEXT: | | |-ImplicitCastExpr [[ADDR_64:0x[a-z0-9]*]] 'int (*)(double)' // CHECK-NEXT: | | | `-DeclRefExpr [[ADDR_65:0x[a-z0-9]*]] 'int (double)' {{.*}}Function [[ADDR_44]] 'also_after' 'int (double)' // CHECK-NEXT: | | `-CXXFunctionalCastExpr [[ADDR_66:0x[a-z0-9]*]] 'double':'double' functional cast to double // CHECK-NEXT: | | `-ImplicitCastExpr [[ADDR_67:0x[a-z0-9]*]] 'double':'double' part_of_explicit_cast // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_58]] 'int' 0 // CHECK-NEXT: | `-CallExpr [[ADDR_68:0x[a-z0-9]*]] 'int' // CHECK-NEXT: | |-ImplicitCastExpr [[ADDR_69:0x[a-z0-9]*]] 'int (*)(double)' // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_25]] 'int (double)' Function [[ADDR_26]] 'also_after[implementation={vendor(llvm)}]' 'int (double)' // CHECK-NEXT: | `-CXXFunctionalCastExpr [[ADDR_66]] 'double':'double' functional cast to double // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_67]] 'double':'double' part_of_explicit_cast // CHECK-NEXT: | `-IntegerLiteral [[ADDR_58]] 'int' 0 // CHECK-NEXT: |-TypedefDecl [[ADDR_70:0x[a-z0-9]*]] col:14 referenced Ty 'int (*)({{.*}})' // CHECK-NEXT: | `-PointerType [[ADDR_71:0x[a-z0-9]*]] 'int (*)({{.*}})' // CHECK-NEXT: | `-ParenType [[ADDR_72:0x[a-z0-9]*]] 'int ({{.*}})' sugar // CHECK-NEXT: | `-FunctionProtoType [[ADDR_73:0x[a-z0-9]*]] 'int ({{.*}})' cdecl // CHECK-NEXT: | `-BuiltinType [[ADDR_74:0x[a-z0-9]*]] 'int' // CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_75:0x[a-z0-9]*]] line:45:5 test2 // CHECK-NEXT: | |-NonTypeTemplateParmDecl [[ADDR_76:0x[a-z0-9]*]] col:13 referenced 'Ty':'int (*)({{.*}})' depth 0 index 0 fn // CHECK-NEXT: | |-FunctionDecl [[ADDR_77:0x[a-z0-9]*]] line:45:5 test2 'int ({{.*}})' // CHECK-NEXT: | | `-CompoundStmt [[ADDR_78:0x[a-z0-9]*]] // CHECK-NEXT: | | `-ReturnStmt [[ADDR_79:0x[a-z0-9]*]] // CHECK-NEXT: | | `-CallExpr [[ADDR_80:0x[a-z0-9]*]] 'int' // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_81:0x[a-z0-9]*]] 'Ty':'int (*)({{.*}})' NonTypeTemplateParm [[ADDR_76]] 'fn' 'Ty':'int (*)({{.*}})' // CHECK-NEXT: | `-FunctionDecl [[ADDR_82:0x[a-z0-9]*]] line:45:5 used test2 'int ({{.*}})' // CHECK-NEXT: | |-TemplateArgument decl // CHECK-NEXT: | | `-Function [[ADDR_0]] 'also_before' 'int ({{.*}})' // CHECK-NEXT: | `-CompoundStmt [[ADDR_83:0x[a-z0-9]*]] // CHECK-NEXT: | `-ReturnStmt [[ADDR_84:0x[a-z0-9]*]] // CHECK-NEXT: | `-PseudoObjectExpr [[ADDR_85:0x[a-z0-9]*]] 'int' // CHECK-NEXT: | |-CallExpr [[ADDR_86:0x[a-z0-9]*]] 'int' // CHECK-NEXT: | | `-SubstNonTypeTemplateParmExpr [[ADDR_87:0x[a-z0-9]*]] 'int (*)({{.*}})' // CHECK-NEXT: | | |-NonTypeTemplateParmDecl {{.*}} referenced 'Ty':'int (*)()' depth 0 index 0 fn // CHECK-NEXT: | | `-UnaryOperator [[ADDR_88:0x[a-z0-9]*]] 'int (*)({{.*}})' prefix '&' cannot overflow // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_89:0x[a-z0-9]*]] 'int ({{.*}})' {{.*}}Function [[ADDR_0]] 'also_before' 'int ({{.*}})' // CHECK-NEXT: | `-CallExpr [[ADDR_90:0x[a-z0-9]*]] 'int' // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_91:0x[a-z0-9]*]] 'int (*)({{.*}})' // CHECK-NEXT: | `-DeclRefExpr [[ADDR_5]] 'int ({{.*}})' Function [[ADDR_6]] 'also_before[implementation={vendor(llvm)}]' 'int ({{.*}})' // CHECK-NEXT: `-FunctionDecl [[ADDR_92:0x[a-z0-9]*]] line:50:5 test 'int ({{.*}})' // CHECK-NEXT: `-CompoundStmt [[ADDR_93:0x[a-z0-9]*]] // CHECK-NEXT: `-ReturnStmt [[ADDR_94:0x[a-z0-9]*]] // CHECK-NEXT: `-BinaryOperator [[ADDR_95:0x[a-z0-9]*]] 'int' '+' // CHECK-NEXT: |-CallExpr [[ADDR_96:0x[a-z0-9]*]] 'int' // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_97:0x[a-z0-9]*]] 'int (*)({{.*}})' // CHECK-NEXT: | `-DeclRefExpr [[ADDR_98:0x[a-z0-9]*]] 'int ({{.*}})' {{.*}}Function [[ADDR_59]] 'test1' 'int ({{.*}})' (FunctionTemplate [[ADDR_50]] 'test1') // CHECK-NEXT: `-CallExpr [[ADDR_99:0x[a-z0-9]*]] 'int' // CHECK-NEXT: `-ImplicitCastExpr [[ADDR_100:0x[a-z0-9]*]] 'int (*)({{.*}})' // CHECK-NEXT: `-DeclRefExpr [[ADDR_101:0x[a-z0-9]*]] 'int ({{.*}})' {{.*}}Function [[ADDR_82]] 'test2' 'int ({{.*}})' (FunctionTemplate [[ADDR_75]] 'test2')