DIBuilder: take an optional StringRef to pass in unique identifier.

createClassType, createStructType, createUnionType, createEnumerationType,
and createForwardDecl will take an optional StringRef to pass in
the unique identifier.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189410 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Manman Ren 2013-08-27 23:06:40 +00:00
parent ffba4c7e69
commit 23f84cb140
2 changed files with 29 additions and 19 deletions

View File

@ -279,13 +279,15 @@ namespace llvm {
/// DW_AT_containing_type. See DWARF documentation /// DW_AT_containing_type. See DWARF documentation
/// for more info. /// for more info.
/// @param TemplateParms Template type parameters. /// @param TemplateParms Template type parameters.
/// @param UniqueIdentifier A unique identifier for the class.
DICompositeType createClassType(DIDescriptor Scope, StringRef Name, DICompositeType createClassType(DIDescriptor Scope, StringRef Name,
DIFile File, unsigned LineNumber, DIFile File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t SizeInBits, uint64_t AlignInBits,
uint64_t OffsetInBits, unsigned Flags, uint64_t OffsetInBits, unsigned Flags,
DIType DerivedFrom, DIArray Elements, DIType DerivedFrom, DIArray Elements,
MDNode *VTableHolder = 0, MDNode *VTableHolder = 0,
MDNode *TemplateParms = 0); MDNode *TemplateParms = 0,
StringRef UniqueIdentifier = StringRef());
/// createStructType - Create debugging information entry for a struct. /// createStructType - Create debugging information entry for a struct.
/// @param Scope Scope in which this struct is defined. /// @param Scope Scope in which this struct is defined.
@ -297,12 +299,14 @@ namespace llvm {
/// @param Flags Flags to encode member attribute, e.g. private /// @param Flags Flags to encode member attribute, e.g. private
/// @param Elements Struct elements. /// @param Elements Struct elements.
/// @param RunTimeLang Optional parameter, Objective-C runtime version. /// @param RunTimeLang Optional parameter, Objective-C runtime version.
/// @param UniqueIdentifier A unique identifier for the struct.
DICompositeType createStructType(DIDescriptor Scope, StringRef Name, DICompositeType createStructType(DIDescriptor Scope, StringRef Name,
DIFile File, unsigned LineNumber, DIFile File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t SizeInBits, uint64_t AlignInBits,
unsigned Flags, DIType DerivedFrom, unsigned Flags, DIType DerivedFrom,
DIArray Elements, unsigned RunTimeLang = 0, DIArray Elements, unsigned RunTimeLang = 0,
MDNode *VTableHolder = 0); MDNode *VTableHolder = 0,
StringRef UniqueIdentifier = StringRef());
/// createUnionType - Create debugging information entry for an union. /// createUnionType - Create debugging information entry for an union.
/// @param Scope Scope in which this union is defined. /// @param Scope Scope in which this union is defined.
@ -314,10 +318,12 @@ namespace llvm {
/// @param Flags Flags to encode member attribute, e.g. private /// @param Flags Flags to encode member attribute, e.g. private
/// @param Elements Union elements. /// @param Elements Union elements.
/// @param RunTimeLang Optional parameter, Objective-C runtime version. /// @param RunTimeLang Optional parameter, Objective-C runtime version.
/// @param UniqueIdentifier A unique identifier for the union.
DICompositeType createUnionType( DICompositeType createUnionType(
DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber, DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
DIArray Elements, unsigned RunTimeLang = 0); DIArray Elements, unsigned RunTimeLang = 0,
StringRef UniqueIdentifier = StringRef());
/// createTemplateTypeParameter - Create debugging information for template /// createTemplateTypeParameter - Create debugging information for template
/// type parameter. /// type parameter.
@ -398,12 +404,11 @@ namespace llvm {
/// @param AlignInBits Member alignment. /// @param AlignInBits Member alignment.
/// @param Elements Enumeration elements. /// @param Elements Enumeration elements.
/// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum. /// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
/// @param UniqueIdentifier A unique identifier for the enum.
DICompositeType createEnumerationType(DIDescriptor Scope, StringRef Name, DICompositeType createEnumerationType(DIDescriptor Scope, StringRef Name,
DIFile File, unsigned LineNumber, DIFile File, unsigned LineNumber, uint64_t SizeInBits,
uint64_t SizeInBits, uint64_t AlignInBits, DIArray Elements, DIType UnderlyingType,
uint64_t AlignInBits, StringRef UniqueIdentifier = StringRef());
DIArray Elements,
DIType UnderlyingType);
/// createSubroutineType - Create subroutine type. /// createSubroutineType - Create subroutine type.
/// @param File File in which this subroutine is defined. /// @param File File in which this subroutine is defined.
@ -423,7 +428,8 @@ namespace llvm {
DIDescriptor Scope, DIFile F, DIDescriptor Scope, DIFile F,
unsigned Line, unsigned RuntimeLang = 0, unsigned Line, unsigned RuntimeLang = 0,
uint64_t SizeInBits = 0, uint64_t SizeInBits = 0,
uint64_t AlignInBits = 0); uint64_t AlignInBits = 0,
StringRef UniqueIdentifier = StringRef());
/// retainType - Retain DIType in a module even if it is not referenced /// retainType - Retain DIType in a module even if it is not referenced
/// through debug info anchors. /// through debug info anchors.

View File

@ -599,7 +599,8 @@ DICompositeType DIBuilder::createClassType(DIDescriptor Context, StringRef Name,
unsigned Flags, DIType DerivedFrom, unsigned Flags, DIType DerivedFrom,
DIArray Elements, DIArray Elements,
MDNode *VTableHolder, MDNode *VTableHolder,
MDNode *TemplateParams) { MDNode *TemplateParams,
StringRef UniqueIdentifier) {
assert((!Context || Context.isScope() || Context.isType()) && assert((!Context || Context.isScope() || Context.isType()) &&
"createClassType should be called with a valid Context"); "createClassType should be called with a valid Context");
// TAG_class_type is encoded in DICompositeType format. // TAG_class_type is encoded in DICompositeType format.
@ -618,7 +619,7 @@ DICompositeType DIBuilder::createClassType(DIDescriptor Context, StringRef Name,
ConstantInt::get(Type::getInt32Ty(VMContext), 0), ConstantInt::get(Type::getInt32Ty(VMContext), 0),
VTableHolder, VTableHolder,
TemplateParams, TemplateParams,
NULL // Type Identifer UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
}; };
DICompositeType R(MDNode::get(VMContext, Elts)); DICompositeType R(MDNode::get(VMContext, Elts));
assert(R.isCompositeType() && assert(R.isCompositeType() &&
@ -635,7 +636,8 @@ DICompositeType DIBuilder::createStructType(DIDescriptor Context,
unsigned Flags, DIType DerivedFrom, unsigned Flags, DIType DerivedFrom,
DIArray Elements, DIArray Elements,
unsigned RunTimeLang, unsigned RunTimeLang,
MDNode *VTableHolder) { MDNode *VTableHolder,
StringRef UniqueIdentifier) {
// TAG_structure_type is encoded in DICompositeType format. // TAG_structure_type is encoded in DICompositeType format.
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_structure_type), GetTagConstant(VMContext, dwarf::DW_TAG_structure_type),
@ -652,7 +654,7 @@ DICompositeType DIBuilder::createStructType(DIDescriptor Context,
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang), ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
VTableHolder, VTableHolder,
NULL, NULL,
NULL // Type Identifer UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
}; };
DICompositeType R(MDNode::get(VMContext, Elts)); DICompositeType R(MDNode::get(VMContext, Elts));
assert(R.isCompositeType() && assert(R.isCompositeType() &&
@ -666,7 +668,8 @@ DICompositeType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits, unsigned Flags, uint64_t AlignInBits, unsigned Flags,
DIArray Elements, DIArray Elements,
unsigned RunTimeLang) { unsigned RunTimeLang,
StringRef UniqueIdentifier) {
// TAG_union_type is encoded in DICompositeType format. // TAG_union_type is encoded in DICompositeType format.
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_union_type), GetTagConstant(VMContext, dwarf::DW_TAG_union_type),
@ -683,7 +686,7 @@ DICompositeType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name,
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang), ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
NULL, NULL,
NULL, NULL,
NULL // Type Identifer UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
}; };
return DICompositeType(MDNode::get(VMContext, Elts)); return DICompositeType(MDNode::get(VMContext, Elts));
} }
@ -717,7 +720,7 @@ DIBuilder::createSubroutineType(DIFile File, DIArray ParameterTypes) {
DICompositeType DIBuilder::createEnumerationType( DICompositeType DIBuilder::createEnumerationType(
DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber, DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
uint64_t SizeInBits, uint64_t AlignInBits, DIArray Elements, uint64_t SizeInBits, uint64_t AlignInBits, DIArray Elements,
DIType UnderlyingType) { DIType UnderlyingType, StringRef UniqueIdentifier) {
// TAG_enumeration_type is encoded in DICompositeType format. // TAG_enumeration_type is encoded in DICompositeType format.
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_enumeration_type), GetTagConstant(VMContext, dwarf::DW_TAG_enumeration_type),
@ -734,7 +737,7 @@ DICompositeType DIBuilder::createEnumerationType(
ConstantInt::get(Type::getInt32Ty(VMContext), 0), ConstantInt::get(Type::getInt32Ty(VMContext), 0),
NULL, NULL,
NULL, NULL,
NULL // Type Identifer UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
}; };
MDNode *Node = MDNode::get(VMContext, Elts); MDNode *Node = MDNode::get(VMContext, Elts);
AllEnumTypes.push_back(Node); AllEnumTypes.push_back(Node);
@ -859,7 +862,8 @@ DICompositeType DIBuilder::createForwardDecl(unsigned Tag, StringRef Name,
DIDescriptor Scope, DIFile F, DIDescriptor Scope, DIFile F,
unsigned Line, unsigned RuntimeLang, unsigned Line, unsigned RuntimeLang,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits) { uint64_t AlignInBits,
StringRef UniqueIdentifier) {
// Create a temporary MDNode. // Create a temporary MDNode.
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(VMContext, Tag), GetTagConstant(VMContext, Tag),
@ -877,7 +881,7 @@ DICompositeType DIBuilder::createForwardDecl(unsigned Tag, StringRef Name,
ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang),
NULL, NULL,
NULL, //TemplateParams NULL, //TemplateParams
NULL // Type Identifer UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
}; };
MDNode *Node = MDNode::getTemporary(VMContext, Elts); MDNode *Node = MDNode::getTemporary(VMContext, Elts);
DICompositeType RetTy(Node); DICompositeType RetTy(Node);