Fixup for r167558: Store raw pointer (instead of reference) to RelocMap in DIContext...
authorAlexey Samsonov <samsonov@google.com>
Mon, 12 Nov 2012 14:25:36 +0000 (14:25 +0000)
committerAlexey Samsonov <samsonov@google.com>
Mon, 12 Nov 2012 14:25:36 +0000 (14:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167728 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/DIContext.h
lib/DebugInfo/DIContext.cpp
lib/DebugInfo/DWARFContext.h
lib/DebugInfo/DWARFFormValue.cpp
tools/llvm-dwarfdump/llvm-dwarfdump.cpp

index 26bd1f627526505accb1af6fc89f7b23691235f8..23223414bfa7e1f9b17bf4ab0b48ab250333d690 100644 (file)
@@ -109,7 +109,7 @@ public:
                                     StringRef lineSection = StringRef(),
                                     StringRef stringSection = StringRef(),
                                     StringRef rangeSection = StringRef(),
-                                    const RelocAddrMap &Map = RelocAddrMap());
+                                    const RelocAddrMap *Map = 0);
 
   virtual void dump(raw_ostream &OS) = 0;
 
index 691a92c392c285e72af6915fd1ec67688bdbb5a4..6484abcfe8291ad1f74de3f3d76f02c173ac2f59 100644 (file)
@@ -20,7 +20,7 @@ DIContext *DIContext::getDWARFContext(bool isLittleEndian,
                                       StringRef lineSection,
                                       StringRef stringSection,
                                       StringRef rangeSection,
-                                      const RelocAddrMap &Map) {
+                                      const RelocAddrMap *Map) {
   return new DWARFContextInMemory(isLittleEndian, infoSection, abbrevSection,
                                   aRangeSection, lineSection, stringSection,
                                   rangeSection, Map);
index 4001792b3d5ff72849246c2d011adb3bf983d011..d3e9470a849666d77e5e88511a163cb573cb6d77 100644 (file)
@@ -26,7 +26,7 @@ namespace llvm {
 /// methods that a concrete implementation provides.
 class DWARFContext : public DIContext {
   bool IsLittleEndian;
-  const RelocAddrMap &RelocMap;
+  const RelocAddrMap *RelocMap;
 
   SmallVector<DWARFCompileUnit, 1> CUs;
   OwningPtr<DWARFDebugAbbrev> Abbrev;
@@ -39,7 +39,7 @@ class DWARFContext : public DIContext {
   /// Read compile units from the debug_info section and store them in CUs.
   void parseCompileUnits();
 protected:
-  DWARFContext(bool isLittleEndian, const RelocAddrMap &Map) :
+  DWARFContext(bool isLittleEndian, const RelocAddrMap *Map) :
     IsLittleEndian(isLittleEndian), RelocMap(Map) {}
 public:
   virtual void dump(raw_ostream &OS);
@@ -73,7 +73,7 @@ public:
       DILineInfoSpecifier Specifier = DILineInfoSpecifier());
 
   bool isLittleEndian() const { return IsLittleEndian; }
-  const RelocAddrMap &relocMap() const { return RelocMap; }
+  const RelocAddrMap *relocMap() const { return RelocMap; }
 
   virtual StringRef getInfoSection() = 0;
   virtual StringRef getAbbrevSection() = 0;
@@ -113,7 +113,7 @@ public:
                        StringRef lineSection,
                        StringRef stringSection,
                        StringRef rangeSection,
-                       const RelocAddrMap &Map = RelocAddrMap())
+                       const RelocAddrMap *Map = 0)
     : DWARFContext(isLittleEndian, Map),
       InfoSection(infoSection),
       AbbrevSection(abbrevSection),
index fea9fd7f7d34bc45f8fca8978bfb19f09c7fa0be..b75b0c17b38b19c07265480526298be57cc79f2e 100644 (file)
@@ -100,16 +100,20 @@ DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
     switch (Form) {
     case DW_FORM_addr:
     case DW_FORM_ref_addr: {
-      RelocAddrMap::const_iterator AI
-        = cu->getContext().relocMap().find(*offset_ptr);
-      if (AI != cu->getContext().relocMap().end()) {
-        const std::pair<uint8_t, int64_t> &R = AI->second;
-        Value.uval = R.second;
-        *offset_ptr += R.first;
-      } else
+      bool InRelocMap = false;
+      if (const RelocAddrMap *RelocMap = cu->getContext().relocMap()) {
+        RelocAddrMap::const_iterator AI = RelocMap->find(*offset_ptr);
+        if (AI != RelocMap->end()) {
+          const std::pair<uint8_t, int64_t> &R = AI->second;
+          Value.uval = R.second;
+          *offset_ptr += R.first;
+          InRelocMap = true;
+        }
+      }
+      if (!InRelocMap)
         Value.uval = data.getUnsigned(offset_ptr, cu->getAddressByteSize());
-    }
       break;
+    }
     case DW_FORM_exprloc:
     case DW_FORM_block:
       Value.uval = data.getULEB128(offset_ptr);
@@ -148,13 +152,17 @@ DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
       Value.sval = data.getSLEB128(offset_ptr);
       break;
     case DW_FORM_strp: {
-      RelocAddrMap::const_iterator AI
-        = cu->getContext().relocMap().find(*offset_ptr);
-      if (AI != cu->getContext().relocMap().end()) {
-        const std::pair<uint8_t, int64_t> &R = AI->second;
-        Value.uval = R.second;
-        *offset_ptr += R.first;
-      } else
+      bool InRelocMap = false;
+      if (const RelocAddrMap *RelocMap = cu->getContext().relocMap()) {
+        RelocAddrMap::const_iterator AI = RelocMap->find(*offset_ptr);
+        if (AI != RelocMap->end()) {
+          const std::pair<uint8_t, int64_t> &R = AI->second;
+          Value.uval = R.second;
+          *offset_ptr += R.first;
+          InRelocMap = true;
+        }
+      }
+      if (!InRelocMap)
         Value.uval = data.getU32(offset_ptr);
       break;
     }
index e73300a0cd8d911ed720e23d392e8546716cab7f..c0e3491509d55baa0ed6b44c7879662573ee69c0 100644 (file)
@@ -162,7 +162,7 @@ static void DumpInput(const StringRef &Filename) {
                                                         DebugLineSection,
                                                         DebugStringSection,
                                                         DebugRangesSection,
-                                                        RelocMap));
+                                                        &RelocMap));
   if (Address == -1ULL) {
     outs() << Filename
            << ":\tfile format " << Obj->getFileFormatName() << "\n\n";