Skip to content

Commit bbd8921

Browse files
committed
nfc: prepare to extend diagnostic to values as well
1 parent b17b40c commit bbd8921

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,7 @@ def err_hlsl_virtual_inheritance
18601860
: Error<"virtual inheritance is unsupported in HLSL">;
18611861

18621862
// HLSL Root Signature Parser Diagnostics
1863-
def err_hlsl_invalid_param : Error<"invalid parameter of %0">;
1863+
def err_hlsl_invalid_token : Error<"invalid %select{parameter|value}0 of %1">;
18641864
def err_hlsl_rootsig_repeat_param : Error<"specified the same parameter '%0' multiple times">;
18651865
def err_hlsl_rootsig_missing_param : Error<"did not specify mandatory parameter '%0'">;
18661866
def err_hlsl_number_literal_overflow : Error<

clang/lib/Parse/ParseHLSLRootSignature.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ bool RootSignatureParser::parse() {
6161
Elements.emplace_back(RootSignatureElement(ElementLoc, *Sampler));
6262
} else {
6363
consumeNextToken(); // let diagnostic be at the start of invalid token
64-
reportDiag(diag::err_hlsl_invalid_param)
65-
<< /*param of*/ TokenKind::kw_RootSignature;
64+
reportDiag(diag::err_hlsl_invalid_token)
65+
<< /*parameter=*/0 << /*param of*/ TokenKind::kw_RootSignature;
6666
return true;
6767
}
6868

@@ -268,8 +268,8 @@ std::optional<DescriptorTable> RootSignatureParser::parseDescriptorTable() {
268268
return std::nullopt;
269269
} else {
270270
consumeNextToken(); // let diagnostic be at the start of invalid token
271-
reportDiag(diag::err_hlsl_invalid_param)
272-
<< /*param of*/ TokenKind::kw_DescriptorTable;
271+
reportDiag(diag::err_hlsl_invalid_token)
272+
<< /*parameter=*/0 << /*param of*/ TokenKind::kw_DescriptorTable;
273273
return std::nullopt;
274274
}
275275

@@ -486,8 +486,8 @@ RootSignatureParser::parseRootConstantParams() {
486486
Params.Visibility = Visibility;
487487
} else {
488488
consumeNextToken(); // let diagnostic be at the start of invalid token
489-
reportDiag(diag::err_hlsl_invalid_param)
490-
<< /*param of*/ TokenKind::kw_RootConstants;
489+
reportDiag(diag::err_hlsl_invalid_token)
490+
<< /*parameter=*/0 << /*param of*/ TokenKind::kw_RootConstants;
491491
return std::nullopt;
492492
}
493493

@@ -561,7 +561,8 @@ RootSignatureParser::parseRootDescriptorParams(TokenKind DescKind,
561561
Params.Flags = Flags;
562562
} else {
563563
consumeNextToken(); // let diagnostic be at the start of invalid token
564-
reportDiag(diag::err_hlsl_invalid_param) << /*param of*/ DescKind;
564+
reportDiag(diag::err_hlsl_invalid_token)
565+
<< /*parameter=*/0 << /*param of*/ DescKind;
565566
return std::nullopt;
566567
}
567568

@@ -661,7 +662,8 @@ RootSignatureParser::parseDescriptorTableClauseParams(TokenKind ClauseKind,
661662
Params.Flags = Flags;
662663
} else {
663664
consumeNextToken(); // let diagnostic be at the start of invalid token
664-
reportDiag(diag::err_hlsl_invalid_param) << /*param of*/ ClauseKind;
665+
reportDiag(diag::err_hlsl_invalid_token)
666+
<< /*parameter=*/0 << /*param of*/ ClauseKind;
665667
return std::nullopt;
666668
}
667669

@@ -860,8 +862,8 @@ RootSignatureParser::parseStaticSamplerParams() {
860862
Params.Visibility = Visibility;
861863
} else {
862864
consumeNextToken(); // let diagnostic be at the start of invalid token
863-
reportDiag(diag::err_hlsl_invalid_param)
864-
<< /*param of*/ TokenKind::kw_StaticSampler;
865+
reportDiag(diag::err_hlsl_invalid_token)
866+
<< /*parameter=*/0 << /*param of*/ TokenKind::kw_StaticSampler;
865867
return std::nullopt;
866868
}
867869

clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseInvalidTokenTest) {
865865
Signature, *PP);
866866

867867
// Test correct diagnostic produced - invalid token
868-
Consumer->setExpected(diag::err_hlsl_invalid_param);
868+
Consumer->setExpected(diag::err_hlsl_invalid_token);
869869
ASSERT_TRUE(Parser.parse());
870870

871871
ASSERT_TRUE(Consumer->isSatisfied());

0 commit comments

Comments
 (0)