| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -ast-dump %s | FileCheck %s |
| 2 |
|
| 3 |
void fn(float x[2]) { } |
| 4 |
|
| 5 |
// CHECK: CallExpr {{.*}} 'void' |
| 6 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(float[2])' <FunctionToPointerDecay> |
| 7 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'void (float[2])' lvalue Function {{.*}} 'fn' 'void (float[2])' |
| 8 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float[2]' <HLSLArrayRValue> |
| 9 |
|
| 10 |
void call() { |
| 11 |
float Arr[2] = {0, 0}; |
| 12 |
fn(Arr); |
| 13 |
} |
| 14 |
|
| 15 |
struct Obj { |
| 16 |
float V; |
| 17 |
int X; |
| 18 |
}; |
| 19 |
|
| 20 |
void fn2(Obj O[4]) { } |
| 21 |
|
| 22 |
// CHECK: CallExpr {{.*}} 'void' |
| 23 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(Obj[4])' <FunctionToPointerDecay> |
| 24 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'void (Obj[4])' lvalue Function {{.*}} 'fn2' 'void (Obj[4])' |
| 25 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'Obj[4]' <HLSLArrayRValue> |
| 26 |
|
| 27 |
void call2() { |
| 28 |
Obj Arr[4] = {0, 0, 0, 0, 0, 0, 0, 0}; |
| 29 |
fn2(Arr); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
void fn3(float x[2][2]) { } |
| 34 |
|
| 35 |
// CHECK: CallExpr {{.*}} 'void' |
| 36 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(float[2][2])' <FunctionToPointerDecay> |
| 37 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'void (float[2][2])' lvalue Function {{.*}} 'fn3' 'void (float[2][2])' |
| 38 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float[2][2]' <HLSLArrayRValue> |
| 39 |
|
| 40 |
void call3() { |
| 41 |
float Arr[2][2] = {{0, 0}, {1,1}}; |
| 42 |
fn3(Arr); |
| 43 |
} |
| 44 |
|
| 45 |
// This template function should be instantiated 3 times for the different array |
| 46 |
// types and lengths. |
| 47 |
|
| 48 |
// CHECK: FunctionTemplateDecl {{.*}} template_fn |
| 49 |
// CHECK-NEXT: TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T |
| 50 |
// CHECK-NEXT: FunctionDecl {{.*}} template_fn 'void (T)' |
| 51 |
// CHECK-NEXT: ParmVarDecl {{.*}} Val 'T' |
| 52 |
|
| 53 |
// CHECK: FunctionDecl {{.*}} used template_fn 'void (float[2])' implicit_instantiation |
| 54 |
// CHECK-NEXT: TemplateArgument type 'float[2]' |
| 55 |
// CHECK-NEXT: ArrayParameterType {{.*}} 'float[2]' 2 |
| 56 |
// CHECK-NEXT: BuiltinType {{.*}} 'float' |
| 57 |
// CHECK-NEXT: ParmVarDecl {{.*}} Val 'float[2]' |
| 58 |
|
| 59 |
// CHECK: FunctionDecl {{.*}} used template_fn 'void (float[4])' implicit_instantiation |
| 60 |
// CHECK-NEXT: TemplateArgument type 'float[4]' |
| 61 |
// CHECK-NEXT: ArrayParameterType {{.*}} 'float[4]' 4 |
| 62 |
// CHECK-NEXT: BuiltinType {{.*}} 'float' |
| 63 |
// CHECK-NEXT: ParmVarDecl {{.*}} Val 'float[4]' |
| 64 |
|
| 65 |
// CHECK: FunctionDecl {{.*}} used template_fn 'void (int[3])' implicit_instantiation |
| 66 |
// CHECK-NEXT: TemplateArgument type 'int[3]' |
| 67 |
// CHECK-NEXT: ArrayParameterType {{.*}} 'int[3]' 3 |
| 68 |
// CHECK-NEXT: BuiltinType {{.*}} 'int' |
| 69 |
// CHECK-NEXT: ParmVarDecl {{.*}} Val 'int[3]' |
| 70 |
|
| 71 |
template<typename T> |
| 72 |
void template_fn(T Val) {} |
| 73 |
|
| 74 |
// CHECK: FunctionDecl {{.*}} call 'void (float[2], float[4], int[3])' |
| 75 |
// CHECK: CallExpr {{.*}} 'void' |
| 76 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(float[2])' <FunctionToPointerDecay> |
| 77 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'void (float[2])' lvalue Function {{.*}} 'template_fn' 'void (float[2])' (FunctionTemplate {{.*}} 'template_fn') |
| 78 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float[2]' <HLSLArrayRValue> |
| 79 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'float[2]' lvalue ParmVar {{.*}} 'FA2' 'float[2]' |
| 80 |
// CHECK-NEXT: CallExpr {{.*}} 'void' |
| 81 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(float[4])' <FunctionToPointerDecay> |
| 82 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'void (float[4])' lvalue Function {{.*}} 'template_fn' 'void (float[4])' (FunctionTemplate {{.*}} 'template_fn') |
| 83 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float[4]' <HLSLArrayRValue> |
| 84 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'float[4]' lvalue ParmVar {{.*}} 'FA4' 'float[4]' |
| 85 |
// CHECK-NEXT: CallExpr {{.*}} 'void' |
| 86 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(int[3])' <FunctionToPointerDecay> |
| 87 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'void (int[3])' lvalue Function {{.*}} 'template_fn' 'void (int[3])' (FunctionTemplate {{.*}} 'template_fn') |
| 88 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int[3]' <HLSLArrayRValue> |
| 89 |
// CHECK-NEXT: DeclRefExpr {{.*}} 'int[3]' lvalue ParmVar {{.*}} 'IA3' 'int[3]' |
| 90 |
|
| 91 |
void call(float FA2[2], float FA4[4], int IA3[3]) { |
| 92 |
template_fn(FA2); |
| 93 |
template_fn(FA4); |
| 94 |
template_fn(IA3); |
| 95 |
} |