[clang] [llvm] Explicit types in cbuffer layouts (PR #156919)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 8 10:01:24 PDT 2025
================
@@ -111,53 +118,52 @@ llvm::TargetExtType *HLSLBufferLayoutBuilder::createLayoutType(
if (!PackOffsets || PO != -1) {
if (!layoutField(FD, EndOffset, FieldOffset, FieldType, PO))
return nullptr;
- Layout.push_back(FieldOffset);
- LayoutElements.push_back(FieldType);
+ Layout.emplace_back(FieldOffset, FieldType);
continue;
}
// Have PackOffset info, but there is no packoffset/register(cX)
// annotation on this field. Delay the layout until after all of the
// other elements with packoffsets/register(cX) are processed.
- DelayLayoutFields.emplace_back(FD, LayoutElements.size());
+ DelayLayoutFields.emplace_back(FD, Layout.size());
// reserve space for this field in the layout vector and elements list
- Layout.push_back(UINT_MAX);
- LayoutElements.push_back(nullptr);
+ Layout.emplace_back(UINT_MAX, nullptr);
}
}
// process delayed layouts
for (auto I : DelayLayoutFields) {
const FieldDecl *FD = I.first;
- const unsigned IndexInLayoutElements = I.second;
- // the first item in layout vector is size, so we need to offset the index
- // by 1
- const unsigned IndexInLayout = IndexInLayoutElements + 1;
- assert(Layout[IndexInLayout] == UINT_MAX &&
- LayoutElements[IndexInLayoutElements] == nullptr);
+ assert(Layout[I.second] == std::pair(UINT_MAX, nullptr));
----------------
bogner wrote:
Put an explicit type for the std::pair - should resolve this
https://github.com/llvm/llvm-project/pull/156919
More information about the llvm-commits
mailing list