Skip to content

Commit ee833d1

Browse files
committed
updates based on pr comments
1 parent 4084c2b commit ee833d1

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3849,7 +3849,7 @@ static bool handleScalarCast(EvalInfo &Info, const FPOptions FPO, const Expr *E,
38493849
: Info.Ctx.getIntTypeForBitwidth(64, false);
38503850
Result = APValue(Info.Ctx.MakeIntValue(IntResult, IntType));
38513851
}
3852-
if (DestTy->isFloatingType()) {
3852+
if (DestTy->isRealFloatingType()) {
38533853
APValue Result2 = APValue(APFloat(0.0));
38543854
if (!HandleIntToFloatCast(Info, E, FPO,
38553855
Info.Ctx.getIntTypeForBitwidth(64, false),
@@ -4048,9 +4048,9 @@ static unsigned elementwiseSize(EvalInfo &Info, QualType BaseTy) {
40484048
if (Type->isConstantArrayType()) {
40494049
QualType ElTy = cast<ConstantArrayType>(Info.Ctx.getAsArrayType(Type))
40504050
->getElementType();
4051-
uint64_t Size =
4051+
uint64_t ArrSize =
40524052
cast<ConstantArrayType>(Info.Ctx.getAsArrayType(Type))->getZExtSize();
4053-
for (uint64_t I = 0; I < Size; ++I) {
4053+
for (uint64_t I = 0; I < ArrSize; ++I) {
40544054
WorkList.push_back(ElTy);
40554055
}
40564056
continue;
@@ -11239,11 +11239,12 @@ bool RecordExprEvaluator::VisitCastExpr(const CastExpr *E) {
1123911239
return false;
1124011240
}
1124111241

11242+
unsigned NEls = elementwiseSize(Info, E->getType());
1124211243
// flatten the source
1124311244
SmallVector<APValue> SrcEls;
1124411245
SmallVector<QualType> SrcTypes;
1124511246
if (!flattenAPValue(Info.Ctx, Val, SE->getType(), SrcEls, SrcTypes,
11246-
UINT_MAX))
11247+
NEls))
1124711248
return Error(E);
1124811249

1124911250
// cast the elements and construct our struct result
@@ -13617,11 +13618,12 @@ bool ArrayExprEvaluator::VisitCastExpr(const CastExpr *E) {
1361713618
return false;
1361813619
}
1361913620

13621+
unsigned NEls = elementwiseSize(Info, E->getType());
1362013622
// flatten the source
1362113623
SmallVector<APValue> SrcEls;
1362213624
SmallVector<QualType> SrcTypes;
1362313625
if (!flattenAPValue(Info.Ctx, Val, SE->getType(), SrcEls, SrcTypes,
13624-
UINT_MAX))
13626+
NEls))
1362513627
return Error(E);
1362613628

1362713629
// cast the elements

clang/test/SemaHLSL/Types/AggregateSplatConstantExpr.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export void fn() {
3232
// splat from a vector of size 1
3333

3434
constexpr float1 Y = {1.0};
35-
constexpr int1 A1 = {1};
3635
constexpr float4 F4 = (float4)Y;
3736
_Static_assert(F4[0] == 1.0, "Woo!");
3837
_Static_assert(F4[1] == 1.0, "Woo!");
@@ -51,6 +50,7 @@ export void fn() {
5150
_Static_assert(B6[5] == 3, "Woo!");
5251

5352
// splat from a vector of size 1
53+
constexpr int1 A1 = {1};
5454
constexpr uint64_t2 A7[2] = (uint64_t2[2])A1;
5555
_Static_assert(A7[0][0] == 1, "Woo!");
5656
_Static_assert(A7[0][1] == 1, "Woo!");

clang/test/SemaHLSL/Types/ElementwiseCastConstantExpr.hlsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export void fn() {
3838
// result type int
3939
// truncate from struct
4040
constexpr B1 SB1 = {1.0, 3.0};
41-
constexpr float Blah = SB1.A;
4241
constexpr int X = (int)SB1;
4342
_Static_assert(X == 1, "Woo!");
4443

0 commit comments

Comments
 (0)