[llvm] r222436 - Make DWARFAcceleratorTable::dump() const.

Frederic Riss friss at apple.com
Thu Nov 20 08:21:11 PST 2014


Author: friss
Date: Thu Nov 20 10:21:11 2014
New Revision: 222436

URL: http://llvm.org/viewvc/llvm-project?rev=222436&view=rev
Log:
Make DWARFAcceleratorTable::dump() const.

As dump() methods  should be. To allow that, do not store the DWARFFormValue
objects used for the dump in the header data.

Per Alexey's suggestion!

Modified:
    llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.cpp
    llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.h

Modified: llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.cpp?rev=222436&r1=222435&r2=222436&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.cpp Thu Nov 20 10:21:11 2014
@@ -40,14 +40,14 @@ bool DWARFAcceleratorTable::extract() {
 
   for (unsigned i = 0; i < NumAtoms; ++i) {
     uint16_t AtomType = AccelSection.getU16(&Offset);
-    DWARFFormValue AtomForm(AccelSection.getU16(&Offset));
+    uint16_t AtomForm = AccelSection.getU16(&Offset);
     HdrData.Atoms.push_back(std::make_pair(AtomType, AtomForm));
   }
 
   return true;
 }
 
-void DWARFAcceleratorTable::dump(raw_ostream &OS) {
+void DWARFAcceleratorTable::dump(raw_ostream &OS) const {
   // Dump the header.
   OS << "Magic = " << format("0x%08x", Hdr.Magic) << '\n'
      << "Version = " << format("0x%04x", Hdr.Version) << '\n'
@@ -59,6 +59,7 @@ void DWARFAcceleratorTable::dump(raw_ost
      << "Number of atoms = " << HdrData.Atoms.size() << '\n';
 
   unsigned i = 0;
+  SmallVector<DWARFFormValue, 3> AtomForms;
   for (const auto &Atom: HdrData.Atoms) {
     OS << format("Atom[%d] Type: ", i++);
     if (const char *TypeString = dwarf::AtomTypeString(Atom.first))
@@ -66,11 +67,12 @@ void DWARFAcceleratorTable::dump(raw_ost
     else
       OS << format("DW_ATOM_Unknown_0x%x", Atom.first);
     OS << " Form: ";
-    if (const char *FormString = dwarf::FormEncodingString(Atom.second.getForm()))
+    if (const char *FormString = dwarf::FormEncodingString(Atom.second))
       OS << FormString;
     else
-      OS << format("DW_FORM_Unknown_0x%x", Atom.second.getForm());
+      OS << format("DW_FORM_Unknown_0x%x", Atom.second);
     OS << '\n';
+    AtomForms.push_back(DWARFFormValue(Atom.second));
   }
 
   // Now go through the actual tables and dump them.
@@ -114,10 +116,10 @@ void DWARFAcceleratorTable::dump(raw_ost
         for (unsigned Data = 0; Data < NumData; ++Data) {
           OS << format("    Data[%d] => ", Data);
           unsigned i = 0;
-          for (auto &Atom : HdrData.Atoms) {
+          for (auto &Atom : AtomForms) {
             OS << format("{Atom[%d]: ", i++);
-            if (Atom.second.extractValue(AccelSection, &DataOffset, nullptr))
-              Atom.second.dump(OS, nullptr);
+            if (Atom.extractValue(AccelSection, &DataOffset, nullptr))
+              Atom.dump(OS, nullptr);
             else
               OS << "Error extracting the value";
             OS << "} ";

Modified: llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.h?rev=222436&r1=222435&r2=222436&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFAcceleratorTable.h Thu Nov 20 10:21:11 2014
@@ -29,8 +29,9 @@ class DWARFAcceleratorTable {
 
   struct HeaderData {
     typedef uint16_t AtomType;
+    typedef uint16_t Form;
     uint32_t DIEOffsetBase;
-    SmallVector<std::pair<AtomType, DWARFFormValue>, 1> Atoms;
+    SmallVector<std::pair<AtomType, Form>, 3> Atoms;
   };
 
   struct Header Hdr;
@@ -44,7 +45,7 @@ public:
     : AccelSection(AccelSection), StringSection(StringSection), Relocs(Relocs) {}
 
   bool extract();
-  void dump(raw_ostream &OS);
+  void dump(raw_ostream &OS) const;
 };
 
 }





More information about the llvm-commits mailing list