Skip to content

Commit 7dfe26d

Browse files
committed
change how sema is fixed, revert test changes
1 parent 905bc23 commit 7dfe26d

File tree

2 files changed

+14
-33
lines changed

2 files changed

+14
-33
lines changed

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,8 @@ static bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) {
20152015
}
20162016
if (VecTyA && VecTyB) {
20172017
bool retValue = false;
2018-
if (VecTyA->getElementType() != VecTyB->getElementType()) {
2018+
if (!S->Context.hasSameUnqualifiedType(VecTyA->getElementType(),
2019+
VecTyB->getElementType())) {
20192020
// Note: type promotion is intended to be handeled via the intrinsics
20202021
// and not the builtin itself.
20212022
S->Diag(TheCall->getBeginLoc(),
@@ -2466,32 +2467,12 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
24662467
case Builtin::BI__builtin_hlsl_dot: {
24672468
if (SemaRef.checkArgCount(TheCall, 2))
24682469
return true;
2469-
// check no bool or bool vectors
2470-
const Expr *Arg0 = TheCall->getArg(0);
2471-
QualType T0 = Arg0->getType();
2472-
const Expr *Arg1 = TheCall->getArg(1);
2473-
QualType T1 = Arg1->getType();
2474-
QualType BoolType = SemaRef.getASTContext().BoolTy;
2475-
if (const auto *VT0 = T0->getAs<VectorType>())
2476-
T0 = VT0->getElementType();
2477-
if (const auto *VT1 = T1->getAs<VectorType>())
2478-
T1 = VT1->getElementType();
2479-
if (SemaRef.Context.hasSameUnqualifiedType(T0, BoolType))
2480-
return SemaRef.Diag(Arg0->getBeginLoc(),
2481-
diag::err_builtin_invalid_arg_type)
2482-
<< 1 << /* scalar or vector of */ 5 << /* integer ty */ 1
2483-
<< /* fp type */ 1 << Arg0->getType();
2484-
if (SemaRef.Context.hasSameUnqualifiedType(T1, BoolType))
2485-
return SemaRef.Diag(Arg1->getBeginLoc(),
2486-
diag::err_builtin_invalid_arg_type)
2487-
<< 2 << /* scalar or vector of */ 5 << /* integer ty */ 1
2488-
<< /* fp type */ 1 << Arg1->getType();
2489-
if (CheckNoDoubleVectors(&SemaRef, TheCall))
2490-
return true;
2491-
if (CheckAllArgsHaveSameType(&SemaRef, TheCall))
2470+
if (CheckVectorElementCallArgs(&SemaRef, TheCall))
24922471
return true;
24932472
if (SemaRef.BuiltinVectorToScalarMath(TheCall))
24942473
return true;
2474+
if (CheckNoDoubleVectors(&SemaRef, TheCall))
2475+
return true;
24952476
break;
24962477
}
24972478
case Builtin::BI__builtin_hlsl_elementwise_firstbithigh:

clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,37 +76,37 @@ int64_t test_builtin_dot_vec_int16_to_int64_promotion(int64_t2 p0,
7676

7777
float test_builtin_dot_float2_splat(float p0, float2 p1) {
7878
return __builtin_hlsl_dot(p0, p1);
79-
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}}
79+
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}}
8080
}
8181

8282
float test_builtin_dot_float3_splat(float p0, float3 p1) {
8383
return __builtin_hlsl_dot(p0, p1);
84-
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}}
84+
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}}
8585
}
8686

8787
float test_builtin_dot_float4_splat(float p0, float4 p1) {
8888
return __builtin_hlsl_dot(p0, p1);
89-
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}}
89+
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}}
9090
}
9191

9292
float test_dot_float2_int_splat(float2 p0, int p1) {
9393
return __builtin_hlsl_dot(p0, p1);
94-
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}}
94+
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}}
9595
}
9696

9797
float test_dot_float3_int_splat(float3 p0, int p1) {
9898
return __builtin_hlsl_dot(p0, p1);
99-
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}}
99+
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}}
100100
}
101101

102102
float test_builtin_dot_int_vect_to_float_vec_promotion(int2 p0, float p1) {
103103
return __builtin_hlsl_dot(p0, p1);
104-
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}}
104+
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must be vectors}}
105105
}
106106

107107
int test_builtin_dot_bool_type_promotion(bool p0, float p1) {
108108
return __builtin_hlsl_dot(p0, p1);
109-
// expected-error@-1 {{1st argument must be a scalar or vector of integer or floating-point types (was 'bool')}}
109+
// expected-error@-1 {{1st argument must be a vector, integer or floating-point type (was 'bool')}}
110110
}
111111

112112
double test_dot_double(double2 p0, double2 p1) {
@@ -120,10 +120,10 @@ double test_dot_double_builtin(double2 p0, double2 p1) {
120120

121121
float builtin_bool_to_float_type_promotion ( float p0, bool p1 ) {
122122
return __builtin_hlsl_dot ( p0, p1 );
123-
// expected-error@-1 {{2nd argument must be a scalar or vector of integer or floating-point types (was 'bool')}}
123+
// expected-error@-1 {{are of different types ('float' vs 'bool')}}
124124
}
125125

126126
float builtin_dot_int_to_float_promotion ( float p0, int p1 ) {
127127
return __builtin_hlsl_dot (p0, p1 );
128-
// expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have the same type}}
128+
// expected-error@-1 {{are of different types ('float' vs 'int')}}
129129
}

0 commit comments

Comments
 (0)