[llvm-branch-commits] [clang] [llvm] [HLSL][RootSignature] Add parsing of floats for StaticSampler (PR #140181)
Deric C. via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri May 23 14:54:40 PDT 2025
================
@@ -821,22 +873,110 @@ std::optional<uint32_t> RootSignatureParser::handleUIntLiteral() {
PP.getSourceManager(), PP.getLangOpts(),
PP.getTargetInfo(), PP.getDiagnostics());
if (Literal.hadError)
- return true; // Error has already been reported so just return
+ return std::nullopt; // Error has already been reported so just return
- assert(Literal.isIntegerLiteral() && "IsNumberChar will only support digits");
+ assert(Literal.isIntegerLiteral() &&
+ "NumSpelling can only consist of digits");
llvm::APSInt Val = llvm::APSInt(32, false);
if (Literal.GetIntegerValue(Val)) {
// Report that the value has overflowed
PP.getDiagnostics().Report(CurToken.TokLoc,
diag::err_hlsl_number_literal_overflow)
- << 0 << CurToken.NumSpelling;
+ << /*integer type*/ 0 << /*is signed*/ 0;
return std::nullopt;
}
return Val.getExtValue();
}
+std::optional<int32_t> RootSignatureParser::handleIntLiteral(bool Negated) {
+ // Parse the numeric value and do semantic checks on its specification
+ clang::NumericLiteralParser Literal(CurToken.NumSpelling, CurToken.TokLoc,
+ PP.getSourceManager(), PP.getLangOpts(),
+ PP.getTargetInfo(), PP.getDiagnostics());
+ if (Literal.hadError)
+ return std::nullopt; // Error has already been reported so just return
+
+ assert(Literal.isIntegerLiteral() &&
+ "NumSpelling can only consist of digits");
+
+ llvm::APSInt Val = llvm::APSInt(32, true);
+ if (Literal.GetIntegerValue(Val) || INT32_MAX < Val.getExtValue()) {
----------------
Icohedron wrote:
nvm. I see why
https://github.com/llvm/llvm-project/pull/140181
More information about the llvm-branch-commits
mailing list