Skip to content

Commit 0d1bf3a

Browse files
authored
[HLSL][NFC] Refactor worklist loop in HLSLEmitter.cpp to use index-based iteration (#193638)
As suggested by @shafik, the worklist loop in HLSLEmitter.cpp would be more readable as an index-based for-loop as opposed to a range-based for-loop. This PR changes the range-based for-loop over worklist items into an index-based for-loop.
1 parent 3174c94 commit 0d1bf3a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

clang/utils/TableGen/HLSLEmitter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ static void emitWorklistOverloads(raw_ostream &OS, const OverloadContext &Ctx,
461461
ArrayRef<int64_t> VectorSizes,
462462
ArrayRef<const Record *> MatrixDimensions) {
463463
bool InIfdef = false;
464-
for (const TypeWorkItem &Item : Worklist) {
464+
for (size_t I = 0, E = Worklist.size(); I != E; ++I) {
465+
const TypeWorkItem &Item = Worklist[I];
465466
if (Item.NeedsIfdefGuard && !InIfdef) {
466467
OS << "#ifdef __HLSL_ENABLE_16_BIT\n";
467468
InIfdef = true;
@@ -487,8 +488,7 @@ static void emitWorklistOverloads(raw_ostream &OS, const OverloadContext &Ctx,
487488
}
488489

489490
if (InIfdef) {
490-
bool NextIsUnguarded =
491-
(&Item == &Worklist.back()) || !(&Item + 1)->NeedsIfdefGuard;
491+
bool NextIsUnguarded = (I + 1 == E) || !Worklist[I + 1].NeedsIfdefGuard;
492492
if (NextIsUnguarded) {
493493
OS << "#endif\n";
494494
InIfdef = false;

0 commit comments

Comments
 (0)