[DebugInfo] Delete dead code, simplify and fix code style for some existing code. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192894 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexey Samsonov 2013-10-17 13:28:16 +00:00
parent 651ffc703e
commit 2e56d575b7
2 changed files with 31 additions and 49 deletions

View File

@ -182,36 +182,29 @@ bool DWARFDebugInfoEntryMinimal::isSubroutineDIE() const {
Tag == DW_TAG_inlined_subroutine; Tag == DW_TAG_inlined_subroutine;
} }
uint32_t DWARFDebugInfoEntryMinimal::getAttributeValue( bool DWARFDebugInfoEntryMinimal::getAttributeValue(
const DWARFUnit *u, const uint16_t attr, DWARFFormValue &form_value, const DWARFUnit *U, const uint16_t Attr, DWARFFormValue &FormValue) const {
uint32_t *end_attr_offset_ptr) const { if (!AbbrevDecl)
if (AbbrevDecl) { return false;
uint32_t attr_idx = AbbrevDecl->findAttributeIndex(attr);
if (attr_idx != -1U) { uint32_t AttrIdx = AbbrevDecl->findAttributeIndex(Attr);
uint32_t offset = getOffset(); if (AttrIdx == -1U)
return false;
DataExtractor debug_info_data = u->getDebugInfoExtractor(); DataExtractor DebugInfoData = U->getDebugInfoExtractor();
uint32_t DebugInfoOffset = getOffset();
// Skip the abbreviation code so we are at the data for the attributes // Skip the abbreviation code so we are at the data for the attributes
debug_info_data.getULEB128(&offset); DebugInfoData.getULEB128(&DebugInfoOffset);
uint32_t idx = 0; // Skip preceding attribute values.
while (idx < attr_idx) for (uint32_t i = 0; i < AttrIdx; ++i) {
DWARFFormValue::skipValue(AbbrevDecl->getFormByIndex(idx++), DWARFFormValue::skipValue(AbbrevDecl->getFormByIndex(i),
debug_info_data, &offset, u); DebugInfoData, &DebugInfoOffset, 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;
}
}
} }
return 0; FormValue = DWARFFormValue(AbbrevDecl->getFormByIndex(AttrIdx));
return FormValue.extractValue(DebugInfoData, &DebugInfoOffset, U);
} }
const char *DWARFDebugInfoEntryMinimal::getAttributeValueAsString( const char *DWARFDebugInfoEntryMinimal::getAttributeValueAsString(
@ -238,20 +231,12 @@ uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsUnsigned(
return FailValue; 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( uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsReference(
const DWARFUnit *u, const uint16_t attr, uint64_t fail_value) const { const DWARFUnit *U, const uint16_t Attr, uint64_t FailValue) const {
DWARFFormValue form_value; DWARFFormValue FormValue;
if (getAttributeValue(u, attr, form_value)) if (getAttributeValue(U, Attr, FormValue))
return form_value.getReference(u); return FormValue.getReference(U);
return fail_value; return FailValue;
} }
bool DWARFDebugInfoEntryMinimal::getLowAndHighPC(const DWARFUnit *U, bool DWARFDebugInfoEntryMinimal::getLowAndHighPC(const DWARFUnit *U,
@ -259,6 +244,7 @@ bool DWARFDebugInfoEntryMinimal::getLowAndHighPC(const DWARFUnit *U,
uint64_t &HighPC) const { uint64_t &HighPC) const {
HighPC = -1ULL; HighPC = -1ULL;
LowPC = getAttributeValueAsAddress(U, DW_AT_low_pc, -1ULL); LowPC = getAttributeValueAsAddress(U, DW_AT_low_pc, -1ULL);
// FIXME: Check if HighPC is of class constant (it has different semantics).
if (LowPC != -1ULL) if (LowPC != -1ULL)
HighPC = getAttributeValueAsAddress(U, DW_AT_high_pc, -1ULL); HighPC = getAttributeValueAsAddress(U, DW_AT_high_pc, -1ULL);
return (HighPC != -1ULL); return (HighPC != -1ULL);

View File

@ -120,24 +120,20 @@ public:
return AbbrevDecl; return AbbrevDecl;
} }
uint32_t getAttributeValue(const DWARFUnit *u, const uint16_t attr, bool getAttributeValue(const DWARFUnit *U, const uint16_t Attr,
DWARFFormValue &formValue, DWARFFormValue &FormValue) const;
uint32_t *end_attr_offset_ptr = 0) const;
const char *getAttributeValueAsString(const DWARFUnit *u, const uint16_t attr, const char *getAttributeValueAsString(const DWARFUnit *U, const uint16_t Attr,
const char *fail_value) const; const char *FailValue) const;
uint64_t getAttributeValueAsAddress(const DWARFUnit *U, const uint16_t Attr, uint64_t getAttributeValueAsAddress(const DWARFUnit *U, const uint16_t Attr,
uint64_t FailValue) const; uint64_t FailValue) const;
uint64_t getAttributeValueAsUnsigned(const DWARFUnit *u, const uint16_t attr, uint64_t getAttributeValueAsUnsigned(const DWARFUnit *U, const uint16_t Attr,
uint64_t fail_value) const; uint64_t FailValue) const;
uint64_t getAttributeValueAsReference(const DWARFUnit *u, const uint16_t attr, uint64_t getAttributeValueAsReference(const DWARFUnit *U, const uint16_t Attr,
uint64_t fail_value) const; uint64_t FailValue) const;
int64_t getAttributeValueAsSigned(const DWARFUnit *u, const uint16_t attr,
int64_t fail_value) const;
/// Retrieves DW_AT_low_pc and DW_AT_high_pc from CU. /// Retrieves DW_AT_low_pc and DW_AT_high_pc from CU.
/// Returns true if both attributes are present. /// Returns true if both attributes are present.