Skip to content

Commit 8cebb68

Browse files
committed
[DebugInfo][CGDebugInfo] Add RunTimeLang to more DIBuilder functions
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 6e574f1 commit 8cebb68

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
@@ -3385,9 +3385,9 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) {
33853385
unsigned Line = getLineNumber(ED->getLocation());
33863386
llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
33873387
llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
3388-
return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
3389-
Line, Size, Align, EltArray, ClassTy,
3390-
Identifier, ED->isScoped());
3388+
return DBuilder.createEnumerationType(
3389+
EnumContext, ED->getName(), DefUnit, Line, Size, Align, EltArray, ClassTy,
3390+
/*RunTimeLang=*/0, Identifier, ED->isScoped());
33913391
}
33923392

33933393
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
@@ -424,6 +424,7 @@ namespace llvm {
424424
/// \param OffsetInBits Member offset.
425425
/// \param Flags Flags to encode member attribute, e.g. private
426426
/// \param Elements class members.
427+
/// \param RunTimeLang Optional parameter, Objective-C runtime version.
427428
/// \param VTableHolder Debug info of the base class that contains vtable
428429
/// for this type. This is used in
429430
/// DW_AT_containing_type. See DWARF documentation
@@ -434,8 +435,8 @@ namespace llvm {
434435
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
435436
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
436437
DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
437-
DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
438-
StringRef UniqueIdentifier = "");
438+
unsigned RunTimeLang = 0, DIType *VTableHolder = nullptr,
439+
MDNode *TemplateParms = nullptr, StringRef UniqueIdentifier = "");
439440

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

llvm/lib/IR/DIBuilder.cpp

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

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

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

llvm/lib/IR/DebugInfo.cpp

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

14791478
LLVMMetadataRef

0 commit comments

Comments
 (0)