================
@@ -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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to