From 81becb73abf0d4f39adf73fe6a35b1c30af70231 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 31 Jul 2014 20:19:36 +0000 Subject: [PATCH] Use a reference instead of a pointer. This makes using a std::unique_ptr in the caller more convenient. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214433 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DIContext.h | 2 +- lib/DebugInfo/DIContext.cpp | 2 +- lib/DebugInfo/DWARFContext.cpp | 14 +++++++------- lib/DebugInfo/DWARFContext.h | 2 +- lib/DebugInfo/DWARFUnit.cpp | 2 +- tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 2 +- tools/llvm-objdump/MachODump.cpp | 2 +- tools/llvm-rtdyld/llvm-rtdyld.cpp | 2 +- tools/llvm-symbolizer/LLVMSymbolize.cpp | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h index c1aba01fbf7..6fba4f956ce 100644 --- a/include/llvm/DebugInfo/DIContext.h +++ b/include/llvm/DebugInfo/DIContext.h @@ -124,7 +124,7 @@ public: virtual ~DIContext(); /// getDWARFContext - get a context for binary DWARF data. - static DIContext *getDWARFContext(object::ObjectFile *); + static DIContext *getDWARFContext(object::ObjectFile &); virtual void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All) = 0; diff --git a/lib/DebugInfo/DIContext.cpp b/lib/DebugInfo/DIContext.cpp index 49a44097d3e..29ef8f29f14 100644 --- a/lib/DebugInfo/DIContext.cpp +++ b/lib/DebugInfo/DIContext.cpp @@ -13,6 +13,6 @@ using namespace llvm; DIContext::~DIContext() {} -DIContext *DIContext::getDWARFContext(object::ObjectFile *Obj) { +DIContext *DIContext::getDWARFContext(object::ObjectFile &Obj) { return new DWARFContextInMemory(Obj); } diff --git a/lib/DebugInfo/DWARFContext.cpp b/lib/DebugInfo/DWARFContext.cpp index 3961905f658..fc8d93dce3d 100644 --- a/lib/DebugInfo/DWARFContext.cpp +++ b/lib/DebugInfo/DWARFContext.cpp @@ -621,10 +621,10 @@ static bool consumeCompressedDebugSectionHeader(StringRef &data, return true; } -DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) - : IsLittleEndian(Obj->isLittleEndian()), - AddressSize(Obj->getBytesInAddress()) { - for (const SectionRef &Section : Obj->sections()) { +DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile &Obj) + : IsLittleEndian(Obj.isLittleEndian()), + AddressSize(Obj.getBytesInAddress()) { + for (const SectionRef &Section : Obj.sections()) { StringRef name; Section.getName(name); StringRef data; @@ -687,7 +687,7 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) } section_iterator RelocatedSection = Section.getRelocatedSection(); - if (RelocatedSection == Obj->section_end()) + if (RelocatedSection == Obj.section_end()) continue; StringRef RelSecName; @@ -724,12 +724,12 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) Reloc.getType(Type); uint64_t SymAddr = 0; // ELF relocations may need the symbol address - if (Obj->isELF()) { + if (Obj.isELF()) { object::symbol_iterator Sym = Reloc.getSymbol(); Sym->getAddress(SymAddr); } - object::RelocVisitor V(Obj->getFileFormatName()); + object::RelocVisitor V(Obj.getFileFormatName()); // The section address is always 0 for debug sections. object::RelocToApply R(V.visit(Type, Reloc, 0, SymAddr)); if (V.error()) { diff --git a/lib/DebugInfo/DWARFContext.h b/lib/DebugInfo/DWARFContext.h index 6d1ae921cec..6e1e2852c23 100644 --- a/lib/DebugInfo/DWARFContext.h +++ b/lib/DebugInfo/DWARFContext.h @@ -245,7 +245,7 @@ class DWARFContextInMemory : public DWARFContext { SmallVector, 4> UncompressedSections; public: - DWARFContextInMemory(object::ObjectFile *); + DWARFContextInMemory(object::ObjectFile &); bool isLittleEndian() const override { return IsLittleEndian; } uint8_t getAddressSize() const override { return AddressSize; } const Section &getInfoSection() override { return InfoSection; } diff --git a/lib/DebugInfo/DWARFUnit.cpp b/lib/DebugInfo/DWARFUnit.cpp index 4ec3bdd5823..197d347090d 100644 --- a/lib/DebugInfo/DWARFUnit.cpp +++ b/lib/DebugInfo/DWARFUnit.cpp @@ -237,7 +237,7 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) { DWARFUnit::DWOHolder::DWOHolder(object::ObjectFile *DWOFile) : DWOFile(DWOFile), - DWOContext(cast(DIContext::getDWARFContext(DWOFile))), + DWOContext(cast(DIContext::getDWARFContext(*DWOFile))), DWOU(nullptr) { if (DWOContext->getNumDWOCompileUnits() > 0) DWOU = DWOContext->getDWOCompileUnitAtIndex(0); diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 414205a3c2a..33bb766f200 100644 --- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -82,7 +82,7 @@ static void DumpInput(const StringRef &Filename) { } std::unique_ptr Obj = std::move(ObjOrErr.get()); - std::unique_ptr DICtx(DIContext::getDWARFContext(Obj.get())); + std::unique_ptr DICtx(DIContext::getDWARFContext(*Obj)); outs() << Filename << ":\tfile format " << Obj->getFileFormatName() << "\n\n"; diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index a999110cb3c..1c893ea3fad 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -298,7 +298,7 @@ static void DisassembleInputMachO2(StringRef Filename, } // Setup the DIContext - diContext.reset(DIContext::getDWARFContext(DbgObj)); + diContext.reset(DIContext::getDWARFContext(*DbgObj)); } for (unsigned SectIdx = 0; SectIdx != Sections.size(); SectIdx++) { diff --git a/tools/llvm-rtdyld/llvm-rtdyld.cpp b/tools/llvm-rtdyld/llvm-rtdyld.cpp index f0c365dd481..9de4d9e0a7d 100644 --- a/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -213,7 +213,7 @@ static int printLineInfoForInput() { Dyld.resolveRelocations(); std::unique_ptr Context( - DIContext::getDWARFContext(LoadedObject->getObjectFile())); + DIContext::getDWARFContext(*LoadedObject->getObjectFile())); // Use symbol info to iterate functions in the object. for (object::symbol_iterator I = LoadedObject->begin_symbols(), diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp index 630f629b9a4..7c4743b5dfb 100644 --- a/tools/llvm-symbolizer/LLVMSymbolize.cpp +++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp @@ -388,7 +388,7 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) { Modules.insert(make_pair(ModuleName, (ModuleInfo *)nullptr)); return nullptr; } - DIContext *Context = DIContext::getDWARFContext(DbgObj); + DIContext *Context = DIContext::getDWARFContext(*DbgObj); assert(Context); ModuleInfo *Info = new ModuleInfo(Obj, Context); Modules.insert(make_pair(ModuleName, Info)); -- 2.34.1