[llvm] r192894 - [DebugInfo] Delete dead code, simplify and fix code style for some existing code. No functionality change.
Alexey Samsonov
samsonov at google.com
Thu Oct 17 06:28:17 PDT 2013
Author: samsonov
Date: Thu Oct 17 08:28:16 2013
New Revision: 192894
URL: http://llvm.org/viewvc/llvm-project?rev=192894&view=rev
Log:
[DebugInfo] Delete dead code, simplify and fix code style for some existing code. No functionality change.
Modified:
llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp
llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h
Modified: llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp?rev=192894&r1=192893&r2=192894&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp Thu Oct 17 08:28:16 2013
@@ -182,36 +182,29 @@ bool DWARFDebugInfoEntryMinimal::isSubro
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();
-
- DataExtractor debug_info_data = u->getDebugInfoExtractor();
-
- // Skip the abbreviation code so we are at the data for the attributes
- debug_info_data.getULEB128(&offset);
-
- uint32_t idx = 0;
- while (idx < attr_idx)
- DWARFFormValue::skipValue(AbbrevDecl->getFormByIndex(idx++),
- debug_info_data, &offset, u);
-
- 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;
- }
- }
+bool DWARFDebugInfoEntryMinimal::getAttributeValue(
+ const DWARFUnit *U, const uint16_t Attr, DWARFFormValue &FormValue) const {
+ if (!AbbrevDecl)
+ return false;
+
+ uint32_t AttrIdx = AbbrevDecl->findAttributeIndex(Attr);
+ if (AttrIdx == -1U)
+ return false;
+
+ DataExtractor DebugInfoData = U->getDebugInfoExtractor();
+ uint32_t DebugInfoOffset = getOffset();
+
+ // Skip the abbreviation code so we are at the data for the attributes
+ DebugInfoData.getULEB128(&DebugInfoOffset);
+
+ // 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::get
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::getLowA
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);
Modified: llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h?rev=192894&r1=192893&r2=192894&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h Thu Oct 17 08:28:16 2013
@@ -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.
More information about the llvm-commits
mailing list