[clang] [llvm] [SemaHLSL] Correct descriptor range overflow validation (PR #159475)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 19 21:17:32 PDT 2025
================
@@ -1377,32 +1378,28 @@ bool SemaHLSL::handleRootSignatureElements(
if (Clause->NumDescriptors == 0)
return true;
- if (Clause->Offset !=
- llvm::hlsl::rootsig::DescriptorTableOffsetAppend) {
- // Manually specified the offset
+ bool IsAppending =
+ Clause->Offset == llvm::hlsl::rootsig::DescriptorTableOffsetAppend;
+ if (!IsAppending)
----------------
joaosaffran wrote:
I think you might be able to to remove the need to track `Unbound`, if you check if the offset is overflowing, after updating the offset and before calculating `rangeBound`, something like:
```c++
if(Clause->Offset != llvm::hlsl::rootsig::DescriptorTableOffsetAppend)
Offset = Clause->Offset;
if (!llvm::hlsl::rootsig::verifyNoOverflowedOffset(Offset))
Diag(Loc, diag::err_hlsl_appending_onto_unbound);
// From this point onwards, Offset is not overflowing
uint64_t RangeBound = llvm::hlsl::rootsig::computeRangeBound(
Offset, Clause->NumDescriptors);
if (!llvm::hlsl::rootsig::verifyNoOverflowedOffset(RangeBound))
Diag(Loc, diag::err_hlsl_offset_overflow) << Offset << RangeBound;
Offset = RangeBound + 1;
```
https://github.com/llvm/llvm-project/pull/159475
More information about the llvm-commits
mailing list