summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-11-18 23:33:32 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-11-18 23:33:32 +0000
commit4adba52570723c2e1654b1c01feddf759893f096 (patch)
treebbabddbffef1149beb61818d217502eecc8a0944
parenta7b7a7d629c3101f6f6c87e6848e865734e0238c (diff)
downloadexternal_llvm-4adba52570723c2e1654b1c01feddf759893f096.zip
external_llvm-4adba52570723c2e1654b1c01feddf759893f096.tar.gz
external_llvm-4adba52570723c2e1654b1c01feddf759893f096.tar.bz2
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
-rw-r--r--include/llvm/DIBuilder.h6
-rw-r--r--include/llvm/DebugInfo.h2
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp39
-rw-r--r--lib/IR/DIBuilder.cpp8
4 files changed, 26 insertions, 29 deletions
diff --git a/include/llvm/DIBuilder.h b/include/llvm/DIBuilder.h
index 420dcef..bac1679 100644
--- a/include/llvm/DIBuilder.h
+++ b/include/llvm/DIBuilder.h
@@ -289,7 +289,7 @@ namespace llvm {
uint64_t SizeInBits, uint64_t AlignInBits,
uint64_t OffsetInBits, unsigned Flags,
DIType DerivedFrom, DIArray Elements,
- DIType VTableHolder = NULL,
+ DIType VTableHolder = DIType(),
MDNode *TemplateParms = 0,
StringRef UniqueIdentifier = StringRef());
@@ -309,7 +309,7 @@ namespace llvm {
uint64_t SizeInBits, uint64_t AlignInBits,
unsigned Flags, DIType DerivedFrom,
DIArray Elements, unsigned RunTimeLang = 0,
- DIType VTableHolder = NULL,
+ DIType VTableHolder = DIType(),
StringRef UniqueIdentifier = StringRef());
/// createUnionType - Create debugging information entry for an union.
@@ -601,7 +601,7 @@ namespace llvm {
DICompositeType Ty, bool isLocalToUnit,
bool isDefinition,
unsigned Virtuality = 0, unsigned VTableIndex = 0,
- DIType VTableHolder = NULL,
+ DIType VTableHolder = DIType(),
unsigned Flags = 0,
bool isOptimized = false,
Function *Fn = 0,
diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h
index 12cd40f..07bd832 100644
--- a/include/llvm/DebugInfo.h
+++ b/include/llvm/DebugInfo.h
@@ -281,7 +281,7 @@ protected:
void printInternal(raw_ostream &OS) const;
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.
bool Verify() const;
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index db77a3f..a6ff953 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -592,33 +592,31 @@ void CompileUnit::addBlockByrefAddress(const DbgVariable &DV, DIE *Die,
StringRef varName = DV.getName();
if (Tag == dwarf::DW_TAG_pointer_type) {
- DIDerivedType DTy = DIDerivedType(Ty);
+ DIDerivedType DTy(Ty);
TmpTy = resolve(DTy.getTypeDerivedFrom());
isPointer = true;
}
- DICompositeType blockStruct = DICompositeType(TmpTy);
+ DICompositeType blockStruct(TmpTy);
// Find the __forwarding field and the variable field in the __Block_byref
// struct.
DIArray Fields = blockStruct.getTypeArray();
- DIDescriptor varField;
- DIDescriptor forwardingField;
+ DIDerivedType varField;
+ DIDerivedType forwardingField;
for (unsigned i = 0, N = Fields.getNumElements(); i < N; ++i) {
- DIDescriptor Element = Fields.getElement(i);
- DIDerivedType DT = DIDerivedType(Element);
+ DIDerivedType DT(Fields.getElement(i));
StringRef fieldName = DT.getName();
if (fieldName == "__forwarding")
- forwardingField = Element;
+ forwardingField = DT;
else if (fieldName == varName)
- varField = Element;
+ varField = DT;
}
// Get the offsets for the forwarding field and the variable field.
- unsigned forwardingFieldOffset =
- DIDerivedType(forwardingField).getOffsetInBits() >> 3;
- unsigned varFieldOffset = DIDerivedType(varField).getOffsetInBits() >> 3;
+ unsigned forwardingFieldOffset = forwardingField.getOffsetInBits() >> 3;
+ unsigned varFieldOffset = varField.getOffsetInBits() >> 2;
// Decode the original location, and use that as the start of the byref
// variable's location.
@@ -1145,9 +1143,9 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
case dwarf::DW_TAG_subroutine_type: {
// Add return type. A void return won't have a type.
DIArray Elements = CTy.getTypeArray();
- DIDescriptor RTy = Elements.getElement(0);
+ DIType RTy(Elements.getElement(0));
if (RTy)
- addType(&Buffer, DIType(RTy));
+ addType(&Buffer, RTy);
bool isPrototyped = true;
// Add arguments.
@@ -1181,7 +1179,7 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
DIE *ElemDie = NULL;
if (Element.isSubprogram()) {
DISubprogram SP(Element);
- ElemDie = getOrCreateSubprogramDIE(DISubprogram(Element));
+ ElemDie = getOrCreateSubprogramDIE(SP);
if (SP.isProtected())
addUInt(ElemDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
dwarf::DW_ACCESS_protected);
@@ -1247,9 +1245,9 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
addFlag(&Buffer, dwarf::DW_AT_APPLE_block);
DICompositeType ContainingType(resolve(CTy.getContainingType()));
- if (ContainingType.isCompositeType())
+ if (ContainingType)
addDIEEntry(&Buffer, dwarf::DW_AT_containing_type,
- getOrCreateTypeDIE(DIType(ContainingType)));
+ getOrCreateTypeDIE(ContainingType));
if (CTy.isObjcClassComplete())
addFlag(&Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
@@ -1457,7 +1455,7 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
// be handled while processing variables.
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
- DIType ATy = DIType(Args.getElement(i));
+ DIType ATy(Args.getElement(i));
addType(Arg, ATy);
if (ATy.isArtificial())
addFlag(Arg, dwarf::DW_AT_artificial);
@@ -1708,13 +1706,12 @@ void CompileUnit::constructEnumTypeDIE(DIE &Buffer, DICompositeType CTy) {
// Add enumerators to enumeration type.
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
- DIDescriptor Enum(Elements.getElement(i));
- DIEnumerator ETy = DIEnumerator(Enum);
+ DIEnumerator Enum(Elements.getElement(i));
if (Enum.isEnumerator()) {
DIE *Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
- StringRef Name = ETy.getName();
+ StringRef Name = Enum.getName();
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);
}
}
diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp
index bdbba1b..c4a9f41 100644
--- a/lib/IR/DIBuilder.cpp
+++ b/lib/IR/DIBuilder.cpp
@@ -752,11 +752,11 @@ DICompositeType DIBuilder::createEnumerationType(
NULL,
UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
};
- MDNode *Node = MDNode::get(VMContext, Elts);
- AllEnumTypes.push_back(Node);
+ DICompositeType CTy(MDNode::get(VMContext, Elts));
+ AllEnumTypes.push_back(CTy);
if (!UniqueIdentifier.empty())
- retainType(Node);
- return DICompositeType(Node);
+ retainType(CTy);
+ return CTy;
}
/// createArrayType - Create debugging information entry for an array.