Skip to content

Commit 9083988

Browse files
committed
review: remove INT32_MAX constraint
1 parent b4eba5d commit 9083988

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

clang/lib/Parse/ParseHLSLRootSignature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ std::optional<int32_t> RootSignatureParser::handleIntLiteral(bool Negated) {
902902
"NumSpelling can only consist of digits");
903903

904904
llvm::APSInt Val = llvm::APSInt(32, true);
905-
if (Literal.GetIntegerValue(Val) || INT32_MAX < Val.getExtValue()) {
905+
if (Literal.GetIntegerValue(Val)) {
906906
// Report that the value has overflowed
907907
PP.getDiagnostics().Report(CurToken.TokLoc,
908908
diag::err_hlsl_number_literal_overflow)

clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseFloatsTest) {
265265
StaticSampler(s0, mipLODBias = 42.f),
266266
StaticSampler(s0, mipLODBias = 4.2F),
267267
StaticSampler(s0, mipLODBias = 42.e+10f),
268+
StaticSampler(s0, mipLODBias = -2147483648),
269+
StaticSampler(s0, mipLODBias = 2147483648),
268270
)cc";
269271

270272
TrivialModuleLoader ModLoader;
@@ -324,6 +326,14 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseFloatsTest) {
324326
ASSERT_TRUE(std::holds_alternative<StaticSampler>(Elem));
325327
ASSERT_EQ(std::get<StaticSampler>(Elem).MipLODBias, 420000000000.f);
326328

329+
Elem = Elements[11];
330+
ASSERT_TRUE(std::holds_alternative<StaticSampler>(Elem));
331+
ASSERT_FLOAT_EQ(std::get<StaticSampler>(Elem).MipLODBias, -2147483648.f);
332+
333+
Elem = Elements[12];
334+
ASSERT_TRUE(std::holds_alternative<StaticSampler>(Elem));
335+
ASSERT_FLOAT_EQ(std::get<StaticSampler>(Elem).MipLODBias, 2147483648.f);
336+
327337
ASSERT_TRUE(Consumer->isSatisfied());
328338
}
329339

0 commit comments

Comments
 (0)