Skip to content

Commit bad4640

Browse files
committed
Addressed some feedback from the old PR
1 parent aa2c7ed commit bad4640

File tree

4 files changed

+46
-47
lines changed

4 files changed

+46
-47
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

+1-2
Original file line numberDiff line numberDiff line change
@@ -9273,8 +9273,7 @@ def err_typecheck_expect_scalar_or_vector : Error<
92739273
def err_typecheck_expect_any_scalar_or_vector : Error<
92749274
"invalid operand of type %0 where a scalar or vector is required">;
92759275
def err_typecheck_expect_scalar_or_vector_not_type : Error<
9276-
"invalid operand of type %0 where %1 or "
9277-
"a vector of such type is not allowed">;
9276+
"invalid operand of type %0">;
92789277
def err_typecheck_expect_flt_or_vector : Error<
92799278
"invalid operand of type %0 where floating, complex or "
92809279
"a vector of such types is required">;

clang/lib/Headers/hlsl/hlsl_intrinsics.h

+36-36
Original file line numberDiff line numberDiff line change
@@ -2355,98 +2355,98 @@ __attribute__((convergent)) double4 WaveReadLaneAt(double4, int32_t);
23552355

23562356
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
23572357
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2358-
__attribute((convergent)) half WaveActiveSum(half);
2358+
__attribute__((convergent)) half WaveActiveSum(half);
23592359
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
23602360
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2361-
__attribute((convergent)) half2 WaveActiveSum(half2);
2361+
__attribute__((convergent)) half2 WaveActiveSum(half2);
23622362
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
23632363
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2364-
__attribute((convergent)) half3 WaveActiveSum(half3);
2364+
__attribute__((convergent)) half3 WaveActiveSum(half3);
23652365
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
23662366
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2367-
__attribute((convergent)) half4 WaveActiveSum(half4);
2367+
__attribute__((convergent)) half4 WaveActiveSum(half4);
23682368

23692369
#ifdef __HLSL_ENABLE_16_BIT
23702370
_HLSL_AVAILABILITY(shadermodel, 6.0)
23712371
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2372-
__attribute((convergent)) int16_t WaveActiveSum(int16_t);
2372+
__attribute__((convergent)) int16_t WaveActiveSum(int16_t);
23732373
_HLSL_AVAILABILITY(shadermodel, 6.0)
23742374
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2375-
__attribute((convergent)) int16_t2 WaveActiveSum(int16_t2);
2375+
__attribute__((convergent)) int16_t2 WaveActiveSum(int16_t2);
23762376
_HLSL_AVAILABILITY(shadermodel, 6.0)
23772377
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2378-
__attribute((convergent)) int16_t3 WaveActiveSum(int16_t3);
2378+
__attribute__((convergent)) int16_t3 WaveActiveSum(int16_t3);
23792379
_HLSL_AVAILABILITY(shadermodel, 6.0)
23802380
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2381-
__attribute((convergent)) int16_t4 WaveActiveSum(int16_t4);
2381+
__attribute__((convergent)) int16_t4 WaveActiveSum(int16_t4);
23822382

23832383
_HLSL_AVAILABILITY(shadermodel, 6.0)
23842384
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2385-
__attribute((convergent)) uint16_t WaveActiveSum(uint16_t);
2385+
__attribute__((convergent)) uint16_t WaveActiveSum(uint16_t);
23862386
_HLSL_AVAILABILITY(shadermodel, 6.0)
23872387
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2388-
__attribute((convergent)) uint16_t2 WaveActiveSum(uint16_t2);
2388+
__attribute__((convergent)) uint16_t2 WaveActiveSum(uint16_t2);
23892389
_HLSL_AVAILABILITY(shadermodel, 6.0)
23902390
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2391-
__attribute((convergent)) uint16_t3 WaveActiveSum(uint16_t3);
2391+
__attribute__((convergent)) uint16_t3 WaveActiveSum(uint16_t3);
23922392
_HLSL_AVAILABILITY(shadermodel, 6.0)
23932393
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2394-
__attribute((convergent)) uint16_t4 WaveActiveSum(uint16_t4);
2394+
__attribute__((convergent)) uint16_t4 WaveActiveSum(uint16_t4);
23952395
#endif
23962396

23972397
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2398-
__attribute((convergent)) int WaveActiveSum(int);
2398+
__attribute__((convergent)) int WaveActiveSum(int);
23992399
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2400-
__attribute((convergent)) int2 WaveActiveSum(int2);
2400+
__attribute__((convergent)) int2 WaveActiveSum(int2);
24012401
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2402-
__attribute((convergent)) int3 WaveActiveSum(int3);
2402+
__attribute__((convergent)) int3 WaveActiveSum(int3);
24032403
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2404-
__attribute((convergent)) int4 WaveActiveSum(int4);
2404+
__attribute__((convergent)) int4 WaveActiveSum(int4);
24052405

24062406
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2407-
__attribute((convergent)) uint WaveActiveSum(uint);
2407+
__attribute__((convergent)) uint WaveActiveSum(uint);
24082408
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2409-
__attribute((convergent)) uint2 WaveActiveSum(uint2);
2409+
__attribute__((convergent)) uint2 WaveActiveSum(uint2);
24102410
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2411-
__attribute((convergent)) uint3 WaveActiveSum(uint3);
2411+
__attribute__((convergent)) uint3 WaveActiveSum(uint3);
24122412
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2413-
__attribute((convergent)) uint4 WaveActiveSum(uint4);
2413+
__attribute__((convergent)) uint4 WaveActiveSum(uint4);
24142414

24152415
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2416-
__attribute((convergent)) int64_t WaveActiveSum(int64_t);
2416+
__attribute__((convergent)) int64_t WaveActiveSum(int64_t);
24172417
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2418-
__attribute((convergent)) int64_t2 WaveActiveSum(int64_t2);
2418+
__attribute__((convergent)) int64_t2 WaveActiveSum(int64_t2);
24192419
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2420-
__attribute((convergent)) int64_t3 WaveActiveSum(int64_t3);
2420+
__attribute__((convergent)) int64_t3 WaveActiveSum(int64_t3);
24212421
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2422-
__attribute((convergent)) int64_t4 WaveActiveSum(int64_t4);
2422+
__attribute__((convergent)) int64_t4 WaveActiveSum(int64_t4);
24232423

24242424
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2425-
__attribute((convergent)) uint64_t WaveActiveSum(uint64_t);
2425+
__attribute__((convergent)) uint64_t WaveActiveSum(uint64_t);
24262426
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2427-
__attribute((convergent)) uint64_t2 WaveActiveSum(uint64_t2);
2427+
__attribute__((convergent)) uint64_t2 WaveActiveSum(uint64_t2);
24282428
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2429-
__attribute((convergent)) uint64_t3 WaveActiveSum(uint64_t3);
2429+
__attribute__((convergent)) uint64_t3 WaveActiveSum(uint64_t3);
24302430
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2431-
__attribute((convergent)) uint64_t4 WaveActiveSum(uint64_t4);
2431+
__attribute__((convergent)) uint64_t4 WaveActiveSum(uint64_t4);
24322432

24332433
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2434-
__attribute((convergent)) float WaveActiveSum(float);
2434+
__attribute__((convergent)) float WaveActiveSum(float);
24352435
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2436-
__attribute((convergent)) float2 WaveActiveSum(float2);
2436+
__attribute__((convergent)) float2 WaveActiveSum(float2);
24372437
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2438-
__attribute((convergent)) float3 WaveActiveSum(float3);
2438+
__attribute__((convergent)) float3 WaveActiveSum(float3);
24392439
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2440-
__attribute((convergent)) float4 WaveActiveSum(float4);
2440+
__attribute__((convergent)) float4 WaveActiveSum(float4);
24412441

