================ @@ -118,6 +118,48 @@ 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_]+[0-9]* + // The first part is the semantic name, the second is the optional + // semantic index. + bool Invalid = false; + SmallString<256> Buffer; + Buffer.resize(Tok.getLength() + 1); + StringRef Identifier = PP.getSpelling(Tok, Buffer); + if (Invalid) { + // FIXME: fix error message. + Diag(Tok.getLocation(), diag::err_expected_semantic_identifier); + return {/* Name= */ "", /* Location= */ 0, /* Explicit= */ false}; + } + + unsigned I = 0; + for (; I < Identifier.size() && !isDigit(Identifier[I]); ++I) + continue; + StringRef SemanticName = Identifier.take_front(I); + + if (SemanticName.size() == 0) { + // FIXME: fix error message. + Diag(Tok.getLocation(), diag::err_expected_semantic_identifier); + return {/* Name= */ "", /* Location= */ 0, /* Explicit= */ false}; + } + + unsigned Index = 0; + bool Explicit = I < Identifier.size(); + for (; I < Identifier.size() && isDigit(Identifier[I]); ++I) + Index = Index * 10 + Identifier[I] - '0'; + + // The attribute has letters after the index. ---------------- s-perron wrote:
This is not an error for user semantics. https://github.com/llvm/llvm-project/pull/152537 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits