From cddab279f6978fca9ae5a5676c7346f384579d2c Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Mon, 31 Oct 2016 16:46:02 +0000 Subject: Modify DWARFFormValue to remember the DWARFUnit that it was decoded with. Modifying DWARFFormValue to remember the DWARFUnit that it was encoded with can simplify the usage of instances of this class. Previously users would have to try and pass in the same DWARFUnit that was used to decode the form value and there was a possibility that a different DWARFUnit might be supplied to the functions that extract values (strings, CU relative references, addresses) and cause problems. This fixes this potential issue by storing the DWARFUnit inside the DWARFFormValue so that this mistake can't be made. Instances of DWARFFormValue are not stored permanently and are used as temporary values, so the increase in size of an instance of DWARFFormValue isn't a big deal. This makes decoding form values more bullet proof and is a change that will be used by future modifications. https://reviews.llvm.org/D26052 llvm-svn: 285594 --- llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp') diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp index 880fc5c3fa2..55378e59b3c 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp @@ -158,13 +158,13 @@ void DWARFDebugInfoEntryMinimal::dumpAttribute(raw_ostream &OS, else if (attr == DW_AT_decl_line || attr == DW_AT_call_line) OS << *formValue.getAsUnsignedConstant(); else - formValue.dump(OS, u); + formValue.dump(OS); // We have dumped the attribute raw value. For some attributes // having both the raw value and the pretty-printed value is // interesting. These attributes are handled below. if (attr == DW_AT_specification || attr == DW_AT_abstract_origin) { - Optional Ref = formValue.getAsReference(u); + Optional Ref = formValue.getAsReference(); if (Ref.hasValue()) { uint32_t RefOffset = Ref.getValue(); DWARFDebugInfoEntryMinimal DIE; @@ -264,7 +264,7 @@ const char *DWARFDebugInfoEntryMinimal::getAttributeValueAsString( DWARFFormValue FormValue; if (!getAttributeValue(U, Attr, FormValue)) return FailValue; - Optional Result = FormValue.getAsCString(U); + Optional Result = FormValue.getAsCString(); return Result.hasValue() ? Result.getValue() : FailValue; } @@ -274,7 +274,7 @@ uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsAddress( DWARFFormValue FormValue; if (!getAttributeValue(U, Attr, FormValue)) return FailValue; - Optional Result = FormValue.getAsAddress(U); + Optional Result = FormValue.getAsAddress(); return Result.hasValue() ? Result.getValue() : FailValue; } @@ -294,7 +294,7 @@ uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsReference( DWARFFormValue FormValue; if (!getAttributeValue(U, Attr, FormValue)) return FailValue; - Optional Result = FormValue.getAsReference(U); + Optional Result = FormValue.getAsReference(); return Result.hasValue() ? Result.getValue() : FailValue; } -- cgit v1.2.3