DebugInfo: Simplify a few more explicit constructions, underconstrained types, and make DIType(MDNode*) explicit like all the other DI* node ctors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195055 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2013-11-18 23:33:32 +00:00
parent a7b7a7d629
commit 4adba52570
4 changed files with 26 additions and 29 deletions

View File

@ -289,7 +289,7 @@ namespace llvm {
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,
DIType VTableHolder = NULL, DIType VTableHolder = DIType(),
MDNode *TemplateParms = 0, MDNode *TemplateParms = 0,
StringRef UniqueIdentifier = StringRef()); StringRef UniqueIdentifier = StringRef());
@ -309,7 +309,7 @@ namespace llvm {
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,
DIType VTableHolder = NULL, DIType VTableHolder = DIType(),
StringRef UniqueIdentifier = StringRef()); StringRef UniqueIdentifier = StringRef());
/// createUnionType - Create debugging information entry for an union. /// createUnionType - Create debugging information entry for an union.
@ -601,7 +601,7 @@ namespace llvm {
DICompositeType Ty, bool isLocalToUnit, DICompositeType Ty, bool isLocalToUnit,
bool isDefinition, bool isDefinition,
unsigned Virtuality = 0, unsigned VTableIndex = 0, unsigned Virtuality = 0, unsigned VTableIndex = 0,
DIType VTableHolder = NULL, DIType VTableHolder = DIType(),
unsigned Flags = 0, unsigned Flags = 0,
bool isOptimized = false, bool isOptimized = false,
Function *Fn = 0, Function *Fn = 0,

View File

@ -281,7 +281,7 @@ protected:
void printInternal(raw_ostream &OS) const; void printInternal(raw_ostream &OS) const;
public: public:
DIType(const MDNode *N = 0) : DIScope(N) {} explicit DIType(const MDNode *N = 0) : DIScope(N) {}
/// Verify - Verify that a type descriptor is well formed. /// Verify - Verify that a type descriptor is well formed.
bool Verify() const; bool Verify() const;

View File

@ -592,33 +592,31 @@ void CompileUnit::addBlockByrefAddress(const DbgVariable &DV, DIE *Die,
StringRef varName = DV.getName(); StringRef varName = DV.getName();
if (Tag == dwarf::DW_TAG_pointer_type) { if (Tag == dwarf::DW_TAG_pointer_type) {
DIDerivedType DTy = DIDerivedType(Ty); DIDerivedType DTy(Ty);
TmpTy = resolve(DTy.getTypeDerivedFrom()); TmpTy = resolve(DTy.getTypeDerivedFrom());
isPointer = true; isPointer = true;
} }
DICompositeType blockStruct = DICompositeType(TmpTy); DICompositeType blockStruct(TmpTy);
// Find the __forwarding field and the variable field in the __Block_byref // Find the __forwarding field and the variable field in the __Block_byref
// struct. // struct.
DIArray Fields = blockStruct.getTypeArray(); DIArray Fields = blockStruct.getTypeArray();
DIDescriptor varField; DIDerivedType varField;
DIDescriptor forwardingField; DIDerivedType forwardingField;
for (unsigned i = 0, N = Fields.getNumElements(); i < N; ++i) { for (unsigned i = 0, N = Fields.getNumElements(); i < N; ++i) {
DIDescriptor Element = Fields.getElement(i); DIDerivedType DT(Fields.getElement(i));
DIDerivedType DT = DIDerivedType(Element);
StringRef fieldName = DT.getName(); StringRef fieldName = DT.getName();
if (fieldName == "__forwarding") if (fieldName == "__forwarding")
forwardingField = Element; forwardingField = DT;
else if (fieldName == varName) else if (fieldName == varName)
varField = Element; varField = DT;
} }
// Get the offsets for the forwarding field and the variable field. // Get the offsets for the forwarding field and the variable field.
unsigned forwardingFieldOffset = unsigned forwardingFieldOffset = forwardingField.getOffsetInBits() >> 3;
DIDerivedType(forwardingField).getOffsetInBits() >> 3; unsigned varFieldOffset = varField.getOffsetInBits() >> 2;
unsigned varFieldOffset = DIDerivedType(varField).getOffsetInBits() >> 3;
// Decode the original location, and use that as the start of the byref // Decode the original location, and use that as the start of the byref
// variable's location. // variable's location.
@ -1145,9 +1143,9 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
case dwarf::DW_TAG_subroutine_type: { case dwarf::DW_TAG_subroutine_type: {
// Add return type. A void return won't have a type. // Add return type. A void return won't have a type.
DIArray Elements = CTy.getTypeArray(); DIArray Elements = CTy.getTypeArray();
DIDescriptor RTy = Elements.getElement(0); DIType RTy(Elements.getElement(0));
if (RTy) if (RTy)
addType(&Buffer, DIType(RTy)); addType(&Buffer, RTy);
bool isPrototyped = true; bool isPrototyped = true;
// Add arguments. // Add arguments.
@ -1181,7 +1179,7 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
DIE *ElemDie = NULL; DIE *ElemDie = NULL;
if (Element.isSubprogram()) { if (Element.isSubprogram()) {
DISubprogram SP(Element); DISubprogram SP(Element);
ElemDie = getOrCreateSubprogramDIE(DISubprogram(Element)); ElemDie = getOrCreateSubprogramDIE(SP);
if (SP.isProtected()) if (SP.isProtected())
addUInt(ElemDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1, addUInt(ElemDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
dwarf::DW_ACCESS_protected); dwarf::DW_ACCESS_protected);
@ -1247,9 +1245,9 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
addFlag(&Buffer, dwarf::DW_AT_APPLE_block); addFlag(&Buffer, dwarf::DW_AT_APPLE_block);
DICompositeType ContainingType(resolve(CTy.getContainingType())); DICompositeType ContainingType(resolve(CTy.getContainingType()));
if (ContainingType.isCompositeType()) if (ContainingType)
addDIEEntry(&Buffer, dwarf::DW_AT_containing_type, addDIEEntry(&Buffer, dwarf::DW_AT_containing_type,
getOrCreateTypeDIE(DIType(ContainingType))); getOrCreateTypeDIE(ContainingType));
if (CTy.isObjcClassComplete()) if (CTy.isObjcClassComplete())
addFlag(&Buffer, dwarf::DW_AT_APPLE_objc_complete_type); addFlag(&Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
@ -1457,7 +1455,7 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
// be handled while processing variables. // be handled while processing variables.
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie); DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
DIType ATy = DIType(Args.getElement(i)); DIType ATy(Args.getElement(i));
addType(Arg, ATy); addType(Arg, ATy);
if (ATy.isArtificial()) if (ATy.isArtificial())
addFlag(Arg, dwarf::DW_AT_artificial); addFlag(Arg, dwarf::DW_AT_artificial);
@ -1708,13 +1706,12 @@ void CompileUnit::constructEnumTypeDIE(DIE &Buffer, DICompositeType CTy) {
// Add enumerators to enumeration type. // Add enumerators to enumeration type.
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
DIDescriptor Enum(Elements.getElement(i)); DIEnumerator Enum(Elements.getElement(i));
DIEnumerator ETy = DIEnumerator(Enum);
if (Enum.isEnumerator()) { if (Enum.isEnumerator()) {
DIE *Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer); DIE *Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
StringRef Name = ETy.getName(); StringRef Name = Enum.getName();
addString(Enumerator, dwarf::DW_AT_name, Name); addString(Enumerator, dwarf::DW_AT_name, Name);
int64_t Value = ETy.getEnumValue(); int64_t Value = Enum.getEnumValue();
addSInt(Enumerator, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, Value); addSInt(Enumerator, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, Value);
} }
} }

View File

@ -752,11 +752,11 @@ DICompositeType DIBuilder::createEnumerationType(
NULL, NULL,
UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier) UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
}; };
MDNode *Node = MDNode::get(VMContext, Elts); DICompositeType CTy(MDNode::get(VMContext, Elts));
AllEnumTypes.push_back(Node); AllEnumTypes.push_back(CTy);
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
retainType(Node); retainType(CTy);
return DICompositeType(Node); return CTy;
} }
/// createArrayType - Create debugging information entry for an array. /// createArrayType - Create debugging information entry for an array.