[DebugInfo] Delete dead code, simplify and fix code style for some existing code...
authorAlexey Samsonov <samsonov@google.com>
Thu, 17 Oct 2013 13:28:16 +0000 (13:28 +0000)
committerAlexey Samsonov <samsonov@google.com>
Thu, 17 Oct 2013 13:28:16 +0000 (13:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192894 91177308-0d34-0410-b5e6-96231b3b80d8

lib/DebugInfo/DWARFDebugInfoEntry.cpp
lib/DebugInfo/DWARFDebugInfoEntry.h

index fd801a22c215ee040da6a1c6decd884083b6ec10..9bb49df5d1309c5cdf661a4aa8b9569b7343c436 100644 (file)
@@ -182,36 +182,29 @@ bool DWARFDebugInfoEntryMinimal::isSubroutineDIE() const {
          Tag == DW_TAG_inlined_subroutine;
 }
 
-uint32_t DWARFDebugInfoEntryMinimal::getAttributeValue(
-    const DWARFUnit *u, const uint16_t attr, DWARFFormValue &form_value,
-    uint32_t *end_attr_offset_ptr) const {
-  if (AbbrevDecl) {
-    uint32_t attr_idx = AbbrevDecl->findAttributeIndex(attr);
-
-    if (attr_idx != -1U) {
-      uint32_t offset = getOffset();
+bool DWARFDebugInfoEntryMinimal::getAttributeValue(
+    const DWARFUnit *U, const uint16_t Attr, DWARFFormValue &FormValue) const {
+  if (!AbbrevDecl)
+    return false;
 
-      DataExtractor debug_info_data = u->getDebugInfoExtractor();
+  uint32_t AttrIdx = AbbrevDecl->findAttributeIndex(Attr);
+  if (AttrIdx == -1U)
+    return false;
 
-      // Skip the abbreviation code so we are at the data for the attributes
-      debug_info_data.getULEB128(&offset);
+  DataExtractor DebugInfoData = U->getDebugInfoExtractor();
+  uint32_t DebugInfoOffset = getOffset();
 
-      uint32_t idx = 0;
-      while (idx < attr_idx)
-        DWARFFormValue::skipValue(AbbrevDecl->getFormByIndex(idx++),
-                                  debug_info_data, &offset, u);
+  // Skip the abbreviation code so we are at the data for the attributes
+  DebugInfoData.getULEB128(&DebugInfoOffset);
 
-      const uint32_t attr_offset = offset;
-      form_value = DWARFFormValue(AbbrevDecl->getFormByIndex(idx));
-      if (form_value.extractValue(debug_info_data, &offset, u)) {
-        if (end_attr_offset_ptr)
-          *end_attr_offset_ptr = offset;
-        return attr_offset;
-      }
-    }
+  // Skip preceding attribute values.
+  for (uint32_t i = 0; i < AttrIdx; ++i) {
+    DWARFFormValue::skipValue(AbbrevDecl->getFormByIndex(i),
+                              DebugInfoData, &DebugInfoOffset, U);
   }
 
-  return 0;
+  FormValue = DWARFFormValue(AbbrevDecl->getFormByIndex(AttrIdx));
+  return FormValue.extractValue(DebugInfoData, &DebugInfoOffset, U);
 }
 
 const char *DWARFDebugInfoEntryMinimal::getAttributeValueAsString(
@@ -238,20 +231,12 @@ uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsUnsigned(
   return FailValue;
 }
 
-int64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsSigned(
-    const DWARFUnit *u, const uint16_t attr, int64_t fail_value) const {
-  DWARFFormValue form_value;
-  if (getAttributeValue(u, attr, form_value))
-      return form_value.getSigned();
-  return fail_value;
-}
-
 uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsReference(
-    const DWARFUnit *u, const uint16_t attr, uint64_t fail_value) const {
-  DWARFFormValue form_value;
-  if (getAttributeValue(u, attr, form_value))
-      return form_value.getReference(u);
-  return fail_value;
+    const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const {
+  DWARFFormValue FormValue;
+  if (getAttributeValue(U, Attr, FormValue))
+      return FormValue.getReference(U);
+  return FailValue;
 }
 
 bool DWARFDebugInfoEntryMinimal::getLowAndHighPC(const DWARFUnit *U,
@@ -259,6 +244,7 @@ bool DWARFDebugInfoEntryMinimal::getLowAndHighPC(const DWARFUnit *U,
                                                  uint64_t &HighPC) const {
   HighPC = -1ULL;
   LowPC = getAttributeValueAsAddress(U, DW_AT_low_pc, -1ULL);
+  // FIXME: Check if HighPC is of class constant (it has different semantics).
   if (LowPC != -1ULL)
     HighPC = getAttributeValueAsAddress(U, DW_AT_high_pc, -1ULL);
   return (HighPC != -1ULL);
index b5a9753487ff5df66c3ec8b730322d95f38ddd69..e1d88eead770a43284ac24d12c5061de8090ddac 100644 (file)
@@ -120,24 +120,20 @@ public:
     return AbbrevDecl;
   }
 
-  uint32_t getAttributeValue(const DWARFUnit *u, const uint16_t attr,
-                             DWARFFormValue &formValue,
-                             uint32_t *end_attr_offset_ptr = 0) const;
+  bool getAttributeValue(const DWARFUnit *U, const uint16_t Attr,
+                         DWARFFormValue &FormValue) const;
 
-  const char *getAttributeValueAsString(const DWARFUnit *u, const uint16_t attr,
-                                        const char *fail_value) const;
+  const char *getAttributeValueAsString(const DWARFUnit *U, const uint16_t Attr,
+                                        const char *FailValue) const;
 
   uint64_t getAttributeValueAsAddress(const DWARFUnit *U, const uint16_t Attr,
                                       uint64_t FailValue) const;
 
-  uint64_t getAttributeValueAsUnsigned(const DWARFUnit *u, const uint16_t attr,
-                                       uint64_t fail_value) const;
+  uint64_t getAttributeValueAsUnsigned(const DWARFUnit *U, const uint16_t Attr,
+                                       uint64_t FailValue) const;
 
-  uint64_t getAttributeValueAsReference(const DWARFUnit *u, const uint16_t attr,
-                                        uint64_t fail_value) const;
-
-  int64_t getAttributeValueAsSigned(const DWARFUnit *u, const uint16_t attr,
-                                    int64_t fail_value) const;
+  uint64_t getAttributeValueAsReference(const DWARFUnit *U, const uint16_t Attr,
+                                        uint64_t FailValue) const;
 
   /// Retrieves DW_AT_low_pc and DW_AT_high_pc from CU.
   /// Returns true if both attributes are present.