1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

Use a reference instead of a pointer.

This makes using a std::unique_ptr in the caller more convenient.

llvm-svn: 214433
This commit is contained in:
Rafael Espindola 2014-07-31 20:19:36 +00:00
parent b0d2bf534a
commit 3127847c8f
9 changed files with 15 additions and 15 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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()) {

View File

@ -245,7 +245,7 @@ class DWARFContextInMemory : public DWARFContext {
SmallVector<SmallString<32>, 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; }

View File

@ -237,7 +237,7 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
DWARFUnit::DWOHolder::DWOHolder(object::ObjectFile *DWOFile)
: DWOFile(DWOFile),
DWOContext(cast<DWARFContext>(DIContext::getDWARFContext(DWOFile))),
DWOContext(cast<DWARFContext>(DIContext::getDWARFContext(*DWOFile))),
DWOU(nullptr) {
if (DWOContext->getNumDWOCompileUnits() > 0)
DWOU = DWOContext->getDWOCompileUnitAtIndex(0);

View File

@ -82,7 +82,7 @@ static void DumpInput(const StringRef &Filename) {
}
std::unique_ptr<ObjectFile> Obj = std::move(ObjOrErr.get());
std::unique_ptr<DIContext> DICtx(DIContext::getDWARFContext(Obj.get()));
std::unique_ptr<DIContext> DICtx(DIContext::getDWARFContext(*Obj));
outs() << Filename
<< ":\tfile format " << Obj->getFileFormatName() << "\n\n";

View File

@ -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++) {

View File

@ -213,7 +213,7 @@ static int printLineInfoForInput() {
Dyld.resolveRelocations();
std::unique_ptr<DIContext> 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(),

View File

@ -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));