diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-08-23 06:56:01 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-08-23 06:56:01 +0000 |
commit | eb0c179b5688177c1ab5f52a8c0338459e97606e (patch) | |
tree | 2bf3afdfc3f8c32bec38e6114a1d88451066b8bb /lib/DebugInfo/DWARFContext.cpp | |
parent | 1f2c399bdb17b30217c8f9d900bde706a160bb35 (diff) | |
download | llvm-eb0c179b5688177c1ab5f52a8c0338459e97606e.tar.gz llvm-eb0c179b5688177c1ab5f52a8c0338459e97606e.tar.bz2 llvm-eb0c179b5688177c1ab5f52a8c0338459e97606e.tar.xz |
Make DWARFCompileUnit non-copyable
Summary:
This is a part of D1164. DWARFCompileUnit is not that lightweight
to copy it around, and we want it to own corresponding .dwo compile unit
eventually.
Reviewers: echristo
Reviewed By: echristo
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1298
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo/DWARFContext.cpp')
-rw-r--r-- | lib/DebugInfo/DWARFContext.cpp | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/lib/DebugInfo/DWARFContext.cpp b/lib/DebugInfo/DWARFContext.cpp index 51ad64581c..baf2bb5b57 100644 --- a/lib/DebugInfo/DWARFContext.cpp +++ b/lib/DebugInfo/DWARFContext.cpp @@ -23,6 +23,11 @@ using namespace object; typedef DWARFDebugLine::LineTable DWARFLineTable; +DWARFContext::~DWARFContext() { + DeleteContainerPointers(CUs); + DeleteContainerPointers(DWOCUs); +} + void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType) { if (DumpType == DIDT_All || DumpType == DIDT_Abbrev) { OS << ".debug_abbrev contents:\n"; @@ -249,18 +254,15 @@ void DWARFContext::parseCompileUnits() { const DataExtractor &DIData = DataExtractor(getInfoSection(), isLittleEndian(), 0); while (DIData.isValidOffset(offset)) { - CUs.push_back(DWARFCompileUnit(getDebugAbbrev(), getInfoSection(), - getAbbrevSection(), getRangeSection(), - getStringSection(), StringRef(), - getAddrSection(), - &infoRelocMap(), - isLittleEndian())); - if (!CUs.back().extract(DIData, &offset)) { - CUs.pop_back(); + OwningPtr<DWARFCompileUnit> CU(new DWARFCompileUnit( + getDebugAbbrev(), getInfoSection(), getAbbrevSection(), + getRangeSection(), getStringSection(), StringRef(), getAddrSection(), + &infoRelocMap(), isLittleEndian())); + if (!CU->extract(DIData, &offset)) { break; } - - offset = CUs.back().getNextCompileUnitOffset(); + CUs.push_back(CU.take()); + offset = CUs.back()->getNextCompileUnitOffset(); } } @@ -269,34 +271,30 @@ void DWARFContext::parseDWOCompileUnits() { const DataExtractor &DIData = DataExtractor(getInfoDWOSection(), isLittleEndian(), 0); while (DIData.isValidOffset(offset)) { - DWOCUs.push_back(DWARFCompileUnit(getDebugAbbrevDWO(), getInfoDWOSection(), - getAbbrevDWOSection(), - getRangeDWOSection(), - getStringDWOSection(), - getStringOffsetDWOSection(), - getAddrSection(), - &infoDWORelocMap(), - isLittleEndian())); - if (!DWOCUs.back().extract(DIData, &offset)) { - DWOCUs.pop_back(); + OwningPtr<DWARFCompileUnit> DWOCU(new DWARFCompileUnit( + getDebugAbbrevDWO(), getInfoDWOSection(), getAbbrevDWOSection(), + getRangeDWOSection(), getStringDWOSection(), + getStringOffsetDWOSection(), getAddrSection(), &infoDWORelocMap(), + isLittleEndian())); + if (!DWOCU->extract(DIData, &offset)) { break; } - - offset = DWOCUs.back().getNextCompileUnitOffset(); + DWOCUs.push_back(DWOCU.take()); + offset = DWOCUs.back()->getNextCompileUnitOffset(); } } namespace { struct OffsetComparator { - bool operator()(const DWARFCompileUnit &LHS, - const DWARFCompileUnit &RHS) const { - return LHS.getOffset() < RHS.getOffset(); + bool operator()(const DWARFCompileUnit *LHS, + const DWARFCompileUnit *RHS) const { + return LHS->getOffset() < RHS->getOffset(); } - bool operator()(const DWARFCompileUnit &LHS, uint32_t RHS) const { - return LHS.getOffset() < RHS; + bool operator()(const DWARFCompileUnit *LHS, uint32_t RHS) const { + return LHS->getOffset() < RHS; } - bool operator()(uint32_t LHS, const DWARFCompileUnit &RHS) const { - return LHS < RHS.getOffset(); + bool operator()(uint32_t LHS, const DWARFCompileUnit *RHS) const { + return LHS < RHS->getOffset(); } }; } @@ -305,10 +303,11 @@ DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) { if (CUs.empty()) parseCompileUnits(); - DWARFCompileUnit *CU = std::lower_bound(CUs.begin(), CUs.end(), Offset, - OffsetComparator()); - if (CU != CUs.end()) - return &*CU; + DWARFCompileUnit **CU = + std::lower_bound(CUs.begin(), CUs.end(), Offset, OffsetComparator()); + if (CU != CUs.end()) { + return *CU; + } return 0; } |