[clang] Reapply "[HLSL] Rewrite semantics parsing" (#157718) (PR #158044)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 23 08:54:53 PDT 2025


================
@@ -118,6 +118,46 @@ static void fixSeparateAttrArgAndNumber(StringRef ArgStr, SourceLocation ArgLoc,
   Slot = new (Ctx) IdentifierLoc(ArgLoc, PP.getIdentifierInfo(FixedArg));
 }
 
+Parser::ParsedSemantic Parser::ParseHLSLSemantic() {
+  assert(Tok.is(tok::identifier) && "Not a HLSL Annotation");
+
+  // Semantic pattern: [A-Za-z_]([A-Za-z_0-9]*[A-Za-z_])?[0-9]*
+  // The first part is the semantic name, the second is the optional
+  // semantic index. The semantic index is the number at the end of
+  // the semantic, including leading zeroes. Digits located before
+  // the last letter are part of the semantic name.
+  bool Invalid = false;
+  SmallString<256> Buffer;
+  Buffer.resize(Tok.getLength() + 1);
+  StringRef Identifier = PP.getSpelling(Tok, Buffer);
+  if (Invalid) {
----------------
shafik wrote:

This is dead code, you set `Invalid` to `false` and never modify it. Was this intentional and the dead code was left by accident?

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


More information about the cfe-commits mailing list