From b6fd6d4cc53d263c586264d1476265fbdcc0ba21 Mon Sep 17 00:00:00 2001 From: Chris B Date: Fri, 14 Jun 2024 13:13:25 -0500 Subject: [PATCH] [HLSL] Use hlsl vector template in type printer (#95489) In HLSL we really want to be using the HLSL vector template and other built-in sugared spellings for some builtin types. This updates the type printer to take an option to use HLSL type spellings. This changes printing vector type names from: ``` T __attribute__((ext_vector_type(N))) ``` To: ``` vector ``` --- clang/include/clang/AST/PrettyPrinter.h | 7 +- clang/lib/AST/TypePrinter.cpp | 32 +++++-- clang/test/AST/HLSL/pch.hlsl | 2 +- clang/test/AST/HLSL/pch_with_buf.hlsl | 2 +- clang/test/AST/HLSL/vector-alias.hlsl | 16 ++-- clang/test/AST/HLSL/vector-constructors.hlsl | 22 ++--- clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl | 2 +- .../test/SemaHLSL/BuiltIns/clamp-errors.hlsl | 2 +- clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl | 2 +- clang/test/SemaHLSL/BuiltIns/lerp-errors.hlsl | 2 +- clang/test/SemaHLSL/BuiltIns/mad-errors.hlsl | 2 +- .../test/SemaHLSL/BuiltIns/vector-errors.hlsl | 4 +- .../BuiltinVector/ScalarSwizzleErrors.hlsl | 4 +- .../Types/BuiltinVector/ScalarSwizzles.hlsl | 56 ++++++------ .../SemaHLSL/VectorOverloadResolution.hlsl | 30 +++---- .../standard_conversion_sequences.hlsl | 90 +++++++++---------- 16 files changed, 149 insertions(+), 126 deletions(-) diff --git a/clang/include/clang/AST/PrettyPrinter.h b/clang/include/clang/AST/PrettyPrinter.h index da276e26049b00..332ac3c6a004a9 100644 --- a/clang/include/clang/AST/PrettyPrinter.h +++ b/clang/include/clang/AST/PrettyPrinter.h @@ -77,7 +77,7 @@ struct PrintingPolicy { PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true), UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false), CleanUglifiedParameters(false), EntireContentsOfLargeArray(true), - UseEnumerators(true) {} + UseEnumerators(true), UseHLSLTypes(LO.HLSL) {} /// Adjust this printing policy for cases where it's known that we're /// printing C++ code (for instance, if AST dumping reaches a C++-only @@ -342,6 +342,11 @@ struct PrintingPolicy { LLVM_PREFERRED_TYPE(bool) unsigned UseEnumerators : 1; + /// Whether or not we're printing known HLSL code and should print HLSL + /// sugared types when possible. + LLVM_PREFERRED_TYPE(bool) + unsigned UseHLSLTypes : 1; + /// Callbacks to use to allow the behavior of printing to be customized. const PrintingCallbacks *Callbacks = nullptr; }; diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index 58d01705d607b2..4add4d3af69a30 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -644,16 +644,25 @@ void TypePrinter::printDependentAddressSpaceAfter( void TypePrinter::printDependentSizedExtVectorBefore( const DependentSizedExtVectorType *T, raw_ostream &OS) { + if (Policy.UseHLSLTypes) + OS << "vector<"; printBefore(T->getElementType(), OS); } void TypePrinter::printDependentSizedExtVectorAfter( const DependentSizedExtVectorType *T, raw_ostream &OS) { - OS << " __attribute__((ext_vector_type("; - if (T->getSizeExpr()) - T->getSizeExpr()->printPretty(OS, nullptr, Policy); - OS << ")))"; + if (Policy.UseHLSLTypes) { + OS << ", "; + if (T->getSizeExpr()) + T->getSizeExpr()->printPretty(OS, nullptr, Policy); + OS << ">"; + } else { + OS << " __attribute__((ext_vector_type("; + if (T->getSizeExpr()) + T->getSizeExpr()->printPretty(OS, nullptr, Policy); + OS << ")))"; + } printAfter(T->getElementType(), OS); } @@ -815,14 +824,23 @@ void TypePrinter::printDependentVectorAfter( void TypePrinter::printExtVectorBefore(const ExtVectorType *T, raw_ostream &OS) { + if (Policy.UseHLSLTypes) + OS << "vector<"; printBefore(T->getElementType(), OS); } void TypePrinter::printExtVectorAfter(const ExtVectorType *T, raw_ostream &OS) { printAfter(T->getElementType(), OS); - OS << " __attribute__((ext_vector_type("; - OS << T->getNumElements(); - OS << ")))"; + + if (Policy.UseHLSLTypes) { + OS << ", "; + OS << T->getNumElements(); + OS << ">"; + } else { + OS << " __attribute__((ext_vector_type("; + OS << T->getNumElements(); + OS << ")))"; + } } void TypePrinter::printConstantMatrixBefore(const ConstantMatrixType *T, diff --git a/clang/test/AST/HLSL/pch.hlsl b/clang/test/AST/HLSL/pch.hlsl index 839a13093bd150..483af0f5b4c790 100644 --- a/clang/test/AST/HLSL/pch.hlsl +++ b/clang/test/AST/HLSL/pch.hlsl @@ -10,7 +10,7 @@ hlsl::RWBuffer Buffer; float2 bar(float2 a, float2 b) { -// CHECK:CallExpr 0x{{[0-9a-f]+}} 'float2':'float __attribute__((ext_vector_type(2)))' +// CHECK:CallExpr 0x{{[0-9a-f]+}} 'float2':'vector' // CHECK-NEXT:ImplicitCastExpr 0x{{[0-9a-f]+}} 'float2 (*)(float2, float2)' // CHECK-NEXT:`-DeclRefExpr 0x{{[0-9a-f]+}} 'float2 (float2, float2)' lvalue Function 0x[[FOO]] 'foo' 'float2 (float2, float2)' return foo(a, b); diff --git a/clang/test/AST/HLSL/pch_with_buf.hlsl b/clang/test/AST/HLSL/pch_with_buf.hlsl index 63b7ed508a5fba..7fb5e2a3812ead 100644 --- a/clang/test/AST/HLSL/pch_with_buf.hlsl +++ b/clang/test/AST/HLSL/pch_with_buf.hlsl @@ -11,7 +11,7 @@ hlsl::RWBuffer Buf2; float2 bar(float2 a, float2 b) { -// CHECK:CallExpr 0x{{[0-9a-f]+}} 'float2':'float __attribute__((ext_vector_type(2)))' +// CHECK:CallExpr 0x{{[0-9a-f]+}} 'float2':'vector' // CHECK-NEXT:ImplicitCastExpr 0x{{[0-9a-f]+}} 'float2 (*)(float2, float2)' // CHECK-NEXT:`-DeclRefExpr 0x{{[0-9a-f]+}} 'float2 (float2, float2)' lvalue Function 0x[[FOO]] 'foo' 'float2 (float2, float2)' return foo(a, b); diff --git a/clang/test/AST/HLSL/vector-alias.hlsl b/clang/test/AST/HLSL/vector-alias.hlsl index effa1aa53db49a..3d112ee1b22303 100644 --- a/clang/test/AST/HLSL/vector-alias.hlsl +++ b/clang/test/AST/HLSL/vector-alias.hlsl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s // CHECK: NamespaceDecl 0x{{[0-9a-fA-F]+}} <> implicit hlsl // CHECK-NEXT: TypeAliasTemplateDecl 0x{{[0-9a-fA-F]+}} <> implicit vector @@ -8,8 +8,8 @@ // CHECK-NEXT: NonTypeTemplateParmDecl 0x{{[0-9a-fA-F]+}} <> 'int' depth 0 index 1 element_count // CHECK-NEXT: TemplateArgument expr // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-fA-F]+}} <> 'int' 4 -// CHECK-NEXT: TypeAliasDecl 0x{{[0-9a-fA-F]+}} <> implicit vector 'element __attribute__((ext_vector_type(element_count)))' -// CHECK-NEXT: DependentSizedExtVectorType 0x{{[0-9a-fA-F]+}} 'element __attribute__((ext_vector_type(element_count)))' dependent +// CHECK-NEXT: TypeAliasDecl 0x{{[0-9a-fA-F]+}} <> implicit vector 'vector' +// CHECK-NEXT: DependentSizedExtVectorType 0x{{[0-9a-fA-F]+}} 'vector' dependent // CHECK-NEXT: TemplateTypeParmType 0x{{[0-9a-fA-F]+}} 'element' dependent depth 0 index 0 // CHECK-NEXT: TemplateTypeParm 0x{{[0-9a-fA-F]+}} 'element' // CHECK-NEXT: DeclRefExpr 0x{{[0-9a-fA-F]+}} <> 'int' lvalue @@ -24,30 +24,30 @@ int entry() { hlsl::vector Vec2 = {1.0, 2.0}; // CHECK: DeclStmt 0x{{[0-9a-fA-F]+}} - // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}} col:26 Vec2 'hlsl::vector':'float __attribute__((ext_vector_type(2)))' cinit + // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}} col:26 Vec2 'hlsl::vector':'vector' cinit // Verify that you don't need to specify the namespace. vector Vec2a = {1, 2}; // CHECK: DeclStmt 0x{{[0-9a-fA-F]+}} - // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}} col:18 Vec2a 'vector':'int __attribute__((ext_vector_type(2)))' cinit + // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}} col:18 Vec2a 'vector' cinit // Build a bigger vector. vector Vec4 = {1.0, 2.0, 3.0, 4.0}; // CHECK: DeclStmt 0x{{[0-9a-fA-F]+}} - // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}} col:21 used Vec4 'vector':'double __attribute__((ext_vector_type(4)))' cinit + // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}} col:21 used Vec4 'vector' cinit // Verify that swizzles still work. vector Vec3 = Vec4.xyz; // CHECK: DeclStmt 0x{{[0-9a-fA-F]+}} - // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}} col:21 Vec3 'vector':'double __attribute__((ext_vector_type(3)))' cinit + // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}} col:21 Vec3 'vector' cinit // Verify that the implicit arguments generate the correct type. vector<> ImpVec4 = {1.0, 2.0, 3.0, 4.0}; // CHECK: DeclStmt 0x{{[0-9a-fA-F]+}} - // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}} col:12 ImpVec4 'vector<>':'float __attribute__((ext_vector_type(4)))' cinit + // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}} col:12 ImpVec4 'vector<>':'vector' cinit return 1; } diff --git a/clang/test/AST/HLSL/vector-constructors.hlsl b/clang/test/AST/HLSL/vector-constructors.hlsl index 5e0900bb623693..905f11d9223248 100644 --- a/clang/test/AST/HLSL/vector-constructors.hlsl +++ b/clang/test/AST/HLSL/vector-constructors.hlsl @@ -11,9 +11,9 @@ void entry() { // For the float2 vector, we just expect a conversion from constructor // parameters to an initialization list -// CHECK-LABEL: VarDecl 0x{{[0-9a-fA-F]+}} {{.*}} used Vec2 'float2':'float __attribute__((ext_vector_type(2)))' cinit -// CHECK-NEXT: CXXFunctionalCastExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' functional cast to float2 -// CHECK-NEXT: InitListExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' +// CHECK-LABEL: VarDecl 0x{{[0-9a-fA-F]+}} {{.*}} used Vec2 'float2':'vector' cinit +// CHECK-NEXT: CXXFunctionalCastExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float2':'vector' functional cast to float2 +// CHECK-NEXT: InitListExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float2':'vector' // CHECK-NEXT: FloatingLiteral 0x{{[0-9a-fA-F]+}} {{.*}} 'float' 1.000000e+00 // CHECK-NEXT: FloatingLiteral 0x{{[0-9a-fA-F]+}} {{.*}} 'float' 2.000000e+00 @@ -21,22 +21,22 @@ void entry() { // For the float 3 things get fun... // Here we expect accesses to the vec2 to provide the first and second // components using ArraySubscriptExpr -// CHECK-LABEL: VarDecl 0x{{[0-9a-fA-F]+}} {{.*}} col:10 Vec3 'float3':'float __attribute__((ext_vector_type(3)))' cinit -// CHECK-NEXT: CXXFunctionalCastExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float3':'float __attribute__((ext_vector_type(3)))' functional cast to float3 -// CHECK-NEXT: InitListExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float3':'float __attribute__((ext_vector_type(3)))' +// CHECK-LABEL: VarDecl 0x{{[0-9a-fA-F]+}} {{.*}} col:10 Vec3 'float3':'vector' cinit +// CHECK-NEXT: CXXFunctionalCastExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float3':'vector' functional cast to float3 +// CHECK-NEXT: InitListExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float3':'vector' // CHECK-NEXT: ImplicitCastExpr 0x{{[0-9a-fA-F]+}} > 'float' // CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9a-fA-F]+}} > 'float' lvalue -// CHECK-NEXT: DeclRefExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' lvalue Var 0x{{[0-9a-fA-F]+}} 'Vec2' 'float2':'float __attribute__((ext_vector_type(2)))' +// CHECK-NEXT: DeclRefExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float2':'vector' lvalue Var 0x{{[0-9a-fA-F]+}} 'Vec2' 'float2':'vector' // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-fA-F]+}} <> 'int' 0 // CHECK-NEXT: ImplicitCastExpr 0x{{[0-9a-fA-F]+}} > 'float' // CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9a-fA-F]+}} > 'float' lvalue -// CHECK-NEXT: DeclRefExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' lvalue Var 0x{{[0-9a-fA-F]+}} 'Vec2' 'float2':'float __attribute__((ext_vector_type(2)))' +// CHECK-NEXT: DeclRefExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float2':'vector' lvalue Var 0x{{[0-9a-fA-F]+}} 'Vec2' 'float2':'vector' // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-fA-F]+}} <> 'int' 1 // CHECK-NEXT: FloatingLiteral 0x{{[0-9a-fA-F]+}} {{.*}} 'float' 3.000000e+00 -// CHECK: VarDecl 0x{{[0-9a-fA-F]+}} {{.*}} col:10 Vec3b 'float3':'float __attribute__((ext_vector_type(3)))' cinit -// CHECK-NEXT: CXXFunctionalCastExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float3':'float __attribute__((ext_vector_type(3)))' functional cast to float3 -// CHECK-NEXT: InitListExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float3':'float __attribute__((ext_vector_type(3)))' +// CHECK: VarDecl 0x{{[0-9a-fA-F]+}} {{.*}} col:10 Vec3b 'float3':'vector' cinit +// CHECK-NEXT: CXXFunctionalCastExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float3':'vector' functional cast to float3 +// CHECK-NEXT: InitListExpr 0x{{[0-9a-fA-F]+}} {{.*}} 'float3':'vector' // CHECK-NEXT: FloatingLiteral 0x{{[0-9a-fA-F]+}} {{.*}} 'float' 1.000000e+00 // CHECK-NEXT: FloatingLiteral 0x{{[0-9a-fA-F]+}} {{.*}} 'float' 2.000000e+00 diff --git a/clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl b/clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl index b1a15c43191829..fecf3b76ff7bb6 100644 --- a/clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl +++ b/clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl @@ -15,6 +15,6 @@ RWBuffer<> BufferErr2; [numthreads(1,1,1)] void main() { - (void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::RWBuffer'}} + (void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::RWBuffer >'}} // expected-note@* {{implicitly declared private here}} } diff --git a/clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl index 8e0709eb030290..036f04cdac0b51 100644 --- a/clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl +++ b/clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl @@ -22,7 +22,7 @@ float2 test_clamp_no_second_arg(float2 p0) { float2 test_clamp_vector_size_mismatch(float3 p0, float2 p1) { return clamp(p0, p0, p1); - // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector') to 'float __attribute__((ext_vector_type(2)))' (vector of 2 'float' values)}} + // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector') to 'vector' (vector of 2 'float' values)}} } float2 test_clamp_builtin_vector_size_mismatch(float3 p0, float2 p1) { diff --git a/clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl index 58722aaeb9246e..cc42f0cb0a572d 100644 --- a/clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl +++ b/clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl @@ -17,7 +17,7 @@ float test_dot_no_second_arg(float2 p0) { float test_dot_vector_size_mismatch(float3 p0, float2 p1) { return dot(p0, p1); - // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector') to 'float __attribute__((ext_vector_type(2)))' (vector of 2 'float' values)}} + // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector') to 'vector' (vector of 2 'float' values)}} } float test_dot_builtin_vector_size_mismatch(float3 p0, float2 p1) { diff --git a/clang/test/SemaHLSL/BuiltIns/lerp-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/lerp-errors.hlsl index 868ba8a1a4713d..56c8b32cc14e0e 100644 --- a/clang/test/SemaHLSL/BuiltIns/lerp-errors.hlsl +++ b/clang/test/SemaHLSL/BuiltIns/lerp-errors.hlsl @@ -22,7 +22,7 @@ float2 test_lerp_no_second_arg(float2 p0) { float2 test_lerp_vector_size_mismatch(float3 p0, float2 p1) { return lerp(p0, p0, p1); - // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector') to 'float __attribute__((ext_vector_type(2)))' (vector of 2 'float' values)}} + // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector') to 'vector' (vector of 2 'float' values)}} } float2 test_lerp_builtin_vector_size_mismatch(float3 p0, float2 p1) { diff --git a/clang/test/SemaHLSL/BuiltIns/mad-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/mad-errors.hlsl index 5dfbc23f8defa7..ee4605528f4109 100644 --- a/clang/test/SemaHLSL/BuiltIns/mad-errors.hlsl +++ b/clang/test/SemaHLSL/BuiltIns/mad-errors.hlsl @@ -22,7 +22,7 @@ float2 test_mad_no_second_arg(float2 p0) { float2 test_mad_vector_size_mismatch(float3 p0, float2 p1) { return mad(p0, p0, p1); - // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector') to 'float __attribute__((ext_vector_type(2)))' (vector of 2 'float' values)}} + // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector') to 'vector' (vector of 2 'float' values)}} } float2 test_mad_builtin_vector_size_mismatch(float3 p0, float2 p1) { diff --git a/clang/test/SemaHLSL/BuiltIns/vector-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/vector-errors.hlsl index 6aedb9304ed933..7af10a05f76f37 100644 --- a/clang/test/SemaHLSL/BuiltIns/vector-errors.hlsl +++ b/clang/test/SemaHLSL/BuiltIns/vector-errors.hlsl @@ -2,7 +2,7 @@ // Some bad declarations hlsl::vector ShouldWorkSomeday; // expected-error{{use of alias template 'hlsl::vector' requires template arguments}} -// expected-note@*:* {{template declaration from hidden source: template using vector = element __attribute__((ext_vector_type(element_count)))}} +// expected-note@*:* {{template declaration from hidden source: template using vector = vector}} hlsl::vector<1> BadVec; // expected-error{{template argument for template type parameter must be a type}} // expected-note@*:* {{template parameter from hidden source: class element = float}} @@ -11,7 +11,7 @@ hlsl::vector AnotherBadVec; // expected-error{{template argument for // expected-note@*:* {{template parameter from hidden source: int element_count = 4}} hlsl::vector YABV; // expected-error{{too many template arguments for alias template 'vector'}} -// expected-note@*:* {{template declaration from hidden source: template using vector = element __attribute__((ext_vector_type(element_count)))}} +// expected-note@*:* {{template declaration from hidden source: template using vector = vector}} // This code is rejected by clang because clang puts the HLSL built-in types // into the HLSL namespace. diff --git a/clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzleErrors.hlsl b/clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzleErrors.hlsl index 170be6a13c3660..5088991f2e28ac 100644 --- a/clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzleErrors.hlsl +++ b/clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzleErrors.hlsl @@ -1,11 +1,11 @@ // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -x hlsl -finclude-default-header -verify %s int2 ToTwoInts(int V) { - return V.xy; // expected-error{{vector component access exceeds type 'int __attribute__((ext_vector_type(1)))' (vector of 1 'int' value)}} + return V.xy; // expected-error{{vector component access exceeds type 'vector' (vector of 1 'int' value)}} } float2 ToTwoFloats(float V) { - return V.rg; // expected-error{{vector component access exceeds type 'float __attribute__((ext_vector_type(1)))' (vector of 1 'float' value)}} + return V.rg; // expected-error{{vector component access exceeds type 'vector' (vector of 1 'float' value)}} } int4 SomeNonsense(int V) { diff --git a/clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzles.hlsl b/clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzles.hlsl index 4fa04f3d598898..683c05b20c34ed 100644 --- a/clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzles.hlsl +++ b/clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzles.hlsl @@ -3,8 +3,8 @@ // CHECK-LABEL: ToTwoInts -// CHECK: ExtVectorElementExpr {{.*}} 'int __attribute__((ext_vector_type(2)))' xx -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int __attribute__((ext_vector_type(1)))' lvalue +// CHECK: ExtVectorElementExpr {{.*}} 'vector' xx +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' lvalue // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'V' 'int' int2 ToTwoInts(int V){ @@ -12,8 +12,8 @@ int2 ToTwoInts(int V){ } // CHECK-LABEL: ToFourFloats -// CHECK: ExtVectorElementExpr {{.*}} 'float __attribute__((ext_vector_type(4)))' rrrr -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float __attribute__((ext_vector_type(1)))' lvalue +// CHECK: ExtVectorElementExpr {{.*}} 'vector' rrrr +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' lvalue // CHECK-NEXT: DeclRefExpr {{.*}} 'float' lvalue ParmVar {{.*}} 'V' 'float' @@ -22,8 +22,8 @@ float4 ToFourFloats(float V){ } // CHECK-LABEL: FillOne -// CHECK: ExtVectorElementExpr {{.*}} 'int __attribute__((ext_vector_type(2)))' xx -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int __attribute__((ext_vector_type(1)))' +// CHECK: ExtVectorElementExpr {{.*}} 'vector' xx +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 int2 FillOne(){ @@ -31,8 +31,8 @@ int2 FillOne(){ } // CHECK-LABEL: FillOneUnsigned -// CHECK: ExtVectorElementExpr {{.*}} 'unsigned int __attribute__((ext_vector_type(3)))' xxx -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int __attribute__((ext_vector_type(1)))' +// CHECK: ExtVectorElementExpr {{.*}} 'vector' xxx +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: IntegerLiteral {{.*}} 'unsigned int' 1 uint3 FillOneUnsigned(){ @@ -40,8 +40,8 @@ uint3 FillOneUnsigned(){ } // CHECK-LABEL: FillOneUnsignedLong -// CHECK: ExtVectorElementExpr {{.*}} 'unsigned long __attribute__((ext_vector_type(4)))' xxxx -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned long __attribute__((ext_vector_type(1)))' +// CHECK: ExtVectorElementExpr {{.*}} 'vector' xxxx +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: IntegerLiteral {{.*}} 'unsigned long' 1 vector FillOneUnsignedLong(){ @@ -49,8 +49,8 @@ vector FillOneUnsignedLong(){ } // CHECK-LABEL: FillTwoPointFive -// CHECK: ExtVectorElementExpr {{.*}} 'double __attribute__((ext_vector_type(2)))' rr -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'double __attribute__((ext_vector_type(1)))' +// CHECK: ExtVectorElementExpr {{.*}} 'vector' rr +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: FloatingLiteral {{.*}} 'double' 2.500000e+00 double2 FillTwoPointFive(){ @@ -58,8 +58,8 @@ double2 FillTwoPointFive(){ } // CHECK-LABEL: FillOneHalf -// CHECK: ExtVectorElementExpr {{.*}} 'double __attribute__((ext_vector_type(3)))' rrr -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'double __attribute__((ext_vector_type(1)))' +// CHECK: ExtVectorElementExpr {{.*}} 'vector' rrr +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: FloatingLiteral {{.*}} 'double' 5.000000e-01 double3 FillOneHalf(){ @@ -67,8 +67,8 @@ double3 FillOneHalf(){ } // CHECK-LABEL: FillTwoPointFiveFloat -// CHECK: ExtVectorElementExpr {{.*}} 'float __attribute__((ext_vector_type(4)))' rrrr -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float __attribute__((ext_vector_type(1)))' +// CHECK: ExtVectorElementExpr {{.*}} 'vector' rrrr +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: FloatingLiteral {{.*}} 'float' 2.500000e+00 float4 FillTwoPointFiveFloat(){ @@ -80,9 +80,9 @@ float4 FillTwoPointFiveFloat(){ // initialze the returned vector. // CHECK-LABEL: FillOneHalfFloat -// CHECK: ImplicitCastExpr {{.*}} 'vector':'float __attribute__((ext_vector_type(1)))' +// CHECK: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: ExtVectorElementExpr {{.*}} 'float' r -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float __attribute__((ext_vector_type(1)))' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: FloatingLiteral {{.*}} 'float' 5.000000e-01 vector FillOneHalfFloat(){ @@ -90,9 +90,9 @@ vector FillOneHalfFloat(){ } // CHECK-LABEL: HowManyFloats -// CHECK: ExtVectorElementExpr {{.*}} 'float __attribute__((ext_vector_type(2)))' rr -// CHECK-NEXT: ExtVectorElementExpr {{.*}} 'float __attribute__((ext_vector_type(2)))' rr -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float __attribute__((ext_vector_type(1)))' lvalue +// CHECK: ExtVectorElementExpr {{.*}} 'vector' rr +// CHECK-NEXT: ExtVectorElementExpr {{.*}} 'vector' rr +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' lvalue // CHECK-NEXT: DeclRefExpr {{.*}} 'float' lvalue ParmVar {{.*}} 'V' 'float' float2 HowManyFloats(float V) { @@ -100,8 +100,8 @@ float2 HowManyFloats(float V) { } // CHECK-LABEL: HooBoy -// CHECK: ExtVectorElementExpr {{.*}} 'long __attribute__((ext_vector_type(4)))' xxxx -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'long __attribute__((ext_vector_type(1)))' +// CHECK: ExtVectorElementExpr {{.*}} 'vector' xxxx +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: IntegerLiteral {{.*}} 'long' 4 int64_t4 HooBoy() { @@ -113,9 +113,9 @@ int64_t4 HooBoy() { // list with float truncation casts. // CHECK-LABEL: AllRighty -// CHECK: ImplicitCastExpr {{.*}} 'float3':'float __attribute__((ext_vector_type(3)))' -// CHECK-NEXT: ExtVectorElementExpr {{.*}} 'double __attribute__((ext_vector_type(3)))' rrr -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'double __attribute__((ext_vector_type(1)))' +// CHECK: ImplicitCastExpr {{.*}} 'float3':'vector' +// CHECK-NEXT: ExtVectorElementExpr {{.*}} 'vector' rrr +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: FloatingLiteral {{.*}} 'double' 1.000000e+00 float3 AllRighty() { @@ -123,8 +123,8 @@ float3 AllRighty() { } // CHECK-LABEL: AllRighty2 -// CHECK: ExtVectorElementExpr {{.*}} 'float __attribute__((ext_vector_type(3)))' rrr -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float __attribute__((ext_vector_type(1)))' +// CHECK: ExtVectorElementExpr {{.*}} 'vector' rrr +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: FloatingLiteral {{.*}} 'float' 1.000000e+00 float3 AllRighty2() { diff --git a/clang/test/SemaHLSL/VectorOverloadResolution.hlsl b/clang/test/SemaHLSL/VectorOverloadResolution.hlsl index 2ea7d14e80eebf..485094fd09b3c2 100644 --- a/clang/test/SemaHLSL/VectorOverloadResolution.hlsl +++ b/clang/test/SemaHLSL/VectorOverloadResolution.hlsl @@ -7,9 +7,9 @@ void Fn(half2 H); // CHECK: CallExpr {{.*}}'void' // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(double2)' // CHECK-NEXT: DeclRefExpr {{.*}}'void (double2)' lvalue Function {{.*}} 'Fn' 'void (double2)' -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'double2':'double __attribute__((ext_vector_type(2)))' -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' -// CHECK-NEXT: DeclRefExpr {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' lvalue ParmVar {{.*}} 'F' 'float2':'float __attribute__((ext_vector_type(2)))' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'double2':'vector' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float2':'vector' +// CHECK-NEXT: DeclRefExpr {{.*}} 'float2':'vector' lvalue ParmVar {{.*}} 'F' 'float2':'vector' void Call(float2 F) { Fn(F); @@ -22,9 +22,9 @@ void Fn2(int16_t2 S); // CHECK: CallExpr {{.*}} 'void' // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(int64_t2)' // CHECK-NEXT: DeclRefExpr {{.*}} 'void (int64_t2)' lvalue Function {{.*}} 'Fn2' 'void (int64_t2)' -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int64_t2':'long __attribute__((ext_vector_type(2)))' -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int2':'int __attribute__((ext_vector_type(2)))' -// CHECK-NEXT: DeclRefExpr {{.*}} 'int2':'int __attribute__((ext_vector_type(2)))' lvalue ParmVar {{.*}} 'I' 'int2':'int __attribute__((ext_vector_type(2)))' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int64_t2':'vector' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int2':'vector' +// CHECK-NEXT: DeclRefExpr {{.*}} 'int2':'vector' lvalue ParmVar {{.*}} 'I' 'int2':'vector' void Call2(int2 I) { Fn2(I); @@ -36,9 +36,9 @@ void Fn3( int64_t2 p0); // CHECK: CallExpr {{.*}} 'void' // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(int64_t2)' // CHECK-NEXT: DeclRefExpr {{.*}} 'void (int64_t2)' lvalue Function {{.*}} 'Fn3' 'void (int64_t2)' -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int64_t2':'long __attribute__((ext_vector_type(2)))' -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'half2':'half __attribute__((ext_vector_type(2)))' -// CHECK-NEXT: DeclRefExpr {{.*}} 'half2':'half __attribute__((ext_vector_type(2)))' lvalue ParmVar {{.*}} 'p0' 'half2':'half __attribute__((ext_vector_type(2)))' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int64_t2':'vector' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'half2':'vector' +// CHECK-NEXT: DeclRefExpr {{.*}} 'half2':'vector' lvalue ParmVar {{.*}} 'p0' 'half2':'vector' // CHECKIR-LABEL: Call3 // CHECKIR: {{.*}} = fptosi <2 x half> {{.*}} to <2 x i64> void Call3(half2 p0) { @@ -49,9 +49,9 @@ void Call3(half2 p0) { // CHECK: CallExpr {{.*}} 'void' // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(int64_t2)' // CHECK-NEXT: DeclRefExpr {{.*}} 'void (int64_t2)' lvalue Function {{.*}} 'Fn3' 'void (int64_t2)' -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int64_t2':'long __attribute__((ext_vector_type(2)))' -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' -// CHECK-NEXT: DeclRefExpr {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' lvalue ParmVar {{.*}} 'p0' 'float2':'float __attribute__((ext_vector_type(2)))' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int64_t2':'vector' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float2':'vector' +// CHECK-NEXT: DeclRefExpr {{.*}} 'float2':'vector' lvalue ParmVar {{.*}} 'p0' 'float2':'vector' // CHECKIR-LABEL: Call4 // CHECKIR: {{.*}} = fptosi <2 x float> {{.*}} to <2 x i64> void Call4(float2 p0) { @@ -64,9 +64,9 @@ void Fn4( float2 p0); // CHECK: CallExpr {{.*}} 'void' // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(float2)' // CHECK-NEXT: DeclRefExpr {{.*}} 'void (float2)' lvalue Function {{.*}} 'Fn4' 'void (float2)' -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float2':'float __attribute__((ext_vector_type(2)))' -// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int64_t2':'long __attribute__((ext_vector_type(2)))' -// CHECK-NEXT: DeclRefExpr {{.*}} 'int64_t2':'long __attribute__((ext_vector_type(2)))' lvalue ParmVar {{.*}} 'p0' 'int64_t2':'long __attribute__((ext_vector_type(2)))' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float2':'vector' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int64_t2':'vector' +// CHECK-NEXT: DeclRefExpr {{.*}} 'int64_t2':'vector' lvalue ParmVar {{.*}} 'p0' 'int64_t2':'vector' // CHECKIR-LABEL: Call5 // CHECKIR: {{.*}} = sitofp <2 x i64> {{.*}} to <2 x float> void Call5(int64_t2 p0) { diff --git a/clang/test/SemaHLSL/standard_conversion_sequences.hlsl b/clang/test/SemaHLSL/standard_conversion_sequences.hlsl index 256981d2c1e2e0..c8d9f2c156e310 100644 --- a/clang/test/SemaHLSL/standard_conversion_sequences.hlsl +++ b/clang/test/SemaHLSL/standard_conversion_sequences.hlsl @@ -2,79 +2,79 @@ // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -Wno-conversion -DNO_ERR -ast-dump %s | FileCheck %s void test() { - - // CHECK: VarDecl {{.*}} used f3 'vector':'float __attribute__((ext_vector_type(3)))' cinit - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'float __attribute__((ext_vector_type(3)))' + + // CHECK: VarDecl {{.*}} used f3 'vector' cinit + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' // CHECK-NEXT: FloatingLiteral {{.*}} 'float' 1.000000e+00 vector f3 = 1.0; // No warning for splatting to a vector from a literal. - // CHECK: VarDecl {{.*}} used d4 'vector':'double __attribute__((ext_vector_type(4)))' cinit - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'double __attribute__((ext_vector_type(4)))' - // CHECK-NEXT: ExtVectorElementExpr {{.*}} 'float __attribute__((ext_vector_type(4)))' xyzx - // CHECK-NEXT: DeclRefExpr {{.*}} 'vector':'float __attribute__((ext_vector_type(3)))' lvalue Var {{.*}} 'f3' 'vector':'float __attribute__((ext_vector_type(3)))' + // CHECK: VarDecl {{.*}} used d4 'vector' cinit + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ExtVectorElementExpr {{.*}} 'vector' xyzx + // CHECK-NEXT: DeclRefExpr {{.*}} 'vector' lvalue Var {{.*}} 'f3' 'vector' vector d4 = f3.xyzx; // No warnings for promotion or explicit extension. - // CHECK: VarDecl {{.*}} used f2 'vector':'float __attribute__((ext_vector_type(2)))' cinit - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'float __attribute__((ext_vector_type(2)))' - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'float __attribute__((ext_vector_type(3)))' - // CHECK-NEXT: DeclRefExpr {{.*}} 'vector':'float __attribute__((ext_vector_type(3)))' lvalue Var {{.*}} 'f3' 'vector':'float __attribute__((ext_vector_type(3)))' - // expected-warning@#f2{{implicit conversion truncates vector: 'vector' (vector of 3 'float' values) to 'float __attribute__((ext_vector_type(2)))' (vector of 2 'float' values)}} + // CHECK: VarDecl {{.*}} used f2 'vector' cinit + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: DeclRefExpr {{.*}} 'vector' lvalue Var {{.*}} 'f3' 'vector' + // expected-warning@#f2{{implicit conversion truncates vector: 'vector' (vector of 3 'float' values) to 'vector' (vector of 2 'float' values)}} vector f2 = f3; // #f2 - // CHECK: VarDecl {{.*}} f2_2 'vector':'float __attribute__((ext_vector_type(2)))' cinit - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'float __attribute__((ext_vector_type(2)))' - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'double __attribute__((ext_vector_type(2)))' - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'double __attribute__((ext_vector_type(4)))' - // CHECK-NEXT: DeclRefExpr {{.*}} 'vector':'double __attribute__((ext_vector_type(4)))' lvalue Var {{.*}} 'd4' 'vector':'double __attribute__((ext_vector_type(4)))' + // CHECK: VarDecl {{.*}} f2_2 'vector' cinit + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: DeclRefExpr {{.*}} 'vector' lvalue Var {{.*}} 'd4' 'vector' // expected-warning@#f2_2{{implicit conversion truncates vector: 'vector' (vector of 4 'double' values) to 'vector' (vector of 2 'float' values)}} // expected-warning@#f2_2{{implicit conversion loses floating-point precision: 'vector' (vector of 4 'double' values) to 'vector' (vector of 2 'float' values)}} vector f2_2 = d4; // #f2_2 - // CHECK: VarDecl {{.*}} i2 'vector':'int __attribute__((ext_vector_type(2)))' cinit - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'int __attribute__((ext_vector_type(2)))' - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'float __attribute__((ext_vector_type(2)))' - // CHECK-NEXT: DeclRefExpr {{.*}} 'vector':'float __attribute__((ext_vector_type(2)))' lvalue Var {{.*}} 'f2' 'vector':'float __attribute__((ext_vector_type(2)))' + // CHECK: VarDecl {{.*}} i2 'vector' cinit + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: DeclRefExpr {{.*}} 'vector' lvalue Var {{.*}} 'f2' 'vector' // expected-warning@#i2{{mplicit conversion turns floating-point number into integer: 'vector' (vector of 2 'float' values) to 'vector' (vector of 2 'int' values)}} vector i2 = f2; // #i2 - - // CHECK: VarDecl {{.*}} i2_2 'vector':'int __attribute__((ext_vector_type(2)))' cinit - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'int __attribute__((ext_vector_type(2)))' - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'double __attribute__((ext_vector_type(2)))' - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'double __attribute__((ext_vector_type(4)))' - // CHECK-NEXT: DeclRefExpr {{.*}} 'vector':'double __attribute__((ext_vector_type(4)))' lvalue Var {{.*}} 'd4' 'vector':'double __attribute__((ext_vector_type(4)))' + + // CHECK: VarDecl {{.*}} i2_2 'vector' cinit + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: DeclRefExpr {{.*}} 'vector' lvalue Var {{.*}} 'd4' 'vector' // expected-warning@#i2_2{{implicit conversion truncates vector: 'vector' (vector of 4 'double' values) to 'vector' (vector of 2 'int' values)}} // expected-warning@#i2_2{{implicit conversion turns floating-point number into integer: 'vector' (vector of 4 'double' values) to 'vector' (vector of 2 'int' values)}} vector i2_2 = d4; // #i2_2 - // CHECK: VarDecl {{.*}} used i64_4 'vector':'long __attribute__((ext_vector_type(4)))' cinit - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'long __attribute__((ext_vector_type(4)))' - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'double __attribute__((ext_vector_type(4)))' - // CHECK-NEXT: DeclRefExpr {{.*}} 'vector':'double __attribute__((ext_vector_type(4)))' lvalue Var {{.*}} 'd4' 'vector':'double __attribute__((ext_vector_type(4)))' + // CHECK: VarDecl {{.*}} used i64_4 'vector' cinit + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: DeclRefExpr {{.*}} 'vector' lvalue Var {{.*}} 'd4' 'vector' // expected-warning@#i64_4{{implicit conversion turns floating-point number into integer: 'vector' (vector of 4 'double' values) to 'vector' (vector of 4 'long' values)}} vector i64_4 = d4; // #i64_4 - // CHECK: VarDecl {{.*}} used i2_3 'vector':'int __attribute__((ext_vector_type(2)))' cinit - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'int __attribute__((ext_vector_type(2)))' - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'long __attribute__((ext_vector_type(2)))' - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'long __attribute__((ext_vector_type(4)))' - // CHECK-NEXT: DeclRefExpr {{.*}} 'vector':'long __attribute__((ext_vector_type(4)))' lvalue Var {{.*}} 'i64_4' 'vector':'long __attribute__((ext_vector_type(4)))' + // CHECK: VarDecl {{.*}} used i2_3 'vector' cinit + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: DeclRefExpr {{.*}} 'vector' lvalue Var {{.*}} 'i64_4' 'vector' // expected-warning@#i2_3{{implicit conversion loses integer precision: 'vector' (vector of 4 'long' values) to 'vector' (vector of 2 'int' values)}} // expected-warning@#i2_3{{implicit conversion truncates vector: 'vector' (vector of 4 'long' values) to 'vector' (vector of 2 'int' values)}} vector i2_3 = i64_4; // #i2_3 - //CHECK: VarDecl {{.*}} b2 'vector':'bool __attribute__((ext_vector_type(2)))' cinit - //CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'bool __attribute__((ext_vector_type(2)))' - //CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'int __attribute__((ext_vector_type(2)))' - //CHECK-NEXT: DeclRefExpr {{.*}} 'vector':'int __attribute__((ext_vector_type(2)))' lvalue Var {{.*}} 'i2_3' 'vector':'int __attribute__((ext_vector_type(2)))' + //CHECK: VarDecl {{.*}} b2 'vector' cinit + //CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + //CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + //CHECK-NEXT: DeclRefExpr {{.*}} 'vector' lvalue Var {{.*}} 'i2_3' 'vector' vector b2 = i2_3; // No warning for integer to bool conversion. - // CHECK: VarDecl {{.*}} b2_2 'vector':'bool __attribute__((ext_vector_type(2)))' cinit - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'bool __attribute__((ext_vector_type(2)))' - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'double __attribute__((ext_vector_type(2)))' - // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector':'double __attribute__((ext_vector_type(4)))' - // CHECK-NEXT: DeclRefExpr {{.*}} 'vector':'double __attribute__((ext_vector_type(4)))' lvalue Var {{.*}} 'd4' 'vector':'double __attribute__((ext_vector_type(4)))' + // CHECK: VarDecl {{.*}} b2_2 'vector' cinit + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector' + // CHECK-NEXT: DeclRefExpr {{.*}} 'vector' lvalue Var {{.*}} 'd4' 'vector' // expected-warning@#b2_2{{implicit conversion truncates vector: 'vector' (vector of 4 'double' values) to 'vector' (vector of 2 'bool' values)}} // expected-warning@#b2_2{{implicit conversion turns floating-point number into integer: 'vector' (vector of 4 'double' values) to 'vector' (vector of 2 'bool' values)}} vector b2_2 = d4; // #b2_2