Skip to content

Commit bbecb48

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b0f0ac3cad2d' from llvm.org/main into next
2 parents 50e562a + b0f0ac3 commit bbecb48

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

llvm/include/llvm/IR/DIBuilder.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,35 @@ namespace llvm {
587587
PointerUnion<DIExpression *, DIVariable *> Allocated = nullptr,
588588
PointerUnion<DIExpression *, DIVariable *> Rank = nullptr);
589589

590+
/// Create debugging information entry for an array.
591+
/// \param Scope Scope in which this enumeration is defined.
592+
/// \param Name Union name.
593+
/// \param File File where this member is defined.
594+
/// \param LineNumber Line number.
595+
/// \param Size Array size.
596+
/// \param AlignInBits Alignment.
597+
/// \param Ty Element type.
598+
/// \param Subscripts Subscripts.
599+
/// \param DataLocation The location of the raw data of a descriptor-based
600+
/// Fortran array, either a DIExpression* or
601+
/// a DIVariable*.
602+
/// \param Associated The associated attribute of a descriptor-based
603+
/// Fortran array, either a DIExpression* or
604+
/// a DIVariable*.
605+
/// \param Allocated The allocated attribute of a descriptor-based
606+
/// Fortran array, either a DIExpression* or
607+
/// a DIVariable*.
608+
/// \param Rank The rank attribute of a descriptor-based
609+
/// Fortran array, either a DIExpression* or
610+
/// a DIVariable*.
611+
DICompositeType *createArrayType(
612+
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
613+
uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts,
614+
PointerUnion<DIExpression *, DIVariable *> DataLocation = nullptr,
615+
PointerUnion<DIExpression *, DIVariable *> Associated = nullptr,
616+
PointerUnion<DIExpression *, DIVariable *> Allocated = nullptr,
617+
PointerUnion<DIExpression *, DIVariable *> Rank = nullptr);
618+
590619
/// Create debugging information entry for a vector type.
591620
/// \param Size Array size.
592621
/// \param AlignInBits Alignment.

llvm/lib/IR/DIBuilder.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,21 @@ DIBuilder::createArrayType(uint64_t Size, uint32_t AlignInBits, DIType *Ty,
601601
PointerUnion<DIExpression *, DIVariable *> AS,
602602
PointerUnion<DIExpression *, DIVariable *> AL,
603603
PointerUnion<DIExpression *, DIVariable *> RK) {
604+
return createArrayType(nullptr, StringRef(), nullptr, 0, Size, AlignInBits,
605+
Ty, Subscripts, DL, AS, AL, RK);
606+
}
607+
608+
DICompositeType *DIBuilder::createArrayType(
609+
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
610+
uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts,
611+
PointerUnion<DIExpression *, DIVariable *> DL,
612+
PointerUnion<DIExpression *, DIVariable *> AS,
613+
PointerUnion<DIExpression *, DIVariable *> AL,
614+
PointerUnion<DIExpression *, DIVariable *> RK) {
604615
auto *R = DICompositeType::get(
605-
VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0, nullptr, Ty, Size,
606-
AlignInBits, 0, DINode::FlagZero, Subscripts, 0,
607-
/*EnumKind=*/std::nullopt, nullptr, nullptr, "", nullptr,
616+
VMContext, dwarf::DW_TAG_array_type, Name, File, LineNumber,
617+
getNonCompileUnitScope(Scope), Ty, Size, AlignInBits, 0, DINode::FlagZero,
618+
Subscripts, 0, /*EnumKind=*/std::nullopt, nullptr, nullptr, "", nullptr,
608619
isa<DIExpression *>(DL) ? (Metadata *)cast<DIExpression *>(DL)
609620
: (Metadata *)cast<DIVariable *>(DL),
610621
isa<DIExpression *>(AS) ? (Metadata *)cast<DIExpression *>(AS)

llvm/unittests/IR/DebugInfoTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,12 @@ TEST(DIBuilder, CompositeTypes) {
12701270
DICompositeType *Array = DIB.createArrayType(8, 8, nullptr, {});
12711271
EXPECT_EQ(Array->getTag(), dwarf::DW_TAG_array_type);
12721272

1273+
StringRef ArrayNameExp = "AnArray";
1274+
DICompositeType *NamedArray =
1275+
DIB.createArrayType(nullptr, ArrayNameExp, nullptr, 0, 8, 8, nullptr, {});
1276+
EXPECT_EQ(NamedArray->getTag(), dwarf::DW_TAG_array_type);
1277+
EXPECT_EQ(NamedArray->getName(), ArrayNameExp);
1278+
12731279
DICompositeType *Vector = DIB.createVectorType(8, 8, nullptr, {});
12741280
EXPECT_EQ(Vector->getTag(), dwarf::DW_TAG_array_type);
12751281

0 commit comments

Comments
 (0)