24422442
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2443-
__attribute((convergent)) double WaveActiveSum(double);
2443+
__attribute__((convergent)) double WaveActiveSum(double);
24442444
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2445-
__attribute((convergent)) double2 WaveActiveSum(double2);
2445+
__attribute__((convergent)) double2 WaveActiveSum(double2);
24462446
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2447-
__attribute((convergent)) double3 WaveActiveSum(double3);
2447+
__attribute__((convergent)) double3 WaveActiveSum(double3);
24482448
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_sum)
2449-
__attribute((convergent)) double4 WaveActiveSum(double4);
2449+
__attribute__((convergent)) double4 WaveActiveSum(double4);
24502450

24512451
//===----------------------------------------------------------------------===//
24522452
// sign builtins

clang/lib/Sema/SemaHLSL.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -1843,18 +1843,18 @@ static bool CheckAnyScalarOrVector(Sema *S, CallExpr *TheCall,
18431843
return false;
18441844
}
18451845

1846-
static bool CheckNotScalarType(Sema *S, CallExpr *TheCall, QualType Scalar,
1847-
unsigned ArgIndex) {
1846+
static bool CheckNotBoolType(Sema *S, CallExpr *TheCall, unsigned ArgIndex) {
1847+
QualType BoolType = S->getASTContext().BoolTy;
18481848
assert(TheCall->getNumArgs() >= ArgIndex);
18491849
QualType ArgType = TheCall->getArg(ArgIndex)->getType();
18501850
auto *VTy = ArgType->getAs<VectorType>();
1851-
// is the scalar or vector<scalar>
1852-
if (S->Context.hasSameUnqualifiedType(ArgType, Scalar) ||
1851+
// is the bool or vector<bool>
1852+
if (S->Context.hasSameUnqualifiedType(ArgType, BoolType) ||
18531853
(VTy &&
1854-
S->Context.hasSameUnqualifiedType(VTy->getElementType(), Scalar))) {
1854+
S->Context.hasSameUnqualifiedType(VTy->getElementType(), BoolType))) {
18551855
S->Diag(TheCall->getArg(0)->getBeginLoc(),
18561856
diag::err_typecheck_expect_scalar_or_vector_not_type)
1857-
<< ArgType << Scalar;
1857+
<< ArgType << BoolType;
18581858
return true;
18591859
}
18601860
return false;
@@ -2175,7 +2175,7 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
21752175
// Ensure input expr type is a scalar/vector and the same as the return type
21762176
if (CheckAnyScalarOrVector(&SemaRef, TheCall, 0))
21772177
return true;
2178-
if (CheckNotScalarType(&SemaRef, TheCall, getASTContext().BoolTy, 0))
2178+
if (CheckNotBoolType(&SemaRef, TheCall, 0))
21792179
return true;
21802180
ExprResult Expr = TheCall->getArg(0);
21812181
QualType ArgTyExpr = Expr.get()->getType();

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ float2 test_too_many_arg(float2 p0) {
1212

1313
bool test_expr_bool_type_check(bool p0) {
1414
return __builtin_hlsl_wave_active_sum(p0);
15-
// expected-error@-1 {{invalid operand of type 'bool' where 'bool' or a vector of such type is not allowed}}
15+
// expected-error@-1 {{invalid operand of type 'bool'}}
1616
}
1717

1818
bool2 test_expr_bool_vec_type_check(bool2 p0) {
1919
return __builtin_hlsl_wave_active_sum(p0);
20-
// expected-error@-1 {{invalid operand of type 'bool2' (aka 'vector<bool, 2>') where 'bool' or a vector of such type is not allowed}}
20+
// expected-error@-1 {{invalid operand of type 'bool2' (aka 'vector<bool, 2>')}}
2121
}
2222

2323
struct S { float f; };

0 commit comments

Comments
 (0)