Skip to content

Commit 9a0a9a2

Browse files
committed
review: make version more concise
1 parent f417057 commit 9a0a9a2

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();
@@ -151,7 +151,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
151151

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

156157
// Test no diagnostics produced
157158
Consumer->setNoDiag();
@@ -249,7 +250,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
249250

250251
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
251252
SmallVector<RootElement> Elements;
252-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
253+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
254+
*PP);
253255

254256
// Test no diagnostics produced
255257
Consumer->setNoDiag();
@@ -334,7 +336,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseFloatsTest) {
334336

335337
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
336338
SmallVector<RootElement> Elements;
337-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
339+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
340+
*PP);
338341

339342
// Test no diagnostics produced
340343
Consumer->setNoDiag();
@@ -409,7 +412,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidSamplerFlagsTest) {
409412

410413
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
411414
SmallVector<RootElement> Elements;
412-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
415+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
416+
*PP);
413417

414418
// Test no diagnostics produced
415419
Consumer->setNoDiag();
@@ -439,7 +443,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
439443

440444
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
441445
SmallVector<RootElement> Elements;
442-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
446+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
447+
*PP);
443448

444449
// Test no diagnostics produced
445450
Consumer->setNoDiag();
@@ -495,7 +500,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootFlagsTest) {
495500

496501
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
497502
SmallVector<RootElement> Elements;
498-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
503+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
504+
*PP);
499505

500506
// Test no diagnostics produced
501507
Consumer->setNoDiag();
@@ -536,7 +542,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootDescriptorsTest) {
536542

537543
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
538544
SmallVector<RootElement> Elements;
539-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
545+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
546+
*PP);
540547

541548
// Test no diagnostics produced
542549
Consumer->setNoDiag();
@@ -608,7 +615,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidTrailingCommaTest) {
608615

609616
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
610617
SmallVector<RootElement> Elements;
611-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
618+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
619+
*PP);
612620

613621
// Test no diagnostics produced
614622
Consumer->setNoDiag();
@@ -639,8 +647,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion10Test) {
639647

640648
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
641649
SmallVector<RootElement> Elements;
642-
auto Version = llvm::dxbc::RootSignatureVersion::V1_0;
643-
hlsl::RootSignatureParser Parser(Version, Elements, Lexer, *PP);
650+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_0, Elements, Lexer,
651+
*PP);
644652

645653
// Test no diagnostics produced
646654
Consumer->setNoDiag();
@@ -711,8 +719,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion11Test) {
711719

712720
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
713721
SmallVector<RootElement> Elements;
714-
auto Version = llvm::dxbc::RootSignatureVersion::V1_1;
715-
hlsl::RootSignatureParser Parser(Version, Elements, Lexer, *PP);
722+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
723+
*PP);
716724

717725
// Test no diagnostics produced
718726
Consumer->setNoDiag();
@@ -778,7 +786,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedTokenTest) {
778786

779787
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
780788
SmallVector<RootElement> Elements;
781-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
789+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
790+
*PP);
782791

783792
// Test correct diagnostic produced
784793
Consumer->setExpected(diag::err_hlsl_unexpected_end_of_params);
@@ -798,7 +807,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseInvalidTokenTest) {
798807

799808
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
800809
SmallVector<RootElement> Elements;
801-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
810+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
811+
*PP);
802812

803813
// Test correct diagnostic produced - invalid token
804814
Consumer->setExpected(diag::err_hlsl_unexpected_end_of_params);
@@ -818,7 +828,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedEndOfStreamTest) {
818828

819829
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
820830
SmallVector<RootElement> Elements;
821-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
831+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
832+
*PP);
822833

823834
// Test correct diagnostic produced - end of stream
824835
Consumer->setExpected(diag::err_expected_after);
@@ -843,7 +854,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingDTParameterTest) {
843854

844855
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
845856
SmallVector<RootElement> Elements;
846-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
857+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
858+
*PP);
847859

848860
// Test correct diagnostic produced
849861
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -865,7 +877,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRDParameterTest) {
865877

866878
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
867879
SmallVector<RootElement> Elements;
868-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
880+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
881+
*PP);
869882

870883
// Test correct diagnostic produced
871884
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -887,7 +900,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRCParameterTest) {
887900

888901
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
889902
SmallVector<RootElement> Elements;
890-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
903+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
904+
*PP);
891905

892906
// Test correct diagnostic produced
893907
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -911,7 +925,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryDTParameterTest) {
911925

912926
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
913927
SmallVector<RootElement> Elements;
914-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
928+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
929+
*PP);
915930

916931
// Test correct diagnostic produced
917932
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -933,7 +948,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryRCParameterTest) {
933948

934949
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
935950
SmallVector<RootElement> Elements;
936-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
951+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
952+
*PP);
937953

938954
// Test correct diagnostic produced
939955
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -957,7 +973,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalDTParameterTest) {
957973

958974
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
959975
SmallVector<RootElement> Elements;
960-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
976+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
977+
*PP);
961978

962979
// Test correct diagnostic produced
963980
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -983,7 +1000,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalRCParameterTest) {
9831000

9841001
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
9851002
SmallVector<RootElement> Elements;
986-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1003+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1004+
*PP);
9871005

9881006
// Test correct diagnostic produced
9891007
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -1006,7 +1024,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) {
10061024

10071025
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
10081026
SmallVector<RootElement> Elements;
1009-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1027+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1028+
*PP);
10101029

10111030
// Test correct diagnostic produced
10121031
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1028,7 +1047,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseOverflowedNegativeNumberTest) {
10281047

10291048
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
10301049
SmallVector<RootElement> Elements;
1031-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1050+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1051+
*PP);
10321052

10331053
// Test correct diagnostic produced
10341054
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1049,7 +1069,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedFloatTest) {
10491069

10501070
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
10511071
SmallVector<RootElement> Elements;
1052-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1072+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1073+
*PP);
10531074

10541075
// Test correct diagnostic produced
10551076
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1070,7 +1091,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexNegOverflowedFloatTest) {
10701091

10711092
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
10721093
SmallVector<RootElement> Elements;
1073-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1094+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1095+
*PP);
10741096

10751097
// Test correct diagnostic produced
10761098
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1091,7 +1113,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedDoubleTest) {
10911113

10921114
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
10931115
SmallVector<RootElement> Elements;
1094-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1116+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1117+
*PP);
10951118

10961119
// Test correct diagnostic produced
10971120
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -1112,7 +1135,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexUnderflowFloatTest) {
11121135

11131136
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
11141137
SmallVector<RootElement> Elements;
1115-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1138+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1139+
*PP);
11161140

11171141
// Test correct diagnostic produced
11181142
Consumer->setExpected(diag::err_hlsl_number_literal_underflow);
@@ -1136,7 +1160,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidNonZeroFlagsTest) {
11361160

11371161
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
11381162
SmallVector<RootElement> Elements;
1139-
hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
1163+
hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer,
1164+
*PP);
11401165

11411166
// Test correct diagnostic produced
11421167
Consumer->setExpected(diag::err_hlsl_rootsig_non_zero_flag);

0 commit comments

Comments
 (0)