[clang] d0ae239 - Add RunTimeLang to Class and Enumeration DIBuilder functions (#72011)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 15 12:46:11 PST 2023
Author: Augusto Noronha
Date: 2023-11-15T12:46:06-08:00
New Revision: d0ae2391897033c50225a20fd3024816dffd80b6
URL: https://github.com/llvm/llvm-project/commit/d0ae2391897033c50225a20fd3024816dffd80b6
DIFF: https://github.com/llvm/llvm-project/commit/d0ae2391897033c50225a20fd3024816dffd80b6.diff
LOG: 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.
Added:
Modified:
clang/lib/CodeGen/CGDebugInfo.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/DebugInfo.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 7eeb416c70663c9..0b52d99ad07f164 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3380,9 +3380,9 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) {
unsigned Line = getLineNumber(ED->getLocation());
llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
- return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
- Line, Size, Align, EltArray, ClassTy,
- Identifier, ED->isScoped());
+ return DBuilder.createEnumerationType(
+ EnumContext, ED->getName(), DefUnit, Line, Size, Align, EltArray, ClassTy,
+ /*RunTimeLang=*/0, Identifier, ED->isScoped());
}
llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent,
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index 2be133e85e8c1e4..edec161b3971552 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -425,6 +425,7 @@ namespace llvm {
/// \param OffsetInBits Member offset.
/// \param Flags Flags to encode member attribute, e.g. private
/// \param Elements class members.
+ /// \param RunTimeLang Optional parameter, Objective-C runtime version.
/// \param VTableHolder Debug info of the base class that contains vtable
/// for this type. This is used in
/// DW_AT_containing_type. See DWARF documentation
@@ -435,8 +436,8 @@ namespace llvm {
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
- DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
- StringRef UniqueIdentifier = "");
+ unsigned RunTimeLang = 0, DIType *VTableHolder = nullptr,
+ MDNode *TemplateParms = nullptr, StringRef UniqueIdentifier = "");
/// Create debugging information entry for a struct.
/// \param Scope Scope in which this struct is defined.
@@ -579,13 +580,15 @@ namespace llvm {
/// \param AlignInBits Member alignment.
/// \param Elements Enumeration elements.
/// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
+ /// \param RunTimeLang Optional parameter, Objective-C runtime version.
/// \param UniqueIdentifier A unique identifier for the enum.
- /// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum class'.
+ /// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum
+ /// class'.
DICompositeType *createEnumerationType(
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
- DIType *UnderlyingType, StringRef UniqueIdentifier = "", bool IsScoped = false);
-
+ DIType *UnderlyingType, unsigned RunTimeLang = 0,
+ StringRef UniqueIdentifier = "", bool IsScoped = false);
/// Create debugging information entry for a set.
/// \param Scope Scope in which this set is defined.
/// \param Name Set name.
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 58a7e07d9b58d86..0946cf8048f241a 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -476,14 +476,15 @@ DICompositeType *DIBuilder::createClassType(
DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
- DIType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) {
+ unsigned RunTimeLang, DIType *VTableHolder, MDNode *TemplateParams,
+ StringRef UniqueIdentifier) {
assert((!Context || isa<DIScope>(Context)) &&
"createClassType should be called with a valid Context");
auto *R = DICompositeType::get(
VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits,
- OffsetInBits, Flags, Elements, 0, VTableHolder,
+ OffsetInBits, Flags, Elements, RunTimeLang, VTableHolder,
cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier);
trackIfUnresolved(R);
return R;
@@ -534,15 +535,17 @@ DISubroutineType *DIBuilder::createSubroutineType(DITypeRefArray ParameterTypes,
return DISubroutineType::get(VMContext, Flags, CC, ParameterTypes);
}
-DICompositeType *DIBuilder::createEnumerationType(
- DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
- uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
- DIType *UnderlyingType, StringRef UniqueIdentifier, bool IsScoped) {
+DICompositeType *
+DIBuilder::createEnumerationType(DIScope *Scope, StringRef Name, DIFile *File,
+ unsigned LineNumber, uint64_t SizeInBits,
+ uint32_t AlignInBits, DINodeArray Elements,
+ DIType *UnderlyingType, unsigned RunTimeLang,
+ StringRef UniqueIdentifier, bool IsScoped) {
auto *CTy = DICompositeType::get(
VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
getNonCompileUnitScope(Scope), UnderlyingType, SizeInBits, AlignInBits, 0,
- IsScoped ? DINode::FlagEnumClass : DINode::FlagZero, Elements, 0, nullptr,
- nullptr, UniqueIdentifier);
+ IsScoped ? DINode::FlagEnumClass : DINode::FlagZero, Elements,
+ RunTimeLang, nullptr, nullptr, UniqueIdentifier);
AllEnumTypes.emplace_back(CTy);
trackIfUnresolved(CTy);
return CTy;
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index bb6d612638310f9..b0a79ad897fa9b4 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1465,13 +1465,12 @@ LLVMMetadataRef LLVMDIBuilderCreateClassType(LLVMDIBuilderRef Builder,
auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
NumElements});
return wrap(unwrap(Builder)->createClassType(
- unwrapDI<DIScope>(Scope), {Name, NameLen},
- unwrapDI<DIFile>(File), LineNumber,
- SizeInBits, AlignInBits, OffsetInBits,
- map_from_llvmDIFlags(Flags), unwrapDI<DIType>(DerivedFrom),
- Elts, unwrapDI<DIType>(VTableHolder),
- unwrapDI<MDNode>(TemplateParamsNode),
- {UniqueIdentifier, UniqueIdentifierLen}));
+ unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
+ LineNumber, SizeInBits, AlignInBits, OffsetInBits,
+ map_from_llvmDIFlags(Flags), unwrapDI<DIType>(DerivedFrom), Elts,
+ /*RunTimeLang=*/0, unwrapDI<DIType>(VTableHolder),
+ unwrapDI<MDNode>(TemplateParamsNode),
+ {UniqueIdentifier, UniqueIdentifierLen}));
}
LLVMMetadataRef
More information about the cfe-commits
mailing list