[llvm] r214433 - Use a reference instead of a pointer.

Rafael Espindola rafael.espindola at gmail.com
Thu Jul 31 13:19:36 PDT 2014


Author: rafael
Date: Thu Jul 31 15:19:36 2014
New Revision: 214433

URL: http://llvm.org/viewvc/llvm-project?rev=214433&view=rev
Log:
Use a reference instead of a pointer.

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

Modified:
    llvm/trunk/include/llvm/DebugInfo/DIContext.h
    llvm/trunk/lib/DebugInfo/DIContext.cpp
    llvm/trunk/lib/DebugInfo/DWARFContext.cpp
    llvm/trunk/lib/DebugInfo/DWARFContext.h
    llvm/trunk/lib/DebugInfo/DWARFUnit.cpp
    llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
    llvm/trunk/tools/llvm-objdump/MachODump.cpp
    llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp
    llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/DIContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DIContext.h?rev=214433&r1=214432&r2=214433&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Thu Jul 31 15:19:36 2014
@@ -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;
 

Modified: llvm/trunk/lib/DebugInfo/DIContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DIContext.cpp?rev=214433&r1=214432&r2=214433&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DIContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DIContext.cpp Thu Jul 31 15:19:36 2014
@@ -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);
 }

Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=214433&r1=214432&r2=214433&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Thu Jul 31 15:19:36 2014
@@ -621,10 +621,10 @@ static bool consumeCompressedDebugSectio
   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::DWARFContextInMemo
     }
 
     section_iterator RelocatedSection = Section.getRelocatedSection();
-    if (RelocatedSection == Obj->section_end())
+    if (RelocatedSection == Obj.section_end())
       continue;
 
     StringRef RelSecName;
@@ -724,12 +724,12 @@ DWARFContextInMemory::DWARFContextInMemo
         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()) {

Modified: llvm/trunk/lib/DebugInfo/DWARFContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.h?rev=214433&r1=214432&r2=214433&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.h Thu Jul 31 15:19:36 2014
@@ -245,7 +245,7 @@ class DWARFContextInMemory : public DWAR
   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; }

Modified: llvm/trunk/lib/DebugInfo/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.cpp?rev=214433&r1=214432&r2=214433&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFUnit.cpp Thu Jul 31 15:19:36 2014
@@ -237,7 +237,7 @@ size_t DWARFUnit::extractDIEsIfNeeded(bo
 
 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);

Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=214433&r1=214432&r2=214433&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Thu Jul 31 15:19:36 2014
@@ -82,7 +82,7 @@ static void DumpInput(const StringRef &F
   }
   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";

Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=214433&r1=214432&r2=214433&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Thu Jul 31 15:19:36 2014
@@ -298,7 +298,7 @@ static void DisassembleInputMachO2(Strin
     }
 
     // Setup the DIContext
-    diContext.reset(DIContext::getDWARFContext(DbgObj));
+    diContext.reset(DIContext::getDWARFContext(*DbgObj));
   }
 
   for (unsigned SectIdx = 0; SectIdx != Sections.size(); SectIdx++) {

Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=214433&r1=214432&r2=214433&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original)
+++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Thu Jul 31 15:19:36 2014
@@ -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(),

Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=214433&r1=214432&r2=214433&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Thu Jul 31 15:19:36 2014
@@ -388,7 +388,7 @@ LLVMSymbolizer::getOrCreateModuleInfo(co
     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));





More information about the llvm-commits mailing list