From b0f0ac3cad2d43deaf88038eb48c93f5a8c936a7 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 21 Feb 2025 13:17:06 -0700 Subject: Add overload of DIBuilder::createArrayType (#125229) DICompositeType has an attribute representing the name of a type, but currently it isn't possible to set this for array types via the DIBuilder method. This patch adds a new overload of DIBuilder::createArrayType that allows "full" construction of an array type. This is useful for Ada, where arrays are a bit more first-class than C. --- llvm/lib/IR/DIBuilder.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'llvm/lib/IR/DIBuilder.cpp') diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index bbe4d1f..5ed2993 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -601,10 +601,21 @@ DIBuilder::createArrayType(uint64_t Size, uint32_t AlignInBits, DIType *Ty, PointerUnion AS, PointerUnion AL, PointerUnion RK) { + return createArrayType(nullptr, StringRef(), nullptr, 0, Size, AlignInBits, + Ty, Subscripts, DL, AS, AL, RK); +} + +DICompositeType *DIBuilder::createArrayType( + DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, + uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts, + PointerUnion DL, + PointerUnion AS, + PointerUnion AL, + PointerUnion RK) { auto *R = DICompositeType::get( - VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0, nullptr, Ty, Size, - AlignInBits, 0, DINode::FlagZero, Subscripts, 0, - /*EnumKind=*/std::nullopt, nullptr, nullptr, "", nullptr, + VMContext, dwarf::DW_TAG_array_type, Name, File, LineNumber, + getNonCompileUnitScope(Scope), Ty, Size, AlignInBits, 0, DINode::FlagZero, + Subscripts, 0, /*EnumKind=*/std::nullopt, nullptr, nullptr, "", nullptr, isa(DL) ? (Metadata *)cast(DL) : (Metadata *)cast(DL), isa(AS) ? (Metadata *)cast(AS) -- cgit v1.1