Skip to content

Commit 29db170

Browse files
committed
code review feedback - add const, update type, remove unnecessary casts and comment
1 parent c70a662 commit 29db170

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void fillPackoffsetLayout(const HLSLBufferDecl *BufDecl,
207207
continue;
208208
}
209209

210-
size_t Offset = -1;
210+
int32_t Offset = -1;
211211
for (auto *Attr : VD->getAttrs()) {
212212
if (auto *POA = dyn_cast<HLSLPackOffsetAttr>(Attr)) {
213213
Offset = POA->getOffsetInBytes();
@@ -216,7 +216,6 @@ static void fillPackoffsetLayout(const HLSLBufferDecl *BufDecl,
216216
auto *RBA = dyn_cast<HLSLResourceBindingAttr>(Attr);
217217
if (RBA &&
218218
RBA->getRegisterType() == HLSLResourceBindingAttr::RegisterType::C) {
219-
// size of constant buffer row is 16 bytes
220219
Offset = RBA->getSlotNumber() * CBufferRowSizeInBytes;
221220
break;
222221
}

clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ llvm::TargetExtType *HLSLBufferLayoutBuilder::createLayoutType(
109109

110110
// No PackOffset info at all, or have a valid packoffset/register(c#)
111111
// annotations value -> layout the field.
112-
int PO = PackOffsets ? (*PackOffsets)[Index++] : -1;
112+
const int PO = PackOffsets ? (*PackOffsets)[Index++] : -1;
113113
if (!PackOffsets || PO != -1) {
114114
if (!layoutField(FD, EndOffset, FieldOffset, FieldType, PO))
115115
return nullptr;
116-
Layout.push_back((unsigned)FieldOffset);
116+
Layout.push_back(FieldOffset);
117117
LayoutElements.push_back(FieldType);
118118
continue;
119119
}
@@ -130,16 +130,16 @@ llvm::TargetExtType *HLSLBufferLayoutBuilder::createLayoutType(
130130
// process delayed layouts
131131
for (auto I : DelayLayoutFields) {
132132
const FieldDecl *FD = I.first;
133-
unsigned IndexInLayoutElements = I.second;
133+
const unsigned IndexInLayoutElements = I.second;
134134
// the first item in layout vector is size, so we need to offset the index
135135
// by 1
136-
unsigned IndexInLayout = IndexInLayoutElements + 1;
136+
const unsigned IndexInLayout = IndexInLayoutElements + 1;
137137
assert(Layout[IndexInLayout] == UINT_MAX &&
138138
LayoutElements[IndexInLayoutElements] == nullptr);
139139

140140
if (!layoutField(FD, EndOffset, FieldOffset, FieldType))
141141
return nullptr;
142-
Layout[IndexInLayout] = (unsigned)FieldOffset;
142+
Layout[IndexInLayout] = FieldOffset;
143143
LayoutElements[IndexInLayoutElements] = FieldType;
144144
}
145145

0 commit comments

Comments
 (0)