[llvm] r285309 - Switch all DWARF variables for tags, attributes and forms over to use the llvm::dwarf enumerations instead of using raw uint16_t values. This allows easier debugging as users can see the values of the enumerations in the variables view that will show the enumeration string instead of just a number.

Greg Clayton via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 27 09:32:05 PDT 2016


Author: gclayton
Date: Thu Oct 27 11:32:04 2016
New Revision: 285309

URL: http://llvm.org/viewvc/llvm-project?rev=285309&view=rev
Log:
Switch all DWARF variables for tags, attributes and forms over to use the llvm::dwarf enumerations instead of using raw uint16_t values. This allows easier debugging as users can see the values of the enumerations in the variables view that will show the enumeration string instead of just a number.

https://reviews.llvm.org/D26013


Modified:
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
    llvm/trunk/include/llvm/Support/Dwarf.def
    llvm/trunk/include/llvm/Support/Dwarf.h
    llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
    llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
    llvm/trunk/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h Thu Oct 27 11:32:04 2016
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/DataExtractor.h"
+#include "llvm/Support/Dwarf.h"
 
 namespace llvm {
 
@@ -20,16 +21,16 @@ class raw_ostream;
 class DWARFAbbreviationDeclaration {
 public:
   struct AttributeSpec {
-    AttributeSpec(uint16_t Attr, uint16_t Form) : Attr(Attr), Form(Form) {}
-    uint16_t Attr;
-    uint16_t Form;
+    AttributeSpec(dwarf::Attribute A, dwarf::Form F) : Attr(A), Form(F) {}
+    dwarf::Attribute Attr;
+    dwarf::Form Form;
   };
   typedef SmallVector<AttributeSpec, 8> AttributeSpecVector;
 
   DWARFAbbreviationDeclaration();
 
   uint32_t getCode() const { return Code; }
-  uint32_t getTag() const { return Tag; }
+  dwarf::Tag getTag() const { return Tag; }
   bool hasChildren() const { return HasChildren; }
 
   typedef iterator_range<AttributeSpecVector::const_iterator>
@@ -39,11 +40,13 @@ public:
     return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end());
   }
 
-  uint16_t getFormByIndex(uint32_t idx) const {
-    return idx < AttributeSpecs.size() ? AttributeSpecs[idx].Form : 0;
+  dwarf::Form getFormByIndex(uint32_t idx) const {
+    if (idx < AttributeSpecs.size())
+      return AttributeSpecs[idx].Form;
+    return dwarf::Form(0);
   }
 
-  uint32_t findAttributeIndex(uint16_t attr) const;
+  uint32_t findAttributeIndex(dwarf::Attribute attr) const;
   bool extract(DataExtractor Data, uint32_t* OffsetPtr);
   void dump(raw_ostream &OS) const;
 
@@ -51,7 +54,7 @@ private:
   void clear();
 
   uint32_t Code;
-  uint32_t Tag;
+  dwarf::Tag Tag;
   bool HasChildren;
 
   AttributeSpecVector AttributeSpecs;

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h Thu Oct 27 11:32:04 2016
@@ -13,6 +13,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
+#include "llvm/Support/Dwarf.h"
 #include <cstdint>
 
 namespace llvm {
@@ -30,7 +31,7 @@ class DWARFAcceleratorTable {
 
   struct HeaderData {
     typedef uint16_t AtomType;
-    typedef uint16_t Form;
+    typedef dwarf::Form Form;
     uint32_t DIEOffsetBase;
     SmallVector<std::pair<AtomType, Form>, 3> Atoms;
   };

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h Thu Oct 27 11:32:04 2016
@@ -41,7 +41,8 @@ public:
   void dump(raw_ostream &OS, DWARFUnit *u, unsigned recurseDepth,
             unsigned indent = 0) const;
   void dumpAttribute(raw_ostream &OS, DWARFUnit *u, uint32_t *offset_ptr,
-                     uint16_t attr, uint16_t form, unsigned indent = 0) const;
+                     dwarf::Attribute attr, dwarf::Form form, 
+                     unsigned indent = 0) const;
 
   /// Extracts a debug info entry, which is a child of a given unit,
   /// starting at a given offset. If DIE can't be extracted, returns false and
@@ -86,24 +87,27 @@ public:
     return AbbrevDecl;
   }
 
-  bool getAttributeValue(const DWARFUnit *U, const uint16_t Attr,
+  bool getAttributeValue(const DWARFUnit *U, dwarf::Attribute Attr,
                          DWARFFormValue &FormValue) const;
 
-  const char *getAttributeValueAsString(const DWARFUnit *U, const uint16_t Attr,
+  const char *getAttributeValueAsString(const DWARFUnit *U, 
+                                        dwarf::Attribute Attr,
                                         const char *FailValue) const;
 
-  uint64_t getAttributeValueAsAddress(const DWARFUnit *U, const uint16_t Attr,
+  uint64_t getAttributeValueAsAddress(const DWARFUnit *U, 
+                                      dwarf::Attribute Attr,
                                       uint64_t FailValue) const;
 
   uint64_t getAttributeValueAsUnsignedConstant(const DWARFUnit *U,
-                                               const uint16_t Attr,
+                                               dwarf::Attribute Attr,
                                                uint64_t FailValue) const;
 
-  uint64_t getAttributeValueAsReference(const DWARFUnit *U, const uint16_t Attr,
+  uint64_t getAttributeValueAsReference(const DWARFUnit *U, 
+                                        dwarf::Attribute Attr,
                                         uint64_t FailValue) const;
 
   uint64_t getAttributeValueAsSectionOffset(const DWARFUnit *U,
-                                            const uint16_t Attr,
+                                            dwarf::Attribute Attr,
                                             uint64_t FailValue) const;
 
   uint64_t getRangesBaseAttribute(const DWARFUnit *U, uint64_t FailValue) const;

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h Thu Oct 27 11:32:04 2016
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/DataExtractor.h"
+#include "llvm/Support/Dwarf.h"
 
 namespace llvm {
 
@@ -48,12 +49,12 @@ private:
     const uint8_t* data;
   };
 
-  uint16_t Form;   // Form for this value.
+  dwarf::Form Form;   // Form for this value.
   ValueType Value; // Contains all data for the form.
 
 public:
-  DWARFFormValue(uint16_t Form = 0) : Form(Form) {}
-  uint16_t getForm() const { return Form; }
+  DWARFFormValue(dwarf::Form F = dwarf::Form(0)) : Form(F) {}
+  dwarf::Form getForm() const { return Form; }
   bool isFormClass(FormClass FC) const;
 
   void dump(raw_ostream &OS, const DWARFUnit *U) const;
@@ -82,9 +83,9 @@ public:
 
   bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr,
                  const DWARFUnit *u) const;
-  static bool skipValue(uint16_t form, DataExtractor debug_info_data,
+  static bool skipValue(dwarf::Form form, DataExtractor debug_info_data,
                         uint32_t *offset_ptr, const DWARFUnit *u);
-  static bool skipValue(uint16_t form, DataExtractor debug_info_data,
+  static bool skipValue(dwarf::Form form, DataExtractor debug_info_data,
                         uint32_t *offset_ptr, uint16_t Version,
                         uint8_t AddrSize);
 

Modified: llvm/trunk/include/llvm/Support/Dwarf.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Dwarf.def?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Dwarf.def (original)
+++ llvm/trunk/include/llvm/Support/Dwarf.def Thu Oct 27 11:32:04 2016
@@ -42,7 +42,7 @@
 #define HANDLE_DW_CC(ID, NAME)
 #endif
 
-
+HANDLE_DW_TAG(0x0000, null)
 HANDLE_DW_TAG(0x0001, array_type)
 HANDLE_DW_TAG(0x0002, class_type)
 HANDLE_DW_TAG(0x0003, entry_point)

Modified: llvm/trunk/include/llvm/Support/Dwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Dwarf.h?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Dwarf.h (original)
+++ llvm/trunk/include/llvm/Support/Dwarf.h Thu Oct 27 11:32:04 2016
@@ -312,7 +312,8 @@ enum Form : uint16_t {
   DW_FORM_exprloc = 0x18,
   DW_FORM_flag_present = 0x19,
   DW_FORM_ref_sig8 = 0x20,
-
+  
+  DW_FORM_lo_user = 0x1f00,
   // Extensions for Fission proposal
   DW_FORM_GNU_addr_index = 0x1f01,
   DW_FORM_GNU_str_index = 0x1f02,

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp Thu Oct 27 11:32:04 2016
@@ -16,7 +16,7 @@ using namespace dwarf;
 
 void DWARFAbbreviationDeclaration::clear() {
   Code = 0;
-  Tag = 0;
+  Tag = DW_TAG_null;
   HasChildren = false;
   AttributeSpecs.clear();
 }
@@ -26,37 +26,38 @@ DWARFAbbreviationDeclaration::DWARFAbbre
 }
 
 bool
-DWARFAbbreviationDeclaration::extract(DataExtractor Data, uint32_t* OffsetPtr) {
+DWARFAbbreviationDeclaration::extract(DataExtractor Data, 
+                                      uint32_t* OffsetPtr) {
   clear();
   Code = Data.getULEB128(OffsetPtr);
   if (Code == 0) {
     return false;
   }
-  Tag = Data.getULEB128(OffsetPtr);
+  Tag = static_cast<llvm::dwarf::Tag>(Data.getULEB128(OffsetPtr));
+  if (Tag == DW_TAG_null) {
+    clear();
+    return false;
+  }
   uint8_t ChildrenByte = Data.getU8(OffsetPtr);
   HasChildren = (ChildrenByte == DW_CHILDREN_yes);
 
   while (true) {
-    uint32_t CurOffset = *OffsetPtr;
-    uint16_t Attr = Data.getULEB128(OffsetPtr);
-    if (CurOffset == *OffsetPtr) {
-      clear();
-      return false;
-    }
-    CurOffset = *OffsetPtr;
-    uint16_t Form = Data.getULEB128(OffsetPtr);
-    if (CurOffset == *OffsetPtr) {
+    auto A = static_cast<Attribute>(Data.getULEB128(OffsetPtr));
+    auto F = static_cast<Form>(Data.getULEB128(OffsetPtr));
+    if (A && F) {
+        AttributeSpecs.push_back(AttributeSpec(A, F));
+    } else if (A == 0 && F == 0) {
+      // We successfully reached the end of this abbreviation declaration
+      // since both attribute and form are zero.
+      break;
+    } else {
+      // Attribute and form pairs must either both be non-zero, in which case
+      // they are added to the abbreviation declaration, or both be zero to
+      // terminate the abbrevation declaration. In this case only one was
+      // zero which is an error.
       clear();
       return false;
     }
-    if (Attr == 0 && Form == 0)
-      break;
-    AttributeSpecs.push_back(AttributeSpec(Attr, Form));
-  }
-
-  if (Tag == 0) {
-    clear();
-    return false;
   }
   return true;
 }
@@ -88,7 +89,7 @@ void DWARFAbbreviationDeclaration::dump(
 }
 
 uint32_t
-DWARFAbbreviationDeclaration::findAttributeIndex(uint16_t attr) const {
+DWARFAbbreviationDeclaration::findAttributeIndex(dwarf::Attribute attr) const {
   for (uint32_t i = 0, e = AttributeSpecs.size(); i != e; ++i) {
     if (AttributeSpecs[i].Attr == attr)
       return i;

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp Thu Oct 27 11:32:04 2016
@@ -39,7 +39,7 @@ bool DWARFAcceleratorTable::extract() {
 
   for (unsigned i = 0; i < NumAtoms; ++i) {
     uint16_t AtomType = AccelSection.getU16(&Offset);
-    uint16_t AtomForm = AccelSection.getU16(&Offset);
+    auto AtomForm = static_cast<dwarf::Form>(AccelSection.getU16(&Offset));
     HdrData.Atoms.push_back(std::make_pair(AtomType, AtomForm));
   }
 

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp Thu Oct 27 11:32:04 2016
@@ -112,7 +112,8 @@ static void dumpRanges(raw_ostream &OS,
 void DWARFDebugInfoEntryMinimal::dumpAttribute(raw_ostream &OS,
                                                DWARFUnit *u,
                                                uint32_t *offset_ptr,
-                                               uint16_t attr, uint16_t form,
+                                               dwarf::Attribute attr, 
+                                               dwarf::Form form,
                                                unsigned indent) const {
   const char BaseIndent[] = "            ";
   OS << BaseIndent;
@@ -207,7 +208,7 @@ bool DWARFDebugInfoEntryMinimal::extract
 
   // Skip all data in the .debug_info for the attributes
   for (const auto &AttrSpec : AbbrevDecl->attributes()) {
-    uint16_t Form = AttrSpec.Form;
+    auto Form = AttrSpec.Form;
 
     uint8_t FixedFormSize =
         (Form < FixedFormSizes.size()) ? FixedFormSizes[Form] : 0;
@@ -232,8 +233,8 @@ bool DWARFDebugInfoEntryMinimal::isSubro
          Tag == DW_TAG_inlined_subroutine;
 }
 
-bool DWARFDebugInfoEntryMinimal::getAttributeValue(
-    const DWARFUnit *U, const uint16_t Attr, DWARFFormValue &FormValue) const {
+bool DWARFDebugInfoEntryMinimal::getAttributeValue(const DWARFUnit *U, 
+    dwarf::Attribute Attr, DWARFFormValue &FormValue) const {
   if (!AbbrevDecl)
     return false;
 
@@ -258,7 +259,8 @@ bool DWARFDebugInfoEntryMinimal::getAttr
 }
 
 const char *DWARFDebugInfoEntryMinimal::getAttributeValueAsString(
-    const DWARFUnit *U, const uint16_t Attr, const char *FailValue) const {
+    const DWARFUnit *U, dwarf::Attribute Attr, 
+    const char *FailValue) const {
   DWARFFormValue FormValue;
   if (!getAttributeValue(U, Attr, FormValue))
     return FailValue;
@@ -267,7 +269,8 @@ const char *DWARFDebugInfoEntryMinimal::
 }
 
 uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsAddress(
-    const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const {
+    const DWARFUnit *U, dwarf::Attribute Attr, 
+    uint64_t FailValue) const {
   DWARFFormValue FormValue;
   if (!getAttributeValue(U, Attr, FormValue))
     return FailValue;
@@ -276,7 +279,8 @@ uint64_t DWARFDebugInfoEntryMinimal::get
 }
 
 uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsUnsignedConstant(
-    const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const {
+    const DWARFUnit *U, dwarf::Attribute Attr, 
+    uint64_t FailValue) const {
   DWARFFormValue FormValue;
   if (!getAttributeValue(U, Attr, FormValue))
     return FailValue;
@@ -285,7 +289,8 @@ uint64_t DWARFDebugInfoEntryMinimal::get
 }
 
 uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsReference(
-    const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const {
+    const DWARFUnit *U, dwarf::Attribute Attr, 
+    uint64_t FailValue) const {
   DWARFFormValue FormValue;
   if (!getAttributeValue(U, Attr, FormValue))
     return FailValue;
@@ -294,7 +299,8 @@ uint64_t DWARFDebugInfoEntryMinimal::get
 }
 
 uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsSectionOffset(
-    const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const {
+    const DWARFUnit *U, dwarf::Attribute Attr, 
+    uint64_t FailValue) const {
   DWARFFormValue FormValue;
   if (!getAttributeValue(U, Attr, FormValue))
     return FailValue;

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp Thu Oct 27 11:32:04 2016
@@ -123,6 +123,8 @@ bool DWARFFormValue::isFormClass(DWARFFo
   case DW_FORM_GNU_str_index:
   case DW_FORM_GNU_strp_alt:
     return (FC == FC_String);
+  default:
+    break;
   }
   // In DWARF3 DW_FORM_data4 and DW_FORM_data8 served also as a section offset.
   // Don't check for DWARF version here, as some producers may still do this
@@ -208,7 +210,7 @@ bool DWARFFormValue::extractValue(DataEx
       Value.cstr = data.getCStr(offset_ptr);
       break;
     case DW_FORM_indirect:
-      Form = data.getULEB128(offset_ptr);
+      Form = static_cast<dwarf::Form>(data.getULEB128(offset_ptr));
       indirect = true;
       break;
     case DW_FORM_sec_offset:
@@ -259,14 +261,15 @@ DWARFFormValue::skipValue(DataExtractor
 }
 
 bool
-DWARFFormValue::skipValue(uint16_t form, DataExtractor debug_info_data,
+DWARFFormValue::skipValue(dwarf::Form form, DataExtractor debug_info_data,
                           uint32_t *offset_ptr, const DWARFUnit *cu) {
   return skipValue(form, debug_info_data, offset_ptr, cu->getVersion(),
                    cu->getAddressByteSize());
 }
-bool DWARFFormValue::skipValue(uint16_t form, DataExtractor debug_info_data,
-                               uint32_t *offset_ptr, uint16_t Version,
-                               uint8_t AddrSize) {
+bool 
+DWARFFormValue::skipValue(dwarf::Form form, DataExtractor debug_info_data,
+                          uint32_t *offset_ptr, uint16_t Version,
+                          uint8_t AddrSize) {
   bool indirect = false;
   do {
     switch (form) {
@@ -349,7 +352,7 @@ bool DWARFFormValue::skipValue(uint16_t
 
     case DW_FORM_indirect:
       indirect = true;
-      form = debug_info_data.getULEB128(offset_ptr);
+      form = static_cast<dwarf::Form>(debug_info_data.getULEB128(offset_ptr));
       break;
 
     // FIXME: 4 for DWARF32, 8 for DWARF64.

Modified: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp (original)
+++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp Thu Oct 27 11:32:04 2016
@@ -112,8 +112,8 @@ struct CompileUnitIdentifiers {
 };
 
 static Expected<const char *>
-getIndexedString(uint32_t Form, DataExtractor InfoData, uint32_t &InfoOffset,
-                 StringRef StrOffsets, StringRef Str) {
+getIndexedString(dwarf::Form Form, DataExtractor InfoData, 
+                 uint32_t &InfoOffset, StringRef StrOffsets, StringRef Str) {
   if (Form == dwarf::DW_FORM_string)
     return InfoData.getCStr(&InfoOffset);
   if (Form != dwarf::DW_FORM_GNU_str_index)
@@ -142,16 +142,16 @@ static Expected<CompileUnitIdentifiers>
 
   DataExtractor AbbrevData(Abbrev, true, 0);
   uint32_t AbbrevOffset = getCUAbbrev(Abbrev, AbbrCode);
-  uint64_t Tag = AbbrevData.getULEB128(&AbbrevOffset);
+  auto Tag = static_cast<dwarf::Tag>(AbbrevData.getULEB128(&AbbrevOffset));
   if (Tag != dwarf::DW_TAG_compile_unit)
     return make_error<DWPError>("top level DIE is not a compile unit");
   // DW_CHILDREN
   AbbrevData.getU8(&AbbrevOffset);
   uint32_t Name;
-  uint32_t Form;
+  dwarf::Form Form;
   CompileUnitIdentifiers ID;
   while ((Name = AbbrevData.getULEB128(&AbbrevOffset)) |
-             (Form = AbbrevData.getULEB128(&AbbrevOffset)) &&
+         (Form = static_cast<dwarf::Form>(AbbrevData.getULEB128(&AbbrevOffset))) &&
          (Name != 0 || Form != 0)) {
     switch (Name) {
     case dwarf::DW_AT_name: {

Modified: llvm/trunk/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp?rev=285309&r1=285308&r2=285309&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp Thu Oct 27 11:32:04 2016
@@ -33,7 +33,7 @@ TEST(DWARFFormValue, FixedFormSizes) {
   EXPECT_EQ(0U, DWARFFormValue::getFixedFormSizes(16, 2).size());
 }
 
-bool isFormClass(uint16_t Form, DWARFFormValue::FormClass FC) {
+bool isFormClass(dwarf::Form Form, DWARFFormValue::FormClass FC) {
   return DWARFFormValue(Form).isFormClass(FC);
 }
 
@@ -52,7 +52,7 @@ TEST(DWARFFormValue, FormClass) {
 }
 
 template<typename RawTypeT>
-DWARFFormValue createDataXFormValue(uint16_t Form, RawTypeT Value) {
+DWARFFormValue createDataXFormValue(dwarf::Form Form, RawTypeT Value) {
   char Raw[sizeof(RawTypeT)];
   memcpy(Raw, &Value, sizeof(RawTypeT));
   uint32_t Offset = 0;




More information about the llvm-commits mailing list