-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Reland "[HLSL][RootSignature] Implement parsing of a DescriptorTable with empty clauses" #133958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ty clauses (llvm#133302) - defines the Parser class and an initial set of helper methods to support consuming tokens. functionality is demonstrated through a simple empty descriptor table test case - defines an initial in-memory representation of a DescriptorTable - implements a test harness that will be used to validate the correct diagnostics are generated. it will construct a dummy pre-processor with diagnostics consumer to do so Implements the first part of llvm#126569
- there was a warning on some build machines: warning: declaration 'enum clang::hlsl::RootSignatureToken::Kind' does not declare anything. - this was introduced through the use of `using TokenKind = ...`, which was added for the sole purpose of readability - however, it is probably best to remove this `using` statement from the header anyways as it can cause a name clash with `tok::TokenKind` - so to fix the issue, we move the `using TokenKind` statements to exist only in implemenation definitions and not available in the header
- we use an almost identical model for testing diagnostics as LexerTest.cpp which involves creating the same "dummy" clang::Preprocessor - so we can match the same linked libraries required for the test - concretely: missing clangLex was the cause of the linker error and we can remove the unused libraries
@llvm/pr-subscribers-hlsl Author: Finn Plummer (inbelic) ChangesThis pr relands #133302. It resolves two issues:
Patch is 31.36 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/133958.diff 12 Files Affected:
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 86c361b4dbcf7..2582e1e5ef0f6 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1830,4 +1830,8 @@ def err_hlsl_virtual_function
def err_hlsl_virtual_inheritance
: Error<"virtual inheritance is unsupported in HLSL">;
+// HLSL Root Siganture diagnostic messages
+def err_hlsl_unexpected_end_of_params
+ : Error<"expected %0 to denote end of parameters, or, another valid parameter of %1">;
+
} // end of Parser diagnostics
diff --git a/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def b/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def
index e6df763920430..c514d3456146a 100644
--- a/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def
+++ b/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def
@@ -14,16 +14,16 @@
//===----------------------------------------------------------------------===//
#ifndef TOK
-#define TOK(X)
+#define TOK(X, SPELLING)
#endif
#ifndef PUNCTUATOR
-#define PUNCTUATOR(X,Y) TOK(pu_ ## X)
+#define PUNCTUATOR(X,Y) TOK(pu_ ## X, Y)
#endif
#ifndef KEYWORD
-#define KEYWORD(X) TOK(kw_ ## X)
+#define KEYWORD(X) TOK(kw_ ## X, #X)
#endif
#ifndef ENUM
-#define ENUM(NAME, LIT) TOK(en_ ## NAME)
+#define ENUM(NAME, LIT) TOK(en_ ## NAME, LIT)
#endif
// Defines the various types of enum
@@ -49,15 +49,15 @@
#endif
// General Tokens:
-TOK(invalid)
-TOK(end_of_stream)
-TOK(int_literal)
+TOK(invalid, "invalid identifier")
+TOK(end_of_stream, "end of stream")
+TOK(int_literal, "integer literal")
// Register Tokens:
-TOK(bReg)
-TOK(tReg)
-TOK(uReg)
-TOK(sReg)
+TOK(bReg, "b register")
+TOK(tReg, "t register")
+TOK(uReg, "u register")
+TOK(sReg, "s register")
// Punctuators:
PUNCTUATOR(l_paren, '(')
@@ -69,6 +69,7 @@ PUNCTUATOR(plus, '+')
PUNCTUATOR(minus, '-')
// RootElement Keywords:
+KEYWORD(RootSignature) // used only for diagnostic messaging
KEYWORD(DescriptorTable)
// DescriptorTable Keywords:
diff --git a/clang/include/clang/Lex/LexHLSLRootSignature.h b/clang/include/clang/Lex/LexHLSLRootSignature.h
index 21c44e0351d9e..4dc80ff546aa0 100644
--- a/clang/include/clang/Lex/LexHLSLRootSignature.h
+++ b/clang/include/clang/Lex/LexHLSLRootSignature.h
@@ -13,6 +13,7 @@
#ifndef LLVM_CLANG_LEX_LEXHLSLROOTSIGNATURE_H
#define LLVM_CLANG_LEX_LEXHLSLROOTSIGNATURE_H
+#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/SmallVector.h"
@@ -24,11 +25,11 @@ namespace hlsl {
struct RootSignatureToken {
enum Kind {
-#define TOK(X) X,
+#define TOK(X, SPELLING) X,
#include "clang/Lex/HLSLRootSignatureTokenKinds.def"
};
- Kind Kind = Kind::invalid;
+ Kind TokKind = Kind::invalid;
// Retain the SouceLocation of the token for diagnostics
clang::SourceLocation TokLoc;
@@ -38,10 +39,21 @@ struct RootSignatureToken {
// Constructors
RootSignatureToken(clang::SourceLocation TokLoc) : TokLoc(TokLoc) {}
- RootSignatureToken(enum Kind Kind, clang::SourceLocation TokLoc)
- : Kind(Kind), TokLoc(TokLoc) {}
+ RootSignatureToken(Kind TokKind, clang::SourceLocation TokLoc)
+ : TokKind(TokKind), TokLoc(TokLoc) {}
};
-using TokenKind = enum RootSignatureToken::Kind;
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB, const RootSignatureToken::Kind Kind) {
+ switch (Kind) {
+#define TOK(X, SPELLING) \
+ case RootSignatureToken::Kind::X: \
+ DB << SPELLING; \
+ break;
+#include "clang/Lex/HLSLRootSignatureTokenKinds.def"
+ }
+ return DB;
+}
class RootSignatureLexer {
public:
diff --git a/clang/include/clang/Parse/ParseHLSLRootSignature.h b/clang/include/clang/Parse/ParseHLSLRootSignature.h
new file mode 100644
index 0000000000000..18cc2c6692551
--- /dev/null
+++ b/clang/include/clang/Parse/ParseHLSLRootSignature.h
@@ -0,0 +1,107 @@
+//===--- ParseHLSLRootSignature.h -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the RootSignatureParser interface.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_PARSE_PARSEHLSLROOTSIGNATURE_H
+#define LLVM_CLANG_PARSE_PARSEHLSLROOTSIGNATURE_H
+
+#include "clang/Basic/DiagnosticParse.h"
+#include "clang/Lex/LexHLSLRootSignature.h"
+#include "clang/Lex/Preprocessor.h"
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+
+#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
+
+namespace clang {
+namespace hlsl {
+
+class RootSignatureParser {
+public:
+ RootSignatureParser(SmallVector<llvm::hlsl::rootsig::RootElement> &Elements,
+ RootSignatureLexer &Lexer, clang::Preprocessor &PP);
+
+ /// Consumes tokens from the Lexer and constructs the in-memory
+ /// representations of the RootElements. Tokens are consumed until an
+ /// error is encountered or the end of the buffer.
+ ///
+ /// Returns true if a parsing error is encountered.
+ bool parse();
+
+private:
+ DiagnosticsEngine &getDiags() { return PP.getDiagnostics(); }
+
+ // All private Parse.* methods follow a similar pattern:
+ // - Each method will start with an assert to denote what the CurToken is
+ // expected to be and will parse from that token forward
+ //
+ // - Therefore, it is the callers responsibility to ensure that you are
+ // at the correct CurToken. This should be done with the pattern of:
+ //
+ // if (TryConsumeExpectedToken(RootSignatureToken::Kind))
+ // if (Parse.*())
+ // return true;
+ //
+ // or,
+ //
+ // if (ConsumeExpectedToken(RootSignatureToken::Kind, ...))
+ // return true;
+ // if (Parse.*())
+ // return true;
+ //
+ // - All methods return true if a parsing error is encountered. It is the
+ // callers responsibility to propogate this error up, or deal with it
+ // otherwise
+ //
+ // - An error will be raised if the proceeding tokens are not what is
+ // expected, or, there is a lexing error
+
+ /// Root Element parse methods:
+ bool parseDescriptorTable();
+ bool parseDescriptorTableClause();
+
+ /// Invoke the Lexer to consume a token and update CurToken with the result
+ void consumeNextToken() { CurToken = Lexer.ConsumeToken(); }
+
+ /// Return true if the next token one of the expected kinds
+ bool peekExpectedToken(RootSignatureToken::Kind Expected);
+ bool peekExpectedToken(ArrayRef<RootSignatureToken::Kind> AnyExpected);
+
+ /// Consumes the next token and report an error if it is not of the expected
+ /// kind.
+ ///
+ /// Returns true if there was an error reported.
+ bool consumeExpectedToken(
+ RootSignatureToken::Kind Expected, unsigned DiagID = diag::err_expected,
+ RootSignatureToken::Kind Context = RootSignatureToken::Kind::invalid);
+
+ /// Peek if the next token is of the expected kind and if it is then consume
+ /// it.
+ ///
+ /// Returns true if it successfully matches the expected kind and the token
+ /// was consumed.
+ bool tryConsumeExpectedToken(RootSignatureToken::Kind Expected);
+ bool tryConsumeExpectedToken(ArrayRef<RootSignatureToken::Kind> Expected);
+
+private:
+ SmallVector<llvm::hlsl::rootsig::RootElement> &Elements;
+ RootSignatureLexer &Lexer;
+
+ clang::Preprocessor &PP;
+
+ RootSignatureToken CurToken;
+};
+
+} // namespace hlsl
+} // namespace clang
+
+#endif // LLVM_CLANG_PARSE_PARSEHLSLROOTSIGNATURE_H
diff --git a/clang/lib/Lex/LexHLSLRootSignature.cpp b/clang/lib/Lex/LexHLSLRootSignature.cpp
index fb4aab20c7275..b065d9855ddac 100644
--- a/clang/lib/Lex/LexHLSLRootSignature.cpp
+++ b/clang/lib/Lex/LexHLSLRootSignature.cpp
@@ -11,6 +11,8 @@
namespace clang {
namespace hlsl {
+using TokenKind = RootSignatureToken::Kind;
+
// Lexer Definitions
static bool IsNumberChar(char C) {
@@ -34,7 +36,7 @@ RootSignatureToken RootSignatureLexer::LexToken() {
switch (C) {
#define PUNCTUATOR(X, Y) \
case Y: { \
- Result.Kind = TokenKind::pu_##X; \
+ Result.TokKind = TokenKind::pu_##X; \
AdvanceBuffer(); \
return Result; \
}
@@ -45,7 +47,7 @@ RootSignatureToken RootSignatureLexer::LexToken() {
// Integer literal
if (isdigit(C)) {
- Result.Kind = TokenKind::int_literal;
+ Result.TokKind = TokenKind::int_literal;
Result.NumSpelling = Buffer.take_while(IsNumberChar);
AdvanceBuffer(Result.NumSpelling.size());
return Result;
@@ -65,16 +67,16 @@ RootSignatureToken RootSignatureLexer::LexToken() {
// Convert character to the register type.
switch (C) {
case 'b':
- Result.Kind = TokenKind::bReg;
+ Result.TokKind = TokenKind::bReg;
break;
case 't':
- Result.Kind = TokenKind::tReg;
+ Result.TokKind = TokenKind::tReg;
break;
case 'u':
- Result.Kind = TokenKind::uReg;
+ Result.TokKind = TokenKind::uReg;
break;
case 's':
- Result.Kind = TokenKind::sReg;
+ Result.TokKind = TokenKind::sReg;
break;
default:
llvm_unreachable("Switch for an expected token was not provided");
@@ -100,14 +102,14 @@ RootSignatureToken RootSignatureLexer::LexToken() {
#include "clang/Lex/HLSLRootSignatureTokenKinds.def"
// Then attempt to retreive a string from it
- Result.Kind = Switch.Default(TokenKind::invalid);
+ Result.TokKind = Switch.Default(TokenKind::invalid);
AdvanceBuffer(TokSpelling.size());
return Result;
}
RootSignatureToken RootSignatureLexer::ConsumeToken() {
// If we previously peeked then just return the previous value over
- if (NextToken && NextToken->Kind != TokenKind::end_of_stream) {
+ if (NextToken && NextToken->TokKind != TokenKind::end_of_stream) {
RootSignatureToken Result = *NextToken;
NextToken = std::nullopt;
return Result;
diff --git a/clang/lib/Parse/CMakeLists.txt b/clang/lib/Parse/CMakeLists.txt
index 22e902f7e1bc5..00fde537bb9c6 100644
--- a/clang/lib/Parse/CMakeLists.txt
+++ b/clang/lib/Parse/CMakeLists.txt
@@ -14,6 +14,7 @@ add_clang_library(clangParse
ParseExpr.cpp
ParseExprCXX.cpp
ParseHLSL.cpp
+ ParseHLSLRootSignature.cpp
ParseInit.cpp
ParseObjc.cpp
ParseOpenMP.cpp
diff --git a/clang/lib/Parse/ParseHLSLRootSignature.cpp b/clang/lib/Parse/ParseHLSLRootSignature.cpp
new file mode 100644
index 0000000000000..93a9689ebdf72
--- /dev/null
+++ b/clang/lib/Parse/ParseHLSLRootSignature.cpp
@@ -0,0 +1,168 @@
+//=== ParseHLSLRootSignature.cpp - Parse Root Signature -------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Parse/ParseHLSLRootSignature.h"
+
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm::hlsl::rootsig;
+
+namespace clang {
+namespace hlsl {
+
+using TokenKind = RootSignatureToken::Kind;
+
+RootSignatureParser::RootSignatureParser(SmallVector<RootElement> &Elements,
+ RootSignatureLexer &Lexer,
+ Preprocessor &PP)
+ : Elements(Elements), Lexer(Lexer), PP(PP), CurToken(SourceLocation()) {}
+
+bool RootSignatureParser::parse() {
+ // Iterate as many RootElements as possible
+ while (tryConsumeExpectedToken(TokenKind::kw_DescriptorTable)) {
+ // Dispatch onto parser method.
+ // We guard against the unreachable here as we just ensured that CurToken
+ // will be one of the kinds in the while condition
+ switch (CurToken.TokKind) {
+ case TokenKind::kw_DescriptorTable:
+ if (parseDescriptorTable())
+ return true;
+ break;
+ default:
+ llvm_unreachable("Switch for consumed token was not provided");
+ }
+
+ if (!tryConsumeExpectedToken(TokenKind::pu_comma))
+ break;
+ }
+
+ if (!tryConsumeExpectedToken(TokenKind::end_of_stream)) {
+ getDiags().Report(CurToken.TokLoc, diag::err_hlsl_unexpected_end_of_params)
+ << /*expected=*/TokenKind::end_of_stream
+ << /*param of=*/TokenKind::kw_RootSignature;
+ return true;
+ }
+ return false;
+}
+
+bool RootSignatureParser::parseDescriptorTable() {
+ assert(CurToken.TokKind == TokenKind::kw_DescriptorTable &&
+ "Expects to only be invoked starting at given keyword");
+
+ DescriptorTable Table;
+
+ if (consumeExpectedToken(TokenKind::pu_l_paren, diag::err_expected_after,
+ CurToken.TokKind))
+ return true;
+
+ // Iterate as many Clauses as possible
+ while (tryConsumeExpectedToken({TokenKind::kw_CBV, TokenKind::kw_SRV,
+ TokenKind::kw_UAV, TokenKind::kw_Sampler})) {
+ if (parseDescriptorTableClause())
+ return true;
+
+ Table.NumClauses++;
+
+ if (!tryConsumeExpectedToken(TokenKind::pu_comma))
+ break;
+ }
+
+ if (!tryConsumeExpectedToken(TokenKind::pu_r_paren)) {
+ getDiags().Report(CurToken.TokLoc, diag::err_hlsl_unexpected_end_of_params)
+ << /*expected=*/TokenKind::pu_r_paren
+ << /*param of=*/TokenKind::kw_DescriptorTable;
+ return true;
+ }
+
+ Elements.push_back(Table);
+ return false;
+}
+
+bool RootSignatureParser::parseDescriptorTableClause() {
+ assert((CurToken.TokKind == TokenKind::kw_CBV ||
+ CurToken.TokKind == TokenKind::kw_SRV ||
+ CurToken.TokKind == TokenKind::kw_UAV ||
+ CurToken.TokKind == TokenKind::kw_Sampler) &&
+ "Expects to only be invoked starting at given keyword");
+
+ DescriptorTableClause Clause;
+ switch (CurToken.TokKind) {
+ default:
+ llvm_unreachable("Switch for consumed token was not provided");
+ case TokenKind::kw_CBV:
+ Clause.Type = ClauseType::CBuffer;
+ break;
+ case TokenKind::kw_SRV:
+ Clause.Type = ClauseType::SRV;
+ break;
+ case TokenKind::kw_UAV:
+ Clause.Type = ClauseType::UAV;
+ break;
+ case TokenKind::kw_Sampler:
+ Clause.Type = ClauseType::Sampler;
+ break;
+ }
+
+ if (consumeExpectedToken(TokenKind::pu_l_paren, diag::err_expected_after,
+ CurToken.TokKind))
+ return true;
+
+ if (consumeExpectedToken(TokenKind::pu_r_paren, diag::err_expected_after,
+ CurToken.TokKind))
+ return true;
+
+ Elements.push_back(Clause);
+ return false;
+}
+
+bool RootSignatureParser::peekExpectedToken(TokenKind Expected) {
+ return peekExpectedToken(ArrayRef{Expected});
+}
+
+bool RootSignatureParser::peekExpectedToken(ArrayRef<TokenKind> AnyExpected) {
+ RootSignatureToken Result = Lexer.PeekNextToken();
+ return llvm::is_contained(AnyExpected, Result.TokKind);
+}
+
+bool RootSignatureParser::consumeExpectedToken(TokenKind Expected,
+ unsigned DiagID,
+ TokenKind Context) {
+ if (tryConsumeExpectedToken(Expected))
+ return false;
+
+ // Report unexpected token kind error
+ DiagnosticBuilder DB = getDiags().Report(CurToken.TokLoc, DiagID);
+ switch (DiagID) {
+ case diag::err_expected:
+ DB << Expected;
+ break;
+ case diag::err_expected_either:
+ case diag::err_expected_after:
+ DB << Expected << Context;
+ break;
+ default:
+ break;
+ }
+ return true;
+}
+
+bool RootSignatureParser::tryConsumeExpectedToken(TokenKind Expected) {
+ return tryConsumeExpectedToken(ArrayRef{Expected});
+}
+
+bool RootSignatureParser::tryConsumeExpectedToken(
+ ArrayRef<TokenKind> AnyExpected) {
+ // If not the expected token just return
+ if (!peekExpectedToken(AnyExpected))
+ return false;
+ consumeNextToken();
+ return true;
+}
+
+} // namespace hlsl
+} // namespace clang
diff --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index 85d265426ec80..9b3ce8aa7de73 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -25,6 +25,7 @@ endfunction()
add_subdirectory(Basic)
add_subdirectory(Lex)
+add_subdirectory(Parse)
add_subdirectory(Driver)
if(CLANG_ENABLE_STATIC_ANALYZER)
add_subdirectory(Analysis)
diff --git a/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp b/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp
index d72a842922f98..36bd201df1287 100644
--- a/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp
+++ b/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp
@@ -10,6 +10,7 @@
#include "gtest/gtest.h"
using namespace clang;
+using TokenKind = hlsl::RootSignatureToken::Kind;
namespace {
@@ -20,18 +21,18 @@ class LexHLSLRootSignatureTest : public ::testing::Test {
void CheckTokens(hlsl::RootSignatureLexer &Lexer,
SmallVector<hlsl::RootSignatureToken> &Computed,
- SmallVector<hlsl::TokenKind> &Expected) {
+ SmallVector<TokenKind> &Expected) {
for (unsigned I = 0, E = Expected.size(); I != E; ++I) {
// Skip these to help with the macro generated test
- if (Expected[I] == hlsl::TokenKind::invalid ||
- Expected[I] == hlsl::TokenKind::end_of_stream)
+ if (Expected[I] == TokenKind::invalid ||
+ Expected[I] == TokenKind::end_of_stream)
continue;
hlsl::RootSignatureToken Result = Lexer.ConsumeToken();
- ASSERT_EQ(Result.Kind, Expected[I]);
+ ASSERT_EQ(Result.TokKind, Expected[I]);
Computed.push_back(Result);
}
hlsl::RootSignatureToken EndOfStream = Lexer.ConsumeToken();
- ASSERT_EQ(EndOfStream.Kind, hlsl::TokenKind::end_of_stream);
+ ASSERT_EQ(EndOfStream.TokKind, TokenKind::end_of_stream);
ASSERT_TRUE(Lexer.EndOfBuffer());
}
};
@@ -49,11 +50,10 @@ TEST_F(LexHLSLRootSignatureTest, ValidLexNumbersTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<hlsl::RootSignatureToken> Tokens;
- SmallVector<hlsl::TokenKind> Expected = {
- hlsl::TokenKind::pu_minus, hlsl::TokenKind::int_literal,
- hlsl::TokenKind::int_literal, hlsl::TokenKind::pu_plus,
- hlsl::TokenKind::int_literal, hlsl::TokenKind::pu_plus,
- hlsl::TokenKind::int_literal,
+ SmallVector<TokenKind> Expected = {
+ TokenKind::pu_minus, TokenKind::int_literal, TokenKind::int_literal,
+ TokenKind::pu_plus, TokenKind::int_literal, TokenKind::pu_plus,
+ TokenKind::int_literal,
};
CheckTokens(Lexer, Tokens, Expected);
@@ -85,6 +85,8 @@ TEST_F(LexHLSLRootSignatureTest, ValidLexAllTokensTest) {
(),|=+-
+ RootSignature
+
DescriptorTable
CBV SRV UAV Sampler
@@ -112,8 +114,8 @@ TEST_F(LexHLSLRootSignatureTest, ValidLexAllTokensTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<hlsl::RootSignatureToken> Tokens;
- SmallVector<hlsl::TokenKind> Expected = {
-#define TOK(NAME) hlsl::TokenKind::NAME,
+ SmallVector<TokenKind> Expected = {
+#define TOK(NAME, SPELLING) TokenKind::NAME,
#include "clang/Lex/HLSLRootSignatureTokenKinds.def"
};
@@ -134,17 +136,17 @@ TEST_F(LexHLSLRootSignatureTest, ValidCaseInsensitiveKeywordsTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<hlsl::RootSignatureToken> Tokens;
- SmallVector<hlsl::TokenKind> Expected = {
- hlsl::TokenKind::kw_DescriptorTable,
- hlsl::TokenKind::kw_CBV,
- hlsl::TokenKind::kw_SRV,
- hlsl::TokenKind::kw_UAV,
- hlsl::TokenKind::kw_Sampler,
- hlsl::TokenKind::kw_space,
- hlsl::TokenKind::kw_visibility,
- hlsl::TokenKind::kw_flags,
- hlsl::TokenKind::kw_numDescriptors,
- hlsl::TokenKind::kw_offset,
+ SmallVector<TokenKind> Expected = {
+ TokenKind::kw_DescriptorTable,
+ TokenKind::kw_CBV,
+ TokenKind::kw_SRV,
+ T...
[truncated]
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2626 Here is the relevant piece of the build log for the reference
|
…with empty clauses" (llvm#133958) This pr relands llvm#133302. It resolves two issues: - Linking error during build, [here](llvm#133302 (comment)). There was a missing dependency for `clangLex` for the `ParseHLSLRootSignatureTest.cpp` unit testing. This library was added to the dependencies to resolve the error. It wasn't caught previously as the library was transitively linked in most build environments - Warning of unused declaration, [here](llvm#133302 (comment)). There was a usability line in `LexHLSLRootSignature.h` of the form `using TokenKind = enum RootSignatureToken::Kind` which causes this error. The declaration is removed from the header file to be used locally in the `.cpp` files that use it. Notably, the original pr would also exposed `clang::hlsl::TokenKind` to everywhere it was included, which had a name clash with `tok::TokenKind`. This is another motivation to change to the proposed resolution. --------- Co-authored-by: Finn Plummer <[email protected]>
This pr relands #133302.
It resolves two issues:
clangLex
for theParseHLSLRootSignatureTest.cpp
unit testing. This library was added to the dependencies to resolve the error. It wasn't caught previously as the library was transitively linked in most build environmentsLexHLSLRootSignature.h
of the formusing TokenKind = enum RootSignatureToken::Kind
which causes this error. The declaration is removed from the header file to be used locally in the.cpp
files that use it.Notably, the original pr would also exposed
clang::hlsl::TokenKind
to everywhere it was included, which had a name clash withtok::TokenKind
. This is another motivation to change to the proposed resolution.