[clang] [HLSL][RootSignature] Define and integrate rootsig clang attr and decl (PR #137690)

Finn Plummer via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 30 14:25:49 PDT 2025


================
@@ -5209,6 +5211,92 @@ void Parser::ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs) {
   }
 }
 
+void Parser::ParseMicrosoftRootSignatureAttributeArgs(ParsedAttributes &Attrs) {
+  assert(Tok.is(tok::identifier) && "Not a Microsoft attribute list");
+  IdentifierInfo *RootSignatureIdent = Tok.getIdentifierInfo();
+  assert(RootSignatureIdent->getName() == "RootSignature" &&
+         "Not a Microsoft attribute list");
+
+  SourceLocation RootSignatureLoc = Tok.getLocation();
+  ConsumeToken();
+
+  // Ignore the left paren location for now.
+  BalancedDelimiterTracker T(*this, tok::l_paren);
+  if (T.consumeOpen()) {
+    Diag(Tok, diag::err_expected) << tok::l_paren;
+    return;
+  }
+
+  if (!isTokenStringLiteral()) {
+    Diag(Tok, diag::err_expected_string_literal)
+        << /*in attributes...*/ 4 << RootSignatureIdent->getName();
+    SkipUntil(tok::r_square, StopAtSemi | StopBeforeMatch);
+    if (Tok.is(tok::r_paren))
+      T.consumeClose();
+    return;
+  }
+
+  ExprResult StringResult = ParseUnevaluatedStringLiteralExpression();
+  if (StringResult.isInvalid()) {
+    SkipUntil(tok::r_square, StopAtSemi | StopBeforeMatch);
+    if (Tok.is(tok::r_paren))
+      T.consumeClose();
+    return;
+  }
+
+  ArgsVector Args;
+  if (auto Lit = dyn_cast<StringLiteral>(StringResult.get())) {
----------------
inbelic wrote:

Updated the process of extracting the `StringLiteral` so that it better maps to the diag reporting it

https://github.com/llvm/llvm-project/pull/137690


More information about the cfe-commits mailing list