Skip to content

Commit ced2f45

Browse files
committed
nfc: rename some things
1 parent 5c4ed1e commit ced2f45

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ bool SemaHLSL::handleRootSignatureElements(
13351335
bool HasNonSampler = false;
13361336
uint32_t Offset = 0;
13371337
for (const auto &[Clause, ClauseElem] : UnboundClauses) {
1338-
SourceLocation Loc = RootSigElem.getLocation();
1338+
SourceLocation Loc = ClauseElem->getLocation();
13391339
if (Clause->Type == llvm::dxil::ResourceClass::Sampler)
13401340
HasSampler = true;
13411341
else
@@ -1356,19 +1356,20 @@ bool SemaHLSL::handleRootSignatureElements(
13561356
Offset = Clause->Offset;
13571357
}
13581358

1359-
uint64_t NextOffset =
1360-
llvm::hlsl::rootsig::nextOffset(Offset, Clause->NumDescriptors);
1359+
uint64_t RangeBound = llvm::hlsl::rootsig::computeRangeBound(
1360+
Offset, Clause->NumDescriptors);
13611361

13621362
if (!llvm::hlsl::rootsig::verifyBoundOffset(Offset)) {
13631363
// Trying to append onto unbound offset
13641364
Diag(Loc, diag::err_hlsl_appending_onto_unbound);
1365-
} else if (!llvm::hlsl::rootsig::verifyNoOverflowedOffset(NextOffset -
1366-
1)) {
1365+
} else if (!llvm::hlsl::rootsig::verifyNoOverflowedOffset(RangeBound)) {
13671366
// Upper bound overflows maximum offset
1368-
Diag(Loc, diag::err_hlsl_offset_overflow) << Offset << NextOffset - 1;
1367+
Diag(Loc, diag::err_hlsl_offset_overflow) << Offset << RangeBound;
13691368
}
13701369

1371-
Offset = uint32_t(NextOffset);
1370+
Offset = RangeBound == llvm::hlsl::rootsig::NumDescriptorsUnbounded
1371+
? uint32_t(RangeBound)
1372+
: uint32_t(RangeBound + 1);
13721373

13731374
// Compute the register bounds and track resource binding
13741375
uint32_t LowerBound(Clause->Reg.Number);

llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ LLVM_ABI bool verifyLOD(float LOD);
4343

4444
LLVM_ABI bool verifyBoundOffset(uint32_t Offset);
4545
LLVM_ABI bool verifyNoOverflowedOffset(uint64_t Offset);
46-
LLVM_ABI uint64_t nextOffset(uint32_t Offset, uint32_t Size);
46+
LLVM_ABI uint64_t computeRangeBound(uint32_t Offset, uint32_t Size);
4747

4848
} // namespace rootsig
4949
} // namespace hlsl

llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,12 @@ bool verifyNoOverflowedOffset(uint64_t Offset) {
188188
return Offset <= std::numeric_limits<uint32_t>::max();
189189
}
190190

191-
uint64_t nextOffset(uint32_t Offset, uint32_t Size) {
191+
uint64_t computeRangeBound(uint32_t Offset, uint32_t Size) {
192+
assert(0 < Size && "Must be a non-empty range");
192193
if (Size == NumDescriptorsUnbounded)
193194
return NumDescriptorsUnbounded;
194195

195-
return uint64_t(Offset) + uint64_t(Size);
196+
return uint64_t(Offset) + uint64_t(Size) - 1;
196197
}
197198

198199
} // namespace rootsig

0 commit comments

Comments
 (0)