Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h @@ -22,16 +22,16 @@ const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, bool LE, - bool IsDWO, const DWARFUnitSectionBase &UnitSection) + bool IsDWO, const DWARFUnitSection &UnitSection) : DWARFUnit(Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO, UnitSection) {} - // VTable anchor. + /// VTable anchor. ~DWARFCompileUnit() override; - - void dump(raw_ostream &OS, DIDumpOptions DumpOpts); - - static const DWARFSectionKind Section = DW_SECT_INFO; + /// Dump this compile unit to \p OS. + void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override; + /// Enable LLVM-style RTTI. + static bool classof(const DWARFUnit *U) { return !U->isTypeUnit(); } }; } // end namespace llvm Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -57,8 +57,8 @@ /// This data structure is the top level entity that deals with dwarf debug /// information parsing. The actual data is supplied through DWARFObj. class DWARFContext : public DIContext { - DWARFUnitSection CUs; - std::deque> TUs; + DWARFUnitSection CUs; + std::deque TUs; std::unique_ptr CUIndex; std::unique_ptr GdbIndex; std::unique_ptr TUIndex; @@ -75,8 +75,8 @@ std::unique_ptr AppleNamespaces; std::unique_ptr AppleObjC; - DWARFUnitSection DWOCUs; - std::deque> DWOTUs; + DWARFUnitSection DWOCUs; + std::deque DWOTUs; std::unique_ptr AbbrevDWO; std::unique_ptr LocDWO; @@ -139,8 +139,8 @@ bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override; - using cu_iterator_range = DWARFUnitSection::iterator_range; - using tu_iterator_range = DWARFUnitSection::iterator_range; + using cu_iterator_range = DWARFUnitSection::iterator_range; + using tu_iterator_range = DWARFUnitSection::iterator_range; using tu_section_iterator_range = iterator_range; /// Get compile units in this context. @@ -191,14 +191,14 @@ return DWOTUs.size(); } - /// Get the compile unit at the specified index for this compile unit. - DWARFCompileUnit *getCompileUnitAtIndex(unsigned index) { + /// Get the unit at the specified index. + DWARFUnit *getUnitAtIndex(unsigned index) { parseCompileUnits(); return CUs[index].get(); } - /// Get the compile unit at the specified index for the DWO compile units. - DWARFCompileUnit *getDWOCompileUnitAtIndex(unsigned index) { + /// Get the unit at the specified index for the DWO units. + DWARFUnit *getDWOUnitAtIndex(unsigned index) { parseDWOCompileUnits(); return DWOCUs[index].get(); } Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -278,9 +278,8 @@ /// Helper to allow for parsing of an entire .debug_line section in sequence. class SectionParser { public: - using cu_range = DWARFUnitSection::iterator_range; - using tu_range = - iterator_range>::iterator>; + using cu_range = DWARFUnitSection::iterator_range; + using tu_range = iterator_range::iterator>; using LineToUnitMap = std::map; SectionParser(DWARFDataExtractor &Data, const DWARFContext &C, cu_range CUs, Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h @@ -30,15 +30,16 @@ const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, bool LE, bool IsDWO, - const DWARFUnitSectionBase &UnitSection) + const DWARFUnitSection &UnitSection) : DWARFUnit(Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO, UnitSection) {} uint64_t getTypeHash() const { return getHeader().getTypeHash(); } uint32_t getTypeOffset() const { return getHeader().getTypeOffset(); } - void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}); - static const DWARFSectionKind Section = DW_SECT_TYPES; + void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override; + // Enable LLVM-style RTTI. + static bool classof(const DWARFUnit *U) { return U->isTypeUnit(); } }; } // end namespace llvm Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -101,125 +101,31 @@ uint32_t getNextUnitOffset() const { return Offset + Length + 4; } }; -/// Base class for all DWARFUnitSection classes. This provides the -/// functionality common to all unit types. -class DWARFUnitSectionBase { -public: - /// Returns the Unit that contains the given section offset in the - /// same section this Unit originated from. - virtual DWARFUnit *getUnitForOffset(uint32_t Offset) const = 0; - virtual DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) = 0; - - void parse(DWARFContext &C, const DWARFSection &Section); - void parseDWO(DWARFContext &C, const DWARFSection &DWOSection, - bool Lazy = false); - -protected: - ~DWARFUnitSectionBase() = default; - - virtual void parseImpl(DWARFContext &Context, const DWARFObject &Obj, - const DWARFSection &Section, - const DWARFDebugAbbrev *DA, const DWARFSection *RS, - StringRef SS, const DWARFSection &SOS, - const DWARFSection *AOS, const DWARFSection &LS, - bool isLittleEndian, bool isDWO, bool Lazy) = 0; -}; - const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind); -/// Concrete instance of DWARFUnitSection, specialized for one Unit type. -template -class DWARFUnitSection final : public SmallVector, 1>, - public DWARFUnitSectionBase { +/// Describes one section's Units. +class DWARFUnitSection final : public SmallVector, 1> { bool Parsed = false; - std::function(uint32_t)> Parser; + std::function(uint32_t)> Parser; public: - using UnitVector = SmallVectorImpl>; + using UnitVector = SmallVectorImpl>; using iterator = typename UnitVector::iterator; using iterator_range = llvm::iterator_range; - UnitType *getUnitForOffset(uint32_t Offset) const override { - auto *CU = std::upper_bound( - this->begin(), this->end(), Offset, - [](uint32_t LHS, const std::unique_ptr &RHS) { - return LHS < RHS->getNextUnitOffset(); - }); - if (CU != this->end() && (*CU)->getOffset() <= Offset) - return CU->get(); - return nullptr; - } - UnitType *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) override { - const auto *CUOff = E.getOffset(DW_SECT_INFO); - if (!CUOff) - return nullptr; - - auto Offset = CUOff->Offset; - - auto *CU = std::upper_bound( - this->begin(), this->end(), CUOff->Offset, - [](uint32_t LHS, const std::unique_ptr &RHS) { - return LHS < RHS->getNextUnitOffset(); - }); - if (CU != this->end() && (*CU)->getOffset() <= Offset) - return CU->get(); - - if (!Parser) - return nullptr; - - auto U = Parser(Offset); - if (!U) - U = nullptr; - - auto *NewCU = U.get(); - this->insert(CU, std::move(U)); - return NewCU; - } - + DWARFUnit *getUnitForOffset(uint32_t Offset) const; + DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E); + void parse(DWARFContext &C, const DWARFSection &Section, + DWARFSectionKind SectionKind); + void parseDWO(DWARFContext &C, const DWARFSection &DWOSection, + DWARFSectionKind SectionKind, bool Lazy = false); private: void parseImpl(DWARFContext &Context, const DWARFObject &Obj, const DWARFSection &Section, const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, bool LE, - bool IsDWO, bool Lazy) override { - if (Parsed) - return; - DWARFDataExtractor Data(Obj, Section, LE, 0); - if (!Parser) { - const DWARFUnitIndex *Index = nullptr; - if (IsDWO) - Index = &getDWARFUnitIndex(Context, UnitType::Section); - Parser = [=, &Context, &Section, &SOS, - &LS](uint32_t Offset) -> std::unique_ptr { - if (!Data.isValidOffset(Offset)) - return nullptr; - DWARFUnitHeader Header; - if (!Header.extract(Context, Data, &Offset, UnitType::Section, Index)) - return nullptr; - auto U = llvm::make_unique( - Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO, - *this); - return U; - }; - } - if (Lazy) - return; - auto I = this->begin(); - uint32_t Offset = 0; - while (Data.isValidOffset(Offset)) { - if (I != this->end() && (*I)->getOffset() == Offset) { - ++I; - continue; - } - auto U = Parser(Offset); - if (!U) - break; - Offset = U->getNextUnitOffset(); - I = std::next(this->insert(I, std::move(U))); - } - Parsed = true; - } + bool IsDWO, bool Lazy, DWARFSectionKind SectionKind); }; /// Represents base address of the CU. @@ -268,7 +174,7 @@ uint32_t AddrOffsetSectionBase = 0; bool isLittleEndian; bool isDWO; - const DWARFUnitSectionBase &UnitSection; + const DWARFUnitSection &UnitSection; /// Start, length, and DWARF format of the unit's contribution to the string /// offsets table (DWARF v5). @@ -325,7 +231,7 @@ const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, bool LE, bool IsDWO, - const DWARFUnitSectionBase &UnitSection); + const DWARFUnitSection &UnitSection); virtual ~DWARFUnit(); @@ -342,6 +248,7 @@ } uint32_t getLength() const { return Header.getLength(); } uint8_t getUnitType() const { return Header.getUnitType(); } + bool isTypeUnit() const { return Header.isTypeUnit(); } uint32_t getNextUnitOffset() const { return Header.getNextUnitOffset(); } const DWARFSection &getLineSection() const { return LineSection; } StringRef getStringSection() const { return StringSection; } @@ -481,7 +388,7 @@ SmallVectorImpl &InlinedChain); /// getUnitSection - Return the DWARFUnitSection containing this unit. - const DWARFUnitSectionBase &getUnitSection() const { return UnitSection; } + const DWARFUnitSection &getUnitSection() const { return UnitSection; } /// Returns the number of DIEs in the unit. Parses the unit /// if necessary. @@ -541,6 +448,7 @@ return die_iterator_range(DieArray.begin(), DieArray.end()); } + virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0; private: /// Size in bytes of the .debug_info data associated with this compile unit. size_t getDebugInfoSize() const { Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -584,11 +584,11 @@ } DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash(uint64_t Hash) { - DWOCUs.parseDWO(*this, DObj->getInfoDWOSection(), true); + DWOCUs.parseDWO(*this, DObj->getInfoDWOSection(), DW_SECT_INFO, true); if (const auto &CUI = getCUIndex()) { if (const auto *R = CUI.getFromHash(Hash)) - return DWOCUs.getUnitForIndexEntry(*R); + return dyn_cast_or_null(DWOCUs.getUnitForIndexEntry(*R)); return nullptr; } @@ -607,7 +607,7 @@ continue; } if (DWOCU->getDWOId() == Hash) - return DWOCU.get(); + return dyn_cast(DWOCU.get()); } return nullptr; } @@ -690,10 +690,10 @@ return Loc.get(); Loc.reset(new DWARFDebugLoc); - // Assume all compile units have the same address byte size. + // Assume all units have the same address byte size. if (getNumCompileUnits()) { DWARFDataExtractor LocData(*DObj, DObj->getLocSection(), isLittleEndian(), - getCompileUnitAtIndex(0)->getAddressByteSize()); + getUnitAtIndex(0)->getAddressByteSize()); Loc->parse(LocData); } return Loc.get(); @@ -707,7 +707,7 @@ // Assume all compile units have the same address byte size. if (getNumCompileUnits()) { DataExtractor LocData(DObj->getLocDWOSection().Data, isLittleEndian(), - getCompileUnitAtIndex(0)->getAddressByteSize()); + getUnitAtIndex(0)->getAddressByteSize()); LocDWO->parse(LocData); } return LocDWO.get(); @@ -844,7 +844,7 @@ } void DWARFContext::parseCompileUnits() { - CUs.parse(*this, DObj->getInfoSection()); + CUs.parse(*this, DObj->getInfoSection(), DW_SECT_INFO); } void DWARFContext::parseTypeUnits() { @@ -852,12 +852,12 @@ return; DObj->forEachTypesSections([&](const DWARFSection &S) { TUs.emplace_back(); - TUs.back().parse(*this, S); + TUs.back().parse(*this, S, DW_SECT_TYPES); }); } void DWARFContext::parseDWOCompileUnits() { - DWOCUs.parseDWO(*this, DObj->getInfoDWOSection()); + DWOCUs.parseDWO(*this, DObj->getInfoDWOSection(), DW_SECT_INFO); } void DWARFContext::parseDWOTypeUnits() { @@ -865,13 +865,13 @@ return; DObj->forEachTypesDWOSections([&](const DWARFSection &S) { DWOTUs.emplace_back(); - DWOTUs.back().parseDWO(*this, S); + DWOTUs.back().parseDWO(*this, S, DW_SECT_TYPES); }); } DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) { parseCompileUnits(); - return CUs.getUnitForOffset(Offset); + return dyn_cast_or_null(CUs.getUnitForOffset(Offset)); } DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) { Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -11,12 +11,14 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" +#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" #include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h" #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h" #include "llvm/DebugInfo/DWARF/DWARFDie.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" +#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h" #include "llvm/Support/DataExtractor.h" #include "llvm/Support/Path.h" #include "llvm/Support/WithColor.h" @@ -31,21 +33,112 @@ using namespace llvm; using namespace dwarf; -void DWARFUnitSectionBase::parse(DWARFContext &C, const DWARFSection &Section) { +void DWARFUnitSection::parse(DWARFContext &C, const DWARFSection &Section, + DWARFSectionKind SectionKind) { const DWARFObject &D = C.getDWARFObj(); parseImpl(C, D, Section, C.getDebugAbbrev(), &D.getRangeSection(), D.getStringSection(), D.getStringOffsetSection(), &D.getAddrSection(), D.getLineSection(), D.isLittleEndian(), false, - false); + false, SectionKind); } -void DWARFUnitSectionBase::parseDWO(DWARFContext &C, - const DWARFSection &DWOSection, bool Lazy) { +void DWARFUnitSection::parseDWO(DWARFContext &C, + const DWARFSection &DWOSection, + DWARFSectionKind SectionKind, bool Lazy) { const DWARFObject &D = C.getDWARFObj(); parseImpl(C, D, DWOSection, C.getDebugAbbrevDWO(), &D.getRangeDWOSection(), D.getStringDWOSection(), D.getStringOffsetDWOSection(), &D.getAddrSection(), D.getLineDWOSection(), C.isLittleEndian(), - true, Lazy); + true, Lazy, SectionKind); +} + +void DWARFUnitSection::parseImpl(DWARFContext &Context, const DWARFObject &Obj, + const DWARFSection &Section, const DWARFDebugAbbrev *DA, + const DWARFSection *RS, StringRef SS, const DWARFSection &SOS, + const DWARFSection *AOS, const DWARFSection &LS, bool LE, + bool IsDWO, bool Lazy, DWARFSectionKind SectionKind) { + if (Parsed) + return; + DWARFDataExtractor Data(Obj, Section, LE, 0); + // Lazy initialization of Parser, now that we have all section info. + if (!Parser) { + const DWARFUnitIndex *Index = nullptr; + if (IsDWO) + Index = &getDWARFUnitIndex(Context, SectionKind); + Parser = [=, &Context, &Section, &SOS, + &LS](uint32_t Offset) -> std::unique_ptr { + if (!Data.isValidOffset(Offset)) + return nullptr; + DWARFUnitHeader Header; + if (!Header.extract(Context, Data, &Offset, SectionKind, Index)) + return nullptr; + std::unique_ptr U; + if (Header.isTypeUnit()) + U = llvm::make_unique( + Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO, + *this); + else + U = llvm::make_unique( + Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO, + *this); + return U; + }; + } + if (Lazy) + return; + auto I = this->begin(); + uint32_t Offset = 0; + while (Data.isValidOffset(Offset)) { + if (I != this->end() && (*I)->getOffset() == Offset) { + ++I; + continue; + } + auto U = Parser(Offset); + if (!U) + break; + Offset = U->getNextUnitOffset(); + I = std::next(this->insert(I, std::move(U))); + } + Parsed = true; +} + +DWARFUnit *DWARFUnitSection::getUnitForOffset(uint32_t Offset) const { + auto *CU = std::upper_bound( + this->begin(), this->end(), Offset, + [](uint32_t LHS, const std::unique_ptr &RHS) { + return LHS < RHS->getNextUnitOffset(); + }); + if (CU != this->end() && (*CU)->getOffset() <= Offset) + return CU->get(); + return nullptr; +} + +DWARFUnit * +DWARFUnitSection::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) { + const auto *CUOff = E.getOffset(DW_SECT_INFO); + if (!CUOff) + return nullptr; + + auto Offset = CUOff->Offset; + + auto *CU = std::upper_bound( + this->begin(), this->end(), CUOff->Offset, + [](uint32_t LHS, const std::unique_ptr &RHS) { + return LHS < RHS->getNextUnitOffset(); + }); + if (CU != this->end() && (*CU)->getOffset() <= Offset) + return CU->get(); + + if (!Parser) + return nullptr; + + auto U = Parser(Offset); + if (!U) + U = nullptr; + + auto *NewCU = U.get(); + this->insert(CU, std::move(U)); + return NewCU; } DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section, @@ -53,7 +146,7 @@ const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, bool LE, - bool IsDWO, const DWARFUnitSectionBase &UnitSection) + bool IsDWO, const DWARFUnitSection &UnitSection) : Context(DC), InfoSection(Section), Header(Header), Abbrev(DA), RangeSection(RS), LineSection(LS), StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS), isLittleEndian(LE), Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -264,8 +264,7 @@ bool isUnitDWARF64 = false; bool isHeaderChainValid = true; bool hasDIE = DebugInfoData.isValidOffset(Offset); - DWARFUnitSection TUSection{}; - DWARFUnitSection CUSection{}; + DWARFUnitSection UnitSection{}; while (hasDIE) { OffsetStart = Offset; if (!verifyUnitHeader(DebugInfoData, &Offset, UnitIdx, UnitType, @@ -284,7 +283,7 @@ DCtx, DObj.getInfoSection(), Header, DCtx.getDebugAbbrev(), &DObj.getRangeSection(), DObj.getStringSection(), DObj.getStringOffsetSection(), &DObj.getAppleObjCSection(), - DObj.getLineSection(), DCtx.isLittleEndian(), false, TUSection)); + DObj.getLineSection(), DCtx.isLittleEndian(), false, UnitSection)); break; } case dwarf::DW_UT_skeleton: @@ -298,7 +297,7 @@ DCtx, DObj.getInfoSection(), Header, DCtx.getDebugAbbrev(), &DObj.getRangeSection(), DObj.getStringSection(), DObj.getStringOffsetSection(), &DObj.getAppleObjCSection(), - DObj.getLineSection(), DCtx.isLittleEndian(), false, CUSection)); + DObj.getLineSection(), DCtx.isLittleEndian(), false, UnitSection)); break; } default: { llvm_unreachable("Invalid UnitType."); } @@ -1315,11 +1314,12 @@ if (NumErrors > 0) return NumErrors; - for (const std::unique_ptr &CU : DCtx.compile_units()) { + for (const std::unique_ptr &U : DCtx.compile_units()) { if (const DWARFDebugNames::NameIndex *NI = - AccelTable.getCUNameIndex(CU->getOffset())) { + AccelTable.getCUNameIndex(U->getOffset())) { + auto *CU = cast(U.get()); for (const DWARFDebugInfoEntry &Die : CU->dies()) - NumErrors += verifyNameIndexCompleteness(DWARFDie(CU.get(), &Die), *NI); + NumErrors += verifyNameIndexCompleteness(DWARFDie(CU, &Die), *NI); } } return NumErrors; Index: llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp =================================================================== --- llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp +++ llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp @@ -231,7 +231,8 @@ std::unique_ptr DwarfContext = DWARFContext::create(**Obj); uint32_t NumCUs = DwarfContext->getNumCompileUnits(); EXPECT_EQ(NumCUs, 1u); - DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0); + DWARFCompileUnit *U = + cast(DwarfContext->getUnitAtIndex(0)); auto DieDG = U->getUnitDIE(false); EXPECT_TRUE(DieDG.isValid()); @@ -496,7 +497,8 @@ // Verify the number of compile units is correct. uint32_t NumCUs = DwarfContext->getNumCompileUnits(); EXPECT_EQ(NumCUs, 1u); - DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0); + DWARFCompileUnit *U = + cast(DwarfContext->getUnitAtIndex(0)); // Get the compile unit DIE is valid. auto DieDG = U->getUnitDIE(false); @@ -672,8 +674,10 @@ // Verify the number of compile units is correct. uint32_t NumCUs = DwarfContext->getNumCompileUnits(); EXPECT_EQ(NumCUs, 2u); - DWARFCompileUnit *U1 = DwarfContext->getCompileUnitAtIndex(0); - DWARFCompileUnit *U2 = DwarfContext->getCompileUnitAtIndex(1); + DWARFCompileUnit *U1 = + cast(DwarfContext->getUnitAtIndex(0)); + DWARFCompileUnit *U2 = + cast(DwarfContext->getUnitAtIndex(1)); // Get the compile unit DIE is valid. auto Unit1DieDG = U1->getUnitDIE(false); @@ -880,7 +884,8 @@ // Verify the number of compile units is correct. uint32_t NumCUs = DwarfContext->getNumCompileUnits(); EXPECT_EQ(NumCUs, 1u); - DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0); + DWARFCompileUnit *U = + cast(DwarfContext->getUnitAtIndex(0)); // Get the compile unit DIE is valid. auto DieDG = U->getUnitDIE(false); @@ -1055,7 +1060,8 @@ // Verify the number of compile units is correct. uint32_t NumCUs = DwarfContext->getNumCompileUnits(); EXPECT_EQ(NumCUs, 1u); - DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0); + DWARFCompileUnit *U = + cast(DwarfContext->getUnitAtIndex(0)); // Get the compile unit DIE is valid. auto CUDie = U->getUnitDIE(false); @@ -1222,7 +1228,8 @@ // Verify the number of compile units is correct. uint32_t NumCUs = DwarfContext->getNumCompileUnits(); EXPECT_EQ(NumCUs, 1u); - DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0); + DWARFCompileUnit *U = + cast(DwarfContext->getUnitAtIndex(0)); // Get the compile unit DIE is valid. auto CUDie = U->getUnitDIE(false); @@ -1284,7 +1291,8 @@ // Verify the number of compile units is correct. uint32_t NumCUs = DwarfContext->getNumCompileUnits(); EXPECT_EQ(NumCUs, 1u); - DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0); + DWARFCompileUnit *U = + cast(DwarfContext->getUnitAtIndex(0)); // Get the compile unit DIE is valid. auto CUDie = U->getUnitDIE(false); @@ -1331,7 +1339,8 @@ // Verify the number of compile units is correct. uint32_t NumCUs = DwarfContext->getNumCompileUnits(); EXPECT_EQ(NumCUs, 1u); - DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0); + DWARFCompileUnit *U = + cast(DwarfContext->getUnitAtIndex(0)); // Get the compile unit DIE is valid. auto CUDie = U->getUnitDIE(false); @@ -1399,7 +1408,8 @@ // Verify the number of compile units is correct. uint32_t NumCUs = DwarfContext->getNumCompileUnits(); EXPECT_EQ(NumCUs, 1u); - DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0); + DWARFCompileUnit *U = + cast(DwarfContext->getUnitAtIndex(0)); // Get the compile unit DIE is valid. auto CUDie = U->getUnitDIE(false); @@ -1606,7 +1616,8 @@ // Verify the number of compile units is correct. uint32_t NumCUs = DwarfContext->getNumCompileUnits(); EXPECT_EQ(NumCUs, 1u); - DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0); + DWARFCompileUnit *U = + cast(DwarfContext->getUnitAtIndex(0)); // Get the compile unit DIE is valid. auto CUDie = U->getUnitDIE(false); @@ -1665,7 +1676,8 @@ auto Obj = object::ObjectFile::createObjectFile(FileBuffer); EXPECT_TRUE((bool)Obj); std::unique_ptr DwarfContext = DWARFContext::create(**Obj); - DWARFCompileUnit *U = DwarfContext->getCompileUnitAtIndex(0); + DWARFCompileUnit *U = + cast(DwarfContext->getUnitAtIndex(0)); EXPECT_TRUE((bool)U); const auto *Abbrevs = U->getAbbreviations(); Index: llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp =================================================================== --- llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp +++ llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp @@ -129,8 +129,8 @@ Error Unrecoverable; std::function RecordUnrecoverable; - SmallVector, 2> CUs; - std::deque> TUs; + SmallVector, 2> CUs; + std::deque TUs; }; // Fixtures must derive from "Test", but parameterised fixtures from