return MachineReg == TRI.getFrameRegister(*AP.MF);
}
-
-DwarfUnit::DwarfUnit(unsigned UID, dwarf::Tag UnitTag, DICompileUnit Node,
- AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU)
+DwarfUnit::DwarfUnit(unsigned UID, dwarf::Tag UnitTag,
+ const MDCompileUnit *Node, AsmPrinter *A, DwarfDebug *DW,
+ DwarfFile *DWU)
: UniqueID(UID), CUNode(Node), UnitDie(UnitTag), DebugInfoOffset(0), Asm(A),
DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr) {
assert(UnitTag == dwarf::DW_TAG_compile_unit ||
addSourceLine(Die, G->getLine(), G->getFilename(), G->getDirectory());
}
-void DwarfUnit::addSourceLine(DIE &Die, DISubprogram SP) {
+void DwarfUnit::addSourceLine(DIE &Die, const MDSubprogram *SP) {
assert(SP);
addSourceLine(Die, SP->getLine(), SP->getFilename(), SP->getDirectory());
addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
}
-void DwarfUnit::addSourceLine(DIE &Die, DINameSpace NS) {
+void DwarfUnit::addSourceLine(DIE &Die, const MDNamespace *NS) {
addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory());
}
StringRef varName = DV.getName();
if (Tag == dwarf::DW_TAG_pointer_type) {
- DIDerivedType DTy = cast<MDDerivedType>(Ty);
+ auto *DTy = cast<MDDerivedType>(Ty);
TmpTy = resolve(DTy->getBaseType());
isPointer = true;
}
// Find the __forwarding field and the variable field in the __Block_byref
// struct.
DIArray Fields = cast<MDCompositeTypeBase>(TmpTy)->getElements();
- DIDerivedType varField;
- DIDerivedType forwardingField;
+ const MDDerivedType *varField = nullptr;
+ const MDDerivedType *forwardingField = nullptr;
for (unsigned i = 0, N = Fields.size(); i < N; ++i) {
- DIDerivedType DT = cast<MDDerivedTypeBase>(Fields[i]);
+ auto *DT = cast<MDDerivedType>(Fields[i]);
StringRef fieldName = DT->getName();
if (fieldName == "__forwarding")
forwardingField = DT;
/// Return true if type encoding is unsigned.
static bool isUnsignedDIType(DwarfDebug *DD, const MDType *Ty) {
- if (DIDerivedType DTy = dyn_cast<MDDerivedTypeBase>(Ty)) {
+ if (auto *DTy = dyn_cast<MDDerivedTypeBase>(Ty)) {
dwarf::Tag T = (dwarf::Tag)Ty->getTag();
// Encode pointer constants as unsigned bytes. This is used at least for
// null pointer constant emission.
return false;
}
- DIBasicType BTy = cast<MDBasicType>(Ty);
+ auto *BTy = cast<MDBasicType>(Ty);
unsigned Encoding = BTy->getEncoding();
assert((Encoding == dwarf::DW_ATE_unsigned ||
Encoding == dwarf::DW_ATE_unsigned_char ||
}
/// If this type is derived from a base type then return base type size.
-static uint64_t getBaseTypeSize(DwarfDebug *DD, DIDerivedType Ty) {
+static uint64_t getBaseTypeSize(DwarfDebug *DD, const MDDerivedType *Ty) {
unsigned Tag = Ty->getTag();
if (Tag != dwarf::DW_TAG_member && Tag != dwarf::DW_TAG_typedef &&
BaseType->getTag() == dwarf::DW_TAG_rvalue_reference_type)
return Ty->getSizeInBits();
- if (auto *DT = dyn_cast<MDDerivedTypeBase>(BaseType))
+ if (auto *DT = dyn_cast<MDDerivedType>(BaseType))
return getBaseTypeSize(DD, DT);
return BaseType->getSizeInBits();
return getDIE(Context);
}
-DIE *DwarfUnit::createTypeDIE(DICompositeType Ty) {
+DIE *DwarfUnit::createTypeDIE(const MDCompositeType *Ty) {
auto *Context = resolve(Ty->getScope());
DIE *ContextDIE = getOrCreateContextDIE(Context);
// Create new type.
DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
- constructTypeDIE(TyDIE, Ty);
+ constructTypeDIE(TyDIE, cast<MDCompositeType>(Ty));
updateAcceleratorTables(Context, Ty, TyDIE);
return &TyDIE;
if (auto *BT = dyn_cast<MDBasicType>(Ty))
constructTypeDIE(TyDIE, BT);
- else if (DICompositeType CTy = dyn_cast<MDCompositeTypeBase>(Ty)) {
+ else if (auto *STy = dyn_cast<MDSubroutineType>(Ty))
+ constructTypeDIE(TyDIE, STy);
+ else if (auto *CTy = dyn_cast<MDCompositeType>(Ty)) {
if (GenerateDwarfTypeUnits && !Ty->isForwardDecl())
if (MDString *TypeId = CTy->getRawIdentifier()) {
DD->addDwarfTypeUnitType(getCU(), TypeId->getString(), TyDIE, CTy);
return CS;
}
-void DwarfUnit::constructTypeDIE(DIE &Buffer, DIBasicType BTy) {
+void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDBasicType *BTy) {
// Get core information.
StringRef Name = BTy->getName();
// Add name if not anonymous or intermediate type.
addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size);
}
-void DwarfUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) {
+void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDDerivedType *DTy) {
// Get core information.
StringRef Name = DTy->getName();
uint64_t Size = DTy->getSizeInBits() >> 3;
}
}
-void DwarfUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
+void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDSubroutineType *CTy) {
+ // Add return type. A void return won't have a type.
+ auto Elements = cast<MDSubroutineType>(CTy)->getTypeArray();
+ if (Elements.size())
+ if (auto RTy = resolve(Elements[0]))
+ addType(Buffer, RTy);
+
+ bool isPrototyped = true;
+ if (Elements.size() == 2 && !Elements[1])
+ isPrototyped = false;
+
+ constructSubprogramArguments(Buffer, Elements);
+
+ // Add prototype flag if we're dealing with a C language and the function has
+ // been prototyped.
+ uint16_t Language = getLanguage();
+ if (isPrototyped &&
+ (Language == dwarf::DW_LANG_C89 || Language == dwarf::DW_LANG_C99 ||
+ Language == dwarf::DW_LANG_ObjC))
+ addFlag(Buffer, dwarf::DW_AT_prototyped);
+
+ if (CTy->isLValueReference())
+ addFlag(Buffer, dwarf::DW_AT_reference);
+
+ if (CTy->isRValueReference())
+ addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
+}
+
+void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
// Add name if not anonymous or intermediate type.
StringRef Name = CTy->getName();
case dwarf::DW_TAG_enumeration_type:
constructEnumTypeDIE(Buffer, CTy);
break;
- case dwarf::DW_TAG_subroutine_type: {
- // Add return type. A void return won't have a type.
- auto Elements = cast<MDSubroutineType>(CTy)->getTypeArray();
- if (Elements.size())
- if (auto RTy = resolve(Elements[0]))
- addType(Buffer, RTy);
-
- bool isPrototyped = true;
- if (Elements.size() == 2 && !Elements[1])
- isPrototyped = false;
-
- constructSubprogramArguments(Buffer, Elements);
-
- // Add prototype flag if we're dealing with a C language and the
- // function has been prototyped.
- uint16_t Language = getLanguage();
- if (isPrototyped &&
- (Language == dwarf::DW_LANG_C89 || Language == dwarf::DW_LANG_C99 ||
- Language == dwarf::DW_LANG_ObjC))
- addFlag(Buffer, dwarf::DW_AT_prototyped);
-
- if (CTy->isLValueReference())
- addFlag(Buffer, dwarf::DW_AT_reference);
-
- if (CTy->isRValueReference())
- addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
- } break;
case dwarf::DW_TAG_structure_type:
case dwarf::DW_TAG_union_type:
case dwarf::DW_TAG_class_type: {
continue;
if (auto *SP = dyn_cast<MDSubprogram>(Element))
getOrCreateSubprogramDIE(SP);
- else if (DIDerivedType DDTy = dyn_cast<MDDerivedTypeBase>(Element)) {
+ else if (auto *DDTy = dyn_cast<MDDerivedType>(Element)) {
if (DDTy->getTag() == dwarf::DW_TAG_friend) {
DIE &ElemDie = createAndAddDIE(dwarf::DW_TAG_friend, Buffer);
addType(ElemDie, resolve(DDTy->getBaseType()), dwarf::DW_AT_friend);
// This is outside the DWARF spec, but GDB expects a DW_AT_containing_type
// inside C++ composite types to point to the base class with the vtable.
- if (DICompositeType ContainingType =
+ if (auto *ContainingType =
dyn_cast_or_null<MDCompositeType>(resolve(CTy->getVTableHolder())))
addDIEEntry(Buffer, dwarf::DW_AT_containing_type,
*getOrCreateTypeDIE(ContainingType));
}
}
-DIE *DwarfUnit::getOrCreateNameSpace(DINameSpace NS) {
+DIE *DwarfUnit::getOrCreateNameSpace(const MDNamespace *NS) {
// Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE.
DIE *ContextDIE = getOrCreateContextDIE(NS->getScope());
return &NDie;
}
-DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP, bool Minimal) {
+DIE *DwarfUnit::getOrCreateSubprogramDIE(const MDSubprogram *SP, bool Minimal) {
// Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE (as is the case for member function
// declarations).
return &SPDie;
}
-bool DwarfUnit::applySubprogramDefinitionAttributes(DISubprogram SP,
+bool DwarfUnit::applySubprogramDefinitionAttributes(const MDSubprogram *SP,
DIE &SPDie) {
DIE *DeclDie = nullptr;
StringRef DeclLinkageName;
return true;
}
-void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie,
+void DwarfUnit::applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie,
bool Minimal) {
if (!Minimal)
if (applySubprogramDefinitionAttributes(SP, SPDie))
Language == dwarf::DW_LANG_ObjC))
addFlag(SPDie, dwarf::DW_AT_prototyped);
- DISubroutineType SPTy = SP->getType();
+ const MDSubroutineType *SPTy = SP->getType();
assert(SPTy->getTag() == dwarf::DW_TAG_subroutine_type &&
"the type of a subprogram should be a subroutine");
return IndexTyDie;
}
-void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, DICompositeType CTy) {
+void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
if (CTy->isVector())
addFlag(Buffer, dwarf::DW_AT_GNU_vector);
}
}
-void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, DICompositeType CTy) {
+void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
DIArray Elements = CTy->getElements();
// Add enumerators to enumeration type.
}
}
-void DwarfUnit::constructMemberDIE(DIE &Buffer, DIDerivedType DT_) {
- // Downcast to MDDerivedType.
- const MDDerivedType *DT = cast<MDDerivedType>(DT_);
-
+void DwarfUnit::constructMemberDIE(DIE &Buffer, const MDDerivedType *DT) {
DIE &MemberDie = createAndAddDIE(DT->getTag(), Buffer);
StringRef Name = DT->getName();
if (!Name.empty())
addFlag(MemberDie, dwarf::DW_AT_artificial);
}
-DIE *DwarfUnit::getOrCreateStaticMemberDIE(DIDerivedType DT_) {
- const MDDerivedType *DT = cast_or_null<MDDerivedType>(DT_);
+DIE *DwarfUnit::getOrCreateStaticMemberDIE(const MDDerivedType *DT) {
if (!DT)
return nullptr;