[llvm] r307846 - Don't expose a map in the DWARFContext interface.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 12 14:08:25 PDT 2017
Author: rafael
Date: Wed Jul 12 14:08:24 2017
New Revision: 307846
URL: http://llvm.org/viewvc/llvm-project?rev=307846&view=rev
Log:
Don't expose a map in the DWARFContext interface.
Doing so is leaking an implementation detail.
I have an implementation that uses the lld infrastructure and doesn't
use a map or object::SectionRef.
Modified:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=307846&r1=307845&r2=307846&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h Wed Jul 12 14:08:24 2017
@@ -226,11 +226,7 @@ public:
virtual bool isLittleEndian() const = 0;
virtual uint8_t getAddressSize() const = 0;
virtual const DWARFSection &getInfoSection() = 0;
-
- using TypeSectionMap = MapVector<object::SectionRef, DWARFSection,
- std::map<object::SectionRef, unsigned>>;
-
- virtual const TypeSectionMap &getTypesSections() = 0;
+ virtual void forEachTypesSections(function_ref<void(DWARFSection &)> F) = 0;
virtual StringRef getAbbrevSection() = 0;
virtual const DWARFSection &getLocSection() = 0;
virtual StringRef getARangeSection() = 0;
@@ -252,7 +248,8 @@ public:
// Sections for DWARF5 split dwarf proposal.
virtual const DWARFSection &getInfoDWOSection() = 0;
- virtual const TypeSectionMap &getTypesDWOSections() = 0;
+ virtual void
+ forEachTypesDWOSections(function_ref<void(DWARFSection &)> F) = 0;
virtual StringRef getAbbrevDWOSection() = 0;
virtual const DWARFSection &getLineDWOSection() = 0;
virtual const DWARFSection &getLocDWOSection() = 0;
@@ -294,6 +291,9 @@ enum class ErrorPolicy { Halt, Continue
class DWARFContextInMemory : public DWARFContext {
virtual void anchor();
+ using TypeSectionMap = MapVector<object::SectionRef, DWARFSection,
+ std::map<object::SectionRef, unsigned>>;
+
StringRef FileName;
bool IsLittleEndian;
uint8_t AddressSize;
@@ -363,7 +363,10 @@ public:
bool isLittleEndian() const override { return IsLittleEndian; }
uint8_t getAddressSize() const override { return AddressSize; }
const DWARFSection &getInfoSection() override { return InfoSection; }
- const TypeSectionMap &getTypesSections() override { return TypesSections; }
+ void forEachTypesSections(function_ref<void(DWARFSection &)> F) override {
+ for (auto &P : TypesSections)
+ F(P.second);
+ }
StringRef getAbbrevSection() override { return AbbrevSection; }
const DWARFSection &getLocSection() override { return LocSection; }
StringRef getARangeSection() override { return ARangeSection; }
@@ -390,8 +393,9 @@ public:
// Sections for DWARF5 split dwarf proposal.
const DWARFSection &getInfoDWOSection() override { return InfoDWOSection; }
- const TypeSectionMap &getTypesDWOSections() override {
- return TypesDWOSections;
+ void forEachTypesDWOSections(function_ref<void(DWARFSection &)> F) override {
+ for (auto &P : TypesDWOSections)
+ F(P.second);
}
StringRef getAbbrevDWOSection() override { return AbbrevDWOSection; }
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=307846&r1=307845&r2=307846&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Wed Jul 12 14:08:24 2017
@@ -591,10 +591,10 @@ void DWARFContext::parseCompileUnits() {
void DWARFContext::parseTypeUnits() {
if (!TUs.empty())
return;
- for (const auto &I : getTypesSections()) {
+ forEachTypesSections([&](const DWARFSection &S) {
TUs.emplace_back();
- TUs.back().parse(*this, I.second);
- }
+ TUs.back().parse(*this, S);
+ });
}
void DWARFContext::parseDWOCompileUnits() {
@@ -604,10 +604,10 @@ void DWARFContext::parseDWOCompileUnits(
void DWARFContext::parseDWOTypeUnits() {
if (!DWOTUs.empty())
return;
- for (const auto &I : getTypesDWOSections()) {
+ forEachTypesDWOSections([&](const DWARFSection &S) {
DWOTUs.emplace_back();
- DWOTUs.back().parseDWO(*this, I.second);
- }
+ DWOTUs.back().parseDWO(*this, S);
+ });
}
DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) {
More information about the llvm-commits
mailing list