Skip to content

Commit dde1e97

Browse files
committed
review: make version more concise
1 parent 4c45a13 commit dde1e97

File tree

1 file changed

+57
-32
lines changed

1 file changed

+57
-32
lines changed

clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ using namespace llvm::hlsl::rootsig;
2929

3030
namespace {
3131

32-
static const llvm::dxbc::RootSignatureVersion DefVersion =
33-
llvm::dxbc::RootSignatureVersion::V1_1;
32+
using llvm::dxbc::RootSignatureVersion;
3433

3534
// Diagnostic helper for helper tests
3635
class ExpectedDiagConsumer : public DiagnosticConsumer {
@@ -118,7 +117,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseEmptyTest) {
118117

119118
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
120119
SmallVector<RootElement> Elements;
121-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
120+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
121+
*PP);
122122

123123
// Test no diagnostics produced
124124
Consumer->setNoDiag();
@@ -152,7 +152,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
152152

153153
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
154154
SmallVector<RootElement> Elements;
155-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
155+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
156+
*PP);
156157

157158
// Test no diagnostics produced
158159
Consumer->setNoDiag();
@@ -255,7 +256,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
255256

256257
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
257258
SmallVector<RootElement> Elements;
258-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
259+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
260+
*PP);
259261

260262
// Test no diagnostics produced
261263
Consumer->setNoDiag();
@@ -340,7 +342,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseFloatsTest) {
340342

341343
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
342344
SmallVector<RootElement> Elements;
343-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
345+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
346+
*PP);
344347

345348
// Test no diagnostics produced
346349
Consumer->setNoDiag();
@@ -415,7 +418,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidSamplerFlagsTest) {
415418

416419
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
417420
SmallVector<RootElement> Elements;
418-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
421+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
422+
*PP);
419423

420424
// Test no diagnostics produced
421425
Consumer->setNoDiag();
@@ -446,7 +450,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
446450

447451
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
448452
SmallVector<RootElement> Elements;
449-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
453+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
454+
*PP);
450455

451456
// Test no diagnostics produced
452457
Consumer->setNoDiag();
@@ -503,7 +508,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootFlagsTest) {
503508

504509
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
505510
SmallVector<RootElement> Elements;
506-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
511+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
512+
*PP);
507513

508514
// Test no diagnostics produced
509515
Consumer->setNoDiag();
@@ -556,7 +562,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootDescriptorsTest) {
556562

557563
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
558564
SmallVector<RootElement> Elements;
559-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
565+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
566+
*PP);
560567

561568
// Test no diagnostics produced
562569
Consumer->setNoDiag();
@@ -630,7 +637,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidTrailingCommaTest) {
630637

631638
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
632639
SmallVector<RootElement> Elements;
633-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
640+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
641+
*PP);
634642

635643
// Test no diagnostics produced
636644
Consumer->setNoDiag();
@@ -661,8 +669,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion10Test) {
661669

662670
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
663671
SmallVector<RootElement> Elements;
664-
auto Version = llvm::dxbc::RootSignatureVersion::V1_0;
665-
hlsl::RootSignatureParser Parser(Version, Elements, Lexer, *PP);
672+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_0, Elements, Lexer,
673+
*PP);
666674

667675
// Test no diagnostics produced
668676
Consumer->setNoDiag();
@@ -733,8 +741,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion11Test) {
733741

734742
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
735743
SmallVector<RootElement> Elements;
736-
auto Version = llvm::dxbc::RootSignatureVersion::V1_1;
737-
hlsl::RootSignatureParser Parser(Version, Elements, Lexer, *PP);
744+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
745+
*PP);
738746

739747
// Test no diagnostics produced
740748
Consumer->setNoDiag();
@@ -800,7 +808,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedTokenTest) {
800808

801809
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
802810
SmallVector<RootElement> Elements;
803-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
811+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
812+
*PP);
804813

805814
// Test correct diagnostic produced
806815
Consumer->setExpected(diag::err_hlsl_unexpected_end_of_params);
@@ -820,7 +829,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseInvalidTokenTest) {
820829

821830
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
822831
SmallVector<RootElement> Elements;
823-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
832+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
833+
*PP);
824834

825835
// Test correct diagnostic produced - invalid token
826836
Consumer->setExpected(diag::err_hlsl_unexpected_end_of_params);
@@ -840,7 +850,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedEndOfStreamTest) {
840850

841851
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
842852
SmallVector<RootElement> Elements;
843-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
853+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
854+
*PP);
844855

845856
// Test correct diagnostic produced - end of stream
846857
Consumer->setExpected(diag::err_expected_after);
@@ -865,7 +876,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingDTParameterTest) {
865876

866877
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
867878
SmallVector<RootElement> Elements;
868-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
879+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
880+
*PP);
869881

870882
// Test correct diagnostic produced
871883
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -887,7 +899,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRDParameterTest) {
887899

888900
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
889901
SmallVector<RootElement> Elements;
890-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
902+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
903+
*PP);
891904

892905
// Test correct diagnostic produced
893906
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -909,7 +922,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRCParameterTest) {
909922

910923
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
911924
SmallVector<RootElement> Elements;
912-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
925+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
926+
*PP);
913927

914928
// Test correct diagnostic produced
915929
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -933,7 +947,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryDTParameterTest) {
933947

934948
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
935949
SmallVector<RootElement> Elements;
936-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
950+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
951+
*PP);
937952

938953
// Test correct diagnostic produced
939954
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -955,7 +970,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryRCParameterTest) {
955970

956971
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
957972
SmallVector<RootElement> Elements;
958-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
973+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
974+
*PP);
959975

960976
// Test correct diagnostic produced
961977
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -979,7 +995,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalDTParameterTest) {
979995

980996
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
981997
SmallVector<RootElement> Elements;
982-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
998+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
999+
*PP);
9831000

9841001
// Test correct diagnostic produced
9851002
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -1005,7 +1022,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalRCParameterTest) {
10051022

10061023
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
10071024
SmallVector<RootElement> Elements;
1008-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1025+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1026+
*PP);
10091027

10101028
// Test correct diagnostic produced
10111029
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -1028,7 +1046,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) {
10281046

10291047
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
10301048
SmallVector<RootElement> Elements;
1031-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1049+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1050+
*PP);
10321051

10331052
// Test correct diagnostic produced
10341053
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1050,7 +1069,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseOverflowedNegativeNumberTest) {
10501069

10511070
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
10521071
SmallVector<RootElement> Elements;
1053-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1072+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1073+
*PP);
10541074

10551075
// Test correct diagnostic produced
10561076
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1071,7 +1091,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedFloatTest) {
10711091

10721092
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
10731093
SmallVector<RootElement> Elements;
1074-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1094+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1095+
*PP);
10751096

10761097
// Test correct diagnostic produced
10771098
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1092,7 +1113,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexNegOverflowedFloatTest) {
10921113

10931114
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
10941115
SmallVector<RootElement> Elements;
1095-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1116+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1117+
*PP);
10961118

10971119
// Test correct diagnostic produced
10981120
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1113,7 +1135,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedDoubleTest) {
11131135

11141136
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
11151137
SmallVector<RootElement> Elements;
1116-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1138+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1139+
*PP);
11171140

11181141
// Test correct diagnostic produced
11191142
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1134,7 +1157,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexUnderflowFloatTest) {
11341157

11351158
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
11361159
SmallVector<RootElement> Elements;
1137-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1160+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1161+
*PP);
11381162

11391163
// Test correct diagnostic produced
11401164
Consumer->setExpected(diag::err_hlsl_number_literal_underflow);
@@ -1158,7 +1182,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidNonZeroFlagsTest) {
11581182

11591183
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
11601184
SmallVector<RootElement> Elements;
1161-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1185+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1186+
*PP);
11621187

11631188
// Test correct diagnostic produced
11641189
Consumer->setExpected(diag::err_hlsl_rootsig_non_zero_flag);

0 commit comments

Comments
 (0)