Skip to content

Commit d0ae239

Browse files
authored
Add RunTimeLang to Class and Enumeration DIBuilder functions (#72011)
RunTimeLang is already supported by DICompositeType, and already used by structs and unions. Add a new parameter in the class and enumeration create methods, so they can use the RunTimeLang attribute as well.
1 parent c05ab7b commit d0ae239

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3380,9 +3380,9 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) {
33803380
unsigned Line = getLineNumber(ED->getLocation());
33813381
llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
33823382
llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
3383-
return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
3384-
Line, Size, Align, EltArray, ClassTy,
3385-
Identifier, ED->isScoped());
3383+
return DBuilder.createEnumerationType(
3384+
EnumContext, ED->getName(), DefUnit, Line, Size, Align, EltArray, ClassTy,
3385+
/*RunTimeLang=*/0, Identifier, ED->isScoped());
33863386
}
33873387

33883388
llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent,

llvm/include/llvm/IR/DIBuilder.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ namespace llvm {
425425
/// \param OffsetInBits Member offset.
426426
/// \param Flags Flags to encode member attribute, e.g. private
427427
/// \param Elements class members.
428+
/// \param RunTimeLang Optional parameter, Objective-C runtime version.
428429
/// \param VTableHolder Debug info of the base class that contains vtable
429430
/// for this type. This is used in
430431
/// DW_AT_containing_type. See DWARF documentation
@@ -435,8 +436,8 @@ namespace llvm {
435436
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
436437
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
437438
DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
438-
DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
439-
StringRef UniqueIdentifier = "");
439+
unsigned RunTimeLang = 0, DIType *VTableHolder = nullptr,
440+
MDNode *TemplateParms = nullptr, StringRef UniqueIdentifier = "");
440441

441442
/// Create debugging information entry for a struct.
442443
/// \param Scope Scope in which this struct is defined.
@@ -579,13 +580,15 @@ namespace llvm {
579580
/// \param AlignInBits Member alignment.
580581
/// \param Elements Enumeration elements.
581582
/// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
583+
/// \param RunTimeLang Optional parameter, Objective-C runtime version.
582584
/// \param UniqueIdentifier A unique identifier for the enum.
583-
/// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum class'.
585+
/// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum
586+
/// class'.
584587
DICompositeType *createEnumerationType(
585588
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
586589
uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
587-
DIType *UnderlyingType, StringRef UniqueIdentifier = "", bool IsScoped = false);
588-
590+
DIType *UnderlyingType, unsigned RunTimeLang = 0,
591+
StringRef UniqueIdentifier = "", bool IsScoped = false);
589592
/// Create debugging information entry for a set.
590593
/// \param Scope Scope in which this set is defined.
591594
/// \param Name Set name.

llvm/lib/IR/DIBuilder.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,15 @@ DICompositeType *DIBuilder::createClassType(
476476
DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
477477
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
478478
DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
479-
DIType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) {
479+
unsigned RunTimeLang, DIType *VTableHolder, MDNode *TemplateParams,
480+
StringRef UniqueIdentifier) {
480481
assert((!Context || isa<DIScope>(Context)) &&
481482
"createClassType should be called with a valid Context");
482483

483484
auto *R = DICompositeType::get(
484485
VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
485486
getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits,
486-
OffsetInBits, Flags, Elements, 0, VTableHolder,
487+
OffsetInBits, Flags, Elements, RunTimeLang, VTableHolder,
487488
cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier);
488489
trackIfUnresolved(R);
489490
return R;
@@ -534,15 +535,17 @@ DISubroutineType *DIBuilder::createSubroutineType(DITypeRefArray ParameterTypes,
534535
return DISubroutineType::get(VMContext, Flags, CC, ParameterTypes);
535536
}
536537

537-
DICompositeType *DIBuilder::createEnumerationType(
538-
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
539-
uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
540-
DIType *UnderlyingType, StringRef UniqueIdentifier, bool IsScoped) {
538+
DICompositeType *
539+
DIBuilder::createEnumerationType(DIScope *Scope, StringRef Name, DIFile *File,
540+
unsigned LineNumber, uint64_t SizeInBits,
541+
uint32_t AlignInBits, DINodeArray Elements,
542+
DIType *UnderlyingType, unsigned RunTimeLang,
543+
StringRef UniqueIdentifier, bool IsScoped) {
541544
auto *CTy = DICompositeType::get(
542545
VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
543546
getNonCompileUnitScope(Scope), UnderlyingType, SizeInBits, AlignInBits, 0,
544-
IsScoped ? DINode::FlagEnumClass : DINode::FlagZero, Elements, 0, nullptr,
545-
nullptr, UniqueIdentifier);
547+
IsScoped ? DINode::FlagEnumClass : DINode::FlagZero, Elements,
548+
RunTimeLang, nullptr, nullptr, UniqueIdentifier);
546549
AllEnumTypes.emplace_back(CTy);
547550
trackIfUnresolved(CTy);
548551
return CTy;

llvm/lib/IR/DebugInfo.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,13 +1465,12 @@ LLVMMetadataRef LLVMDIBuilderCreateClassType(LLVMDIBuilderRef Builder,
14651465
auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
14661466
NumElements});
14671467
return wrap(unwrap(Builder)->createClassType(
1468-
unwrapDI<DIScope>(Scope), {Name, NameLen},
1469-
unwrapDI<DIFile>(File), LineNumber,
1470-
SizeInBits, AlignInBits, OffsetInBits,
1471-
map_from_llvmDIFlags(Flags), unwrapDI<DIType>(DerivedFrom),
1472-
Elts, unwrapDI<DIType>(VTableHolder),
1473-
unwrapDI<MDNode>(TemplateParamsNode),
1474-
{UniqueIdentifier, UniqueIdentifierLen}));
1468+
unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
1469+
LineNumber, SizeInBits, AlignInBits, OffsetInBits,
1470+
map_from_llvmDIFlags(Flags), unwrapDI<DIType>(DerivedFrom), Elts,
1471+
/*RunTimeLang=*/0, unwrapDI<DIType>(VTableHolder),
1472+
unwrapDI<MDNode>(TemplateParamsNode),
1473+
{UniqueIdentifier, UniqueIdentifierLen}));
14751474
}
14761475

14771476
LLVMMetadataRef

0 commit comments

Comments
 (0)