Use a reference instead of a pointer.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 31 Jul 2014 20:19:36 +0000 (20:19 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 31 Jul 2014 20:19:36 +0000 (20:19 +0000)
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
lib/DebugInfo/DIContext.cpp
lib/DebugInfo/DWARFContext.cpp
lib/DebugInfo/DWARFContext.h
lib/DebugInfo/DWARFUnit.cpp
tools/llvm-dwarfdump/llvm-dwarfdump.cpp
tools/llvm-objdump/MachODump.cpp
tools/llvm-rtdyld/llvm-rtdyld.cpp
tools/llvm-symbolizer/LLVMSymbolize.cpp

index c1aba01fbf75cb25bd58c3f5490c4f21bae2531b..6fba4f956ce9996e11c683c4d184bd379ad6a9d9 100644 (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;
 
index 49a44097d3e22a2e3e06bcf11139aec03302e9d3..29ef8f29f14713ef41fdee07e3eb1e17d78d4d97 100644 (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);
 }
index 3961905f65822a05d35447d13880d1732a411a5b..fc8d93dce3d0c8a5fde50f532e1f85e3be53da8c 100644 (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()) {
index 6d1ae921cec541db3c24e7b4b9123e498172e5d3..6e1e2852c23400c2ba371676fd1f721af6d6ea35 100644 (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; }
index 4ec3bdd5823a28cc981640f401276958d4b5cbfb..197d347090d5ca479ac654419874a66ed153a805 100644 (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);
index 414205a3c2aa4dab18629fec61d074693213bbdd..33bb766f200f38f701a6ba68616af7e33aab0d23 100644 (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";
index a999110cb3cd2c995ce87b645dbf1e81e6849686..1c893ea3fad94f0364f02013ce5bce3d2108aa74 100644 (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++) {
index f0c365dd4810aba2abc7f755293cab56f318cdf1..9de4d9e0a7da3660f9224056c82ccaeea700d09d 100644 (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(),
index 630f629b9a4ec8acefd15097e7eaed152817cd0c..7c4743b5dfb925a36e59ba4ee00274da969a14dc 100644 (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));