diff options
Diffstat (limited to 'clang/test/SemaHLSL/Language')
-rw-r--r-- | clang/test/SemaHLSL/Language/AggregateSplatCasts.hlsl | 7 | ||||
-rw-r--r-- | clang/test/SemaHLSL/Language/ElementwiseCasts.hlsl | 24 | ||||
-rw-r--r-- | clang/test/SemaHLSL/Language/TemplateOutArg.hlsl | 83 |
3 files changed, 111 insertions, 3 deletions
diff --git a/clang/test/SemaHLSL/Language/AggregateSplatCasts.hlsl b/clang/test/SemaHLSL/Language/AggregateSplatCasts.hlsl index e5a851c..623fca0 100644 --- a/clang/test/SemaHLSL/Language/AggregateSplatCasts.hlsl +++ b/clang/test/SemaHLSL/Language/AggregateSplatCasts.hlsl @@ -3,8 +3,9 @@ // splat from vec1 to vec // CHECK-LABEL: call1 // CHECK: CStyleCastExpr {{.*}} 'int3':'vector<int, 3>' <HLSLAggregateSplatCast> -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' lvalue <FloatingToIntegral> part_of_explicit_cast -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float' lvalue <HLSLVectorTruncation> part_of_explicit_cast +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' <FloatingToIntegral> part_of_explicit_cast +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float' <HLSLVectorTruncation> part_of_explicit_cast +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float1':'vector<float, 1>' <LValueToRValue> part_of_explicit_cast // CHECK-NEXT: DeclRefExpr {{.*}} 'float1':'vector<float, 1>' lvalue Var {{.*}} 'A' 'float1':'vector<float, 1>' export void call1() { float1 A = {1.0}; @@ -21,7 +22,7 @@ struct S { // splat from scalar to aggregate // CHECK-LABEL: call2 // CHECK: CStyleCastExpr {{.*}} 'S' <HLSLAggregateSplatCast> -// CHECK-NEXt: IntegerLiteral {{.*}} 'int' 5 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 5 export void call2() { S s = (S)5; } diff --git a/clang/test/SemaHLSL/Language/ElementwiseCasts.hlsl b/clang/test/SemaHLSL/Language/ElementwiseCasts.hlsl index 563d3f0..8481cfc 100644 --- a/clang/test/SemaHLSL/Language/ElementwiseCasts.hlsl +++ b/clang/test/SemaHLSL/Language/ElementwiseCasts.hlsl @@ -21,3 +21,27 @@ export void call2() { float B[1] = {1.0}; B = (float[1])A; } + +struct S { + int A; + float F; +}; + +// cast from a struct +// CHECK-LABEL: call3 +// CHECK: CStyleCastExpr {{.*}} 'int[2]' <HLSLElementwiseCast> +// CHECK-NEXT: DeclRefExpr {{.*}} 'S' lvalue Var {{.*}} 'SS' 'S' +export void call3() { + S SS = {1,1.0}; + int A[2] = (int[2])SS; +} + +// cast from a vector +// CHECK-LABEL: call4 +// CHECK: CStyleCastExpr {{.*}} 'float[3]' <HLSLElementwiseCast> +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int3':'vector<int, 3>' <LValueToRValue> part_of_explicit_cast +// CHECK-NEXT: DeclRefExpr {{.*}} 'int3':'vector<int, 3>' lvalue Var {{.*}} 'A' 'int3' +export void call4() { + int3 A = {1,2,3}; + float B[3] = (float[3])A; +} diff --git a/clang/test/SemaHLSL/Language/TemplateOutArg.hlsl b/clang/test/SemaHLSL/Language/TemplateOutArg.hlsl index 2d6252c..3365dbe 100644 --- a/clang/test/SemaHLSL/Language/TemplateOutArg.hlsl +++ b/clang/test/SemaHLSL/Language/TemplateOutArg.hlsl @@ -195,6 +195,81 @@ T buzz(int X, T Y) { return X + Y; } +// Case 4: Verify that the parameter modifier attributes are instantiated +// for both templated and non-templated arguments, and that the non-templated +// out argument type is not modified by the template instantiation. + +// CHECK-LABEL: FunctionTemplateDecl {{.*}} fizz_two + +// Check the pattern decl. +// CHECK: FunctionDecl {{.*}} fizz_two 'void (inout T, out int)' +// CHECK-NEXT: ParmVarDecl {{.*}} referenced V 'T' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} inout +// CHECK-NEXT: ParmVarDecl {{.*}} referenced I 'int &__restrict' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} out + +// Check the 3 instantiations (int, float, & double). + +// CHECK-LABEL: FunctionDecl {{.*}} used fizz_two 'void (inout int, out int)' implicit_instantiation +// CHECK: ParmVarDecl {{.*}} used V 'int &__restrict' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} inout +// CHECK: ParmVarDecl {{.*}} used I 'int &__restrict' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} out + +// CHECK-LABEL: FunctionDecl {{.*}} used fizz_two 'void (inout float, out int)' implicit_instantiation +// CHECK: ParmVarDecl {{.*}} used V 'float &__restrict' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} inout +// CHECK: ParmVarDecl {{.*}} used I 'int &__restrict' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} out + +// CHECK-LABEL: FunctionDecl {{.*}} used fizz_two 'void (inout double, out int)' implicit_instantiation +// CHECK: ParmVarDecl {{.*}} used V 'double &__restrict' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} inout +// CHECK: ParmVarDecl {{.*}} used I 'int &__restrict' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} out +template <typename T> +void fizz_two(inout T V, out int I) { + V += 2; + I = V; +} + +// Case 5: Verify that `in` parameter modifier attributes are instantiated +// for both templated and non-templated arguments and argument types are not +// modified + +// CHECK-LABEL: FunctionTemplateDecl {{.*}} buzz_two + +// Check the pattern decl. +// CHECK: FunctionDecl {{.*}} buzz_two 'int (T, int)' +// CHECK-NEXT: ParmVarDecl {{.*}} referenced A 'T' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} in +// CHECK-NEXT: ParmVarDecl {{.*}} referenced B 'int' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} in + +// Check the 3 instantiations (int, float, & double). + +// CHECK-LABEL: FunctionDecl {{.*}} used buzz_two 'int (int, int)' implicit_instantiation +// CHECK: ParmVarDecl {{.*}} used A 'int' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} in +// CHECK: ParmVarDecl {{.*}} used B 'int' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} in + +// CHECK-LABEL: FunctionDecl {{.*}} used buzz_two 'int (float, int)' implicit_instantiation +// CHECK: ParmVarDecl {{.*}} used A 'float' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} in +// CHECK: ParmVarDecl {{.*}} used B 'int' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} in + +// CHECK-LABEL: FunctionDecl {{.*}} used buzz_two 'int (double, int)' implicit_instantiation +// CHECK: ParmVarDecl {{.*}} used A 'double' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} in +// CHECK: ParmVarDecl {{.*}} used B 'int' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} in +template <typename T> +int buzz_two(in T A, in int B) { + return A + B; +} + export void caller() { int X = 2; float Y = 3.3; @@ -211,4 +286,12 @@ export void caller() { X = buzz(X, X); Y = buzz(X, Y); Z = buzz(X, Z); + + fizz_two(X, X); + fizz_two(Y, X); + fizz_two(Z, X); + + X = buzz_two(X, X); + X = buzz_two(Y, X); + X = buzz_two(Z, X); } |