[clang] [llvm] Explicit types in cbuffer layouts (PR #156919)
Deric C. via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 4 12:01:11 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));
----------------
Icohedron wrote:
This line causes a build failure on my machine:
```
[264/1543] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/HLSLBufferLayoutBuilder.cpp.o
FAILED: tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/HLSLBufferLayoutBuilder.cpp.o
/nix/store/bichdz31xjvg04ajh8b7qjw6q704a2lb-sccache-0.10.0/bin/sccache /nix/store/pprbhrczrj2gbvvsb0fr2dpqahqz6m77-clang-wrapper-19.1.7/bin/clang++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/workspace/llvm-project/build/tools/clang/lib/CodeGen -I/workspace/llvm-project/clang/lib/CodeGen -I/workspace/llvm-project/clang/include -I/workspace/llvm-project/build/tools/clang/include -I/workspace/llvm-project/build/include -I/workspace/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O2 -g -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/HLSLBufferLayoutBuilder.cpp.o -MF tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/HLSLBufferLayoutBuilder.cpp.o.d -o tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/HLSLBufferLayoutBuilder.cpp.o -c /workspace/llvm-project/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp
/workspace/llvm-project/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp:136:29: error: invalid operands to binary expression ('std::pair<unsigned int, llvm::Type *>' and 'std::pair<unsigned int, std::nullptr_t>' (aka 'pair<unsigned int, std::nullptr_t>'))
136 | assert(Layout[I.second] == std::pair(UINT_MAX, nullptr));
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
https://github.com/llvm/llvm-project/pull/156919
More information about the cfe-commits
mailing list