Skip to content

Commit ca0a146

Browse files
committed
address pr comments
1 parent 4360a27 commit ca0a146

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14147,7 +14147,7 @@ class Sema final {
1414714147
bool SemaBuiltinVectorToScalarMath(CallExpr *TheCall);
1414814148
bool SemaBuiltinElementwiseMath(CallExpr *TheCall);
1414914149
bool SemaBuiltinElementwiseTernaryMath(CallExpr *TheCall,
14150-
bool enforceFloatingPointCheck = true);
14150+
bool CheckForFloatArgs = true);
1415114151
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall);
1415214152
bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
1415314153

clang/lib/Sema/SemaChecking.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5303,7 +5303,7 @@ bool Sema::CheckHLSLBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
53035303
return true;
53045304
if (CheckVectorElementCallArgs(this, TheCall))
53055305
return true;
5306-
if (SemaBuiltinElementwiseTernaryMath(TheCall, false))
5306+
if (SemaBuiltinElementwiseTernaryMath(TheCall, /*CheckForFloatArgs*/ false))
53075307
return true;
53085308
}
53095309
}
@@ -19809,7 +19809,7 @@ bool Sema::SemaBuiltinVectorMath(CallExpr *TheCall, QualType &Res) {
1980919809
}
1981019810

1981119811
bool Sema::SemaBuiltinElementwiseTernaryMath(CallExpr *TheCall,
19812-
bool enforceFloatingPointCheck) {
19812+
bool CheckForFloatArgs) {
1981319813
if (checkArgCount(*this, TheCall, 3))
1981419814
return true;
1981519815

@@ -19821,13 +19821,20 @@ bool Sema::SemaBuiltinElementwiseTernaryMath(CallExpr *TheCall,
1982119821
Args[I] = Converted.get();
1982219822
}
1982319823

19824-
if (enforceFloatingPointCheck) {
19824+
if (CheckForFloatArgs) {
1982519825
int ArgOrdinal = 1;
1982619826
for (Expr *Arg : Args) {
1982719827
if (checkFPMathBuiltinElementType(*this, Arg->getBeginLoc(),
1982819828
Arg->getType(), ArgOrdinal++))
1982919829
return true;
1983019830
}
19831+
} else {
19832+
int ArgOrdinal = 1;
19833+
for (Expr *Arg : Args) {
19834+
if (checkMathBuiltinElementType(*this, Arg->getBeginLoc(), Arg->getType(),
19835+
ArgOrdinal++))
19836+
return true;
19837+
}
1983119838
}
1983219839

1983319840
for (int I = 1; I < 3; ++I) {

clang/test/CodeGenHLSL/builtins/mad.hlsl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,3 @@ float2 test_mad_float2_int_splat(float2 p0, float2 p1, int p2) {
189189
float3 test_mad_float3_int_splat(float3 p0, float3 p1, int p2) {
190190
return mad(p0, p1, p2);
191191
}
192-
193-
// CHECK: %dx.umad = call i1 @llvm.dx.umad.i1(i1 %tobool, i1 %tobool1, i1 %tobool2)
194-
// CHECK: ret i1 %dx.umad
195-
bool test_builtin_mad_bool_type_promotion(bool p0) {
196-
return __builtin_hlsl_mad(p0, p0, p0);
197-
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ float2 test_builtin_mad_int_vect_to_float_vec_promotion(int2 p0, float p1) {
7272

7373
float builtin_bool_to_float_type_promotion(float p0, bool p1) {
7474
return __builtin_hlsl_mad(p0, p0, p1);
75-
// expected-error@-1 {{arguments are of different types ('double' vs 'bool')}}
75+
// expected-error@-1 {{3rd argument must be a vector, integer or floating point type (was 'bool')}}
7676
}
7777

7878
float builtin_bool_to_float_type_promotion2(bool p0, float p1) {
7979
return __builtin_hlsl_mad(p1, p0, p1);
80-
// expected-error@-1 {{arguments are of different types ('double' vs 'bool')}}
80+
// expected-error@-1 {{2nd argument must be a vector, integer or floating point type (was 'bool')}}
8181
}
8282

8383
float builtin_mad_int_to_float_promotion(float p0, int p1) {

0 commit comments

Comments
 (0)