llvm.org GIT mirror llvm / 81becb7
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 Rafael Espindola 5 years ago
9 changed file(s) with 15 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
123123 virtual ~DIContext();
124124
125125 /// getDWARFContext - get a context for binary DWARF data.
126 static DIContext *getDWARFContext(object::ObjectFile *);
126 static DIContext *getDWARFContext(object::ObjectFile &);
127127
128128 virtual void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All) = 0;
129129
1212
1313 DIContext::~DIContext() {}
1414
15 DIContext *DIContext::getDWARFContext(object::ObjectFile *Obj) {
15 DIContext *DIContext::getDWARFContext(object::ObjectFile &Obj) {
1616 return new DWARFContextInMemory(Obj);
1717 }
620620 return true;
621621 }
622622
623 DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj)
624 : IsLittleEndian(Obj->isLittleEndian()),
625 AddressSize(Obj->getBytesInAddress()) {
626 for (const SectionRef &Section : Obj->sections()) {
623 DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile &Obj)
624 : IsLittleEndian(Obj.isLittleEndian()),
625 AddressSize(Obj.getBytesInAddress()) {
626 for (const SectionRef &Section : Obj.sections()) {
627627 StringRef name;
628628 Section.getName(name);
629629 StringRef data;
686686 }
687687
688688 section_iterator RelocatedSection = Section.getRelocatedSection();
689 if (RelocatedSection == Obj->section_end())
689 if (RelocatedSection == Obj.section_end())
690690 continue;
691691
692692 StringRef RelSecName;
723723 Reloc.getType(Type);
724724 uint64_t SymAddr = 0;
725725 // ELF relocations may need the symbol address
726 if (Obj->isELF()) {
726 if (Obj.isELF()) {
727727 object::symbol_iterator Sym = Reloc.getSymbol();
728728 Sym->getAddress(SymAddr);
729729 }
730730
731 object::RelocVisitor V(Obj->getFileFormatName());
731 object::RelocVisitor V(Obj.getFileFormatName());
732732 // The section address is always 0 for debug sections.
733733 object::RelocToApply R(V.visit(Type, Reloc, 0, SymAddr));
734734 if (V.error()) {
244244 SmallVector, 4> UncompressedSections;
245245
246246 public:
247 DWARFContextInMemory(object::ObjectFile *);
247 DWARFContextInMemory(object::ObjectFile &);
248248 bool isLittleEndian() const override { return IsLittleEndian; }
249249 uint8_t getAddressSize() const override { return AddressSize; }
250250 const Section &getInfoSection() override { return InfoSection; }
236236
237237 DWARFUnit::DWOHolder::DWOHolder(object::ObjectFile *DWOFile)
238238 : DWOFile(DWOFile),
239 DWOContext(cast(DIContext::getDWARFContext(DWOFile))),
239 DWOContext(cast(DIContext::getDWARFContext(*DWOFile))),
240240 DWOU(nullptr) {
241241 if (DWOContext->getNumDWOCompileUnits() > 0)
242242 DWOU = DWOContext->getDWOCompileUnitAtIndex(0);
8181 }
8282 std::unique_ptr Obj = std::move(ObjOrErr.get());
8383
84 std::unique_ptr DICtx(DIContext::getDWARFContext(Obj.get()));
84 std::unique_ptr DICtx(DIContext::getDWARFContext(*Obj));
8585
8686 outs() << Filename
8787 << ":\tfile format " << Obj->getFileFormatName() << "\n\n";
297297 }
298298
299299 // Setup the DIContext
300 diContext.reset(DIContext::getDWARFContext(DbgObj));
300 diContext.reset(DIContext::getDWARFContext(*DbgObj));
301301 }
302302
303303 for (unsigned SectIdx = 0; SectIdx != Sections.size(); SectIdx++) {
212212 Dyld.resolveRelocations();
213213
214214 std::unique_ptr Context(
215 DIContext::getDWARFContext(LoadedObject->getObjectFile()));
215 DIContext::getDWARFContext(*LoadedObject->getObjectFile()));
216216
217217 // Use symbol info to iterate functions in the object.
218218 for (object::symbol_iterator I = LoadedObject->begin_symbols(),
387387 Modules.insert(make_pair(ModuleName, (ModuleInfo *)nullptr));
388388 return nullptr;
389389 }
390 DIContext *Context = DIContext::getDWARFContext(DbgObj);
390 DIContext *Context = DIContext::getDWARFContext(*DbgObj);
391391 assert(Context);
392392 ModuleInfo *Info = new ModuleInfo(Obj, Context);
393393 Modules.insert(make_pair(ModuleName, Info));