================ @@ -0,0 +1,171 @@ +#include "clang/Parse/ParseHLSLRootSignature.h" + +namespace clang { +namespace hlsl { + +// Lexer Definitions + +static bool IsNumberChar(char C) { + // TODO(#120472): extend for float support exponents + return isdigit(C); // integer support +} + +bool RootSignatureLexer::LexNumber(RootSignatureToken &Result) { + // NumericLiteralParser does not handle the sign so we will manually apply it + bool Negative = Buffer.front() == '-'; + bool Signed = Negative || Buffer.front() == '+'; + if (Signed) + AdvanceBuffer(); + + // Retrieve the possible number + StringRef NumSpelling = Buffer.take_while(IsNumberChar); + + // Catch this now as the Literal Parser will accept it as valid + if (NumSpelling.empty()) { + PP.getDiagnostics().Report(Result.TokLoc, + diag::err_hlsl_invalid_number_literal); ---------------- llvm-beanz wrote:
IIUC, this occurs if the parser sees a `-` or `+` but no specified literal value after that. Is that correct? A more succinct error message like "expected numeric literal" is probably a better message. The current one "expected number literal is not a supported number literal of unsigned integer or integer" is quite confusing. https://github.com/llvm/llvm-project/pull/122981 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits