Index: include/llvm/ADT/Optional.h =================================================================== --- include/llvm/ADT/Optional.h +++ include/llvm/ADT/Optional.h @@ -284,6 +284,20 @@ return !(X < Y); } +/// A Optional helper class that will return the value of the optional if it +/// has one, or Default if it doesn't have a value. Example usage: +/// +/// @code{.cpp} +/// bool b = OptionalDefault(getOptionalBool(), false); +/// uint32_t F = OptionalDefault(getOptionalUInt32(), 0U); +/// @endcode +template +T OptionalDefault(const Optional &X, const T &Default) { + if (X) + return *X; + return Default; +} + } // end llvm namespace #endif Index: include/llvm/DebugInfo/DWARF/DWARFDie.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDie.h +++ include/llvm/DebugInfo/DWARF/DWARFDie.h @@ -147,21 +147,6 @@ /// DW_AT_abstract_origin referenced DIEs. /// /// \param Attr the attribute to extract. - /// \param FailValue the value to return if this DIE doesn't have this - /// attribute. - /// \returns the address value of the attribute or FailValue if the - /// attribute doesn't exist or if the attribute's form isn't a form that - /// describes an address. - uint64_t getAttributeValueAsAddress(dwarf::Attribute Attr, - uint64_t FailValue) const; - - /// Extract the specified attribute from this DIE as an address. - /// - /// Extract an attribute value from this DIE only. This call doesn't look - /// for the attribute value in any DW_AT_specification or - /// DW_AT_abstract_origin referenced DIEs. - /// - /// \param Attr the attribute to extract. /// \returns an optional value for the attribute. Optional getAttributeValueAsAddress(dwarf::Attribute Attr) const; @@ -172,21 +157,6 @@ /// DW_AT_abstract_origin referenced DIEs. /// /// \param Attr the attribute to extract. - /// \param FailValue the value to return if this DIE doesn't have this - /// attribute. - /// \returns the signed integer constant value of the attribute or FailValue - /// if the attribute doesn't exist or if the attribute's form isn't a form - /// that describes a signed integer. - int64_t getAttributeValueAsSignedConstant(dwarf::Attribute Attr, - int64_t FailValue) const; - - /// Extract the specified attribute from this DIE as a signed integer. - /// - /// Extract an attribute value from this DIE only. This call doesn't look - /// for the attribute value in any DW_AT_specification or - /// DW_AT_abstract_origin referenced DIEs. - /// - /// \param Attr the attribute to extract. /// \returns an optional value for the attribute. Optional getAttributeValueAsSignedConstant(dwarf::Attribute Attr) const; @@ -198,21 +168,6 @@ /// DW_AT_abstract_origin referenced DIEs. /// /// \param Attr the attribute to extract. - /// \param FailValue the value to return if this DIE doesn't have this - /// attribute. - /// \returns the unsigned integer constant value of the attribute or FailValue - /// if the attribute doesn't exist or if the attribute's form isn't a form - /// that describes an unsigned integer. - uint64_t getAttributeValueAsUnsignedConstant(dwarf::Attribute Attr, - uint64_t FailValue) const; - - /// Extract the specified attribute from this DIE as an unsigned integer. - /// - /// Extract an attribute value from this DIE only. This call doesn't look - /// for the attribute value in any DW_AT_specification or - /// DW_AT_abstract_origin referenced DIEs. - /// - /// \param Attr the attribute to extract. /// \returns an optional value for the attribute. Optional getAttributeValueAsUnsignedConstant(dwarf::Attribute Attr) const; @@ -224,21 +179,6 @@ /// DW_AT_abstract_origin referenced DIEs. /// /// \param Attr the attribute to extract. - /// \param FailValue the value to return if this DIE doesn't have this - /// attribute. - /// \returns the unsigned integer constant value of the attribute or FailValue - /// if the attribute doesn't exist or if the attribute's form isn't a form - /// that describes a reference. - uint64_t getAttributeValueAsReference(dwarf::Attribute Attr, - uint64_t FailValue) const; - - /// Extract the specified attribute from this DIE as absolute DIE Offset. - /// - /// Extract an attribute value from this DIE only. This call doesn't look - /// for the attribute value in any DW_AT_specification or - /// DW_AT_abstract_origin referenced DIEs. - /// - /// \param Attr the attribute to extract. /// \returns an optional value for the attribute. Optional getAttributeValueAsReference(dwarf::Attribute Attr) const; @@ -249,20 +189,6 @@ /// DW_AT_abstract_origin referenced DIEs. /// /// \param Attr the attribute to extract. - /// \param FailValue the value to return if this DIE doesn't have this - /// attribute. - /// \returns the unsigned integer constant value of the attribute or FailValue - /// if the attribute doesn't exist or if the attribute's form isn't a form - /// that describes a section offset. - uint64_t getAttributeValueAsSectionOffset(dwarf::Attribute Attr, - uint64_t FailValue) const; - /// Extract the specified attribute from this DIE as absolute section offset. - /// - /// Extract an attribute value from this DIE only. This call doesn't look - /// for the attribute value in any DW_AT_specification or - /// DW_AT_abstract_origin referenced DIEs. - /// - /// \param Attr the attribute to extract. /// \returns an optional value for the attribute. Optional getAttributeValueAsSectionOffset(dwarf::Attribute Attr) const; Index: lib/DebugInfo/DWARF/DWARFDie.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDie.cpp +++ lib/DebugInfo/DWARF/DWARFDie.cpp @@ -152,13 +152,6 @@ return Result.hasValue() ? Result.getValue() : FailValue; } -uint64_t DWARFDie::getAttributeValueAsAddress(dwarf::Attribute Attr, - uint64_t FailValue) const { - if (auto Value = getAttributeValueAsAddress(Attr)) - return *Value; - return FailValue; -} - Optional DWARFDie::getAttributeValueAsAddress(dwarf::Attribute Attr) const { if (auto FormValue = getAttributeValue(Attr)) @@ -166,13 +159,6 @@ return None; } -int64_t DWARFDie::getAttributeValueAsSignedConstant(dwarf::Attribute Attr, - int64_t FailValue) const { - if (auto Value = getAttributeValueAsSignedConstant(Attr)) - return *Value; - return FailValue; -} - Optional DWARFDie::getAttributeValueAsSignedConstant(dwarf::Attribute Attr) const { if (auto FormValue = getAttributeValue(Attr)) @@ -180,15 +166,6 @@ return None; } -uint64_t -DWARFDie::getAttributeValueAsUnsignedConstant(dwarf::Attribute Attr, - uint64_t FailValue) const { - if (auto Value = getAttributeValueAsUnsignedConstant(Attr)) - return *Value; - return FailValue; -} - - Optional DWARFDie::getAttributeValueAsUnsignedConstant(dwarf::Attribute Attr) const { if (auto FormValue = getAttributeValue(Attr)) @@ -196,14 +173,6 @@ return None; } -uint64_t DWARFDie::getAttributeValueAsReference(dwarf::Attribute Attr, - uint64_t FailValue) const { - if (auto Value = getAttributeValueAsReference(Attr)) - return *Value; - return FailValue; -} - - Optional DWARFDie::getAttributeValueAsReference(dwarf::Attribute Attr) const { if (auto FormValue = getAttributeValue(Attr)) @@ -211,13 +180,6 @@ return None; } -uint64_t DWARFDie::getAttributeValueAsSectionOffset(dwarf::Attribute Attr, - uint64_t FailValue) const { - if (auto Value = getAttributeValueAsSectionOffset(Attr)) - return *Value; - return FailValue; -} - Optional DWARFDie::getAttributeValueAsSectionOffset(dwarf::Attribute Attr) const { if (auto FormValue = getAttributeValue(Attr)) @@ -345,9 +307,15 @@ void DWARFDie::getCallerFrame(uint32_t &CallFile, uint32_t &CallLine, uint32_t &CallColumn) const { - CallFile = getAttributeValueAsUnsignedConstant(DW_AT_call_file, 0); - CallLine = getAttributeValueAsUnsignedConstant(DW_AT_call_line, 0); - CallColumn = getAttributeValueAsUnsignedConstant(DW_AT_call_column, 0); + CallFile = + OptionalDefault(getAttributeValueAsUnsignedConstant(DW_AT_call_file), + 0ULL); + CallLine = + OptionalDefault(getAttributeValueAsUnsignedConstant(DW_AT_call_line), + 0ULL); + CallColumn = + OptionalDefault(getAttributeValueAsUnsignedConstant(DW_AT_call_column), + 0ULL); } void DWARFDie::dump(raw_ostream &OS, unsigned RecurseDepth, Index: lib/DebugInfo/DWARF/DWARFUnit.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFUnit.cpp +++ lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -230,10 +230,10 @@ BaseAddr = UnitDie.getAttributeValueAsAddress(DW_AT_entry_pc); if (BaseAddr) setBaseAddress(*BaseAddr); - AddrOffsetSectionBase = UnitDie.getAttributeValueAsSectionOffset( - DW_AT_GNU_addr_base, 0); - RangeSectionBase = UnitDie.getAttributeValueAsSectionOffset( - DW_AT_rnglists_base, 0); + AddrOffsetSectionBase = OptionalDefault( + UnitDie.getAttributeValueAsSectionOffset(DW_AT_GNU_addr_base), 0ULL); + RangeSectionBase = OptionalDefault( + UnitDie.getAttributeValueAsSectionOffset(DW_AT_rnglists_base), 0ULL); // Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for // skeleton CU DIE, so that DWARF users not aware of it are not broken. } Index: tools/dsymutil/DwarfLinker.cpp =================================================================== --- tools/dsymutil/DwarfLinker.cpp +++ tools/dsymutil/DwarfLinker.cpp @@ -205,7 +205,8 @@ Info.resize(OrigUnit.getNumDIEs()); auto CUDie = OrigUnit.getUnitDIE(false); - unsigned Lang = CUDie.getAttributeValueAsUnsignedConstant(dwarf::DW_AT_language, 0); + unsigned Lang = OptionalDefault( + CUDie.getAttributeValueAsUnsignedConstant(dwarf::DW_AT_language), 0ULL); HasODR = CanUseODR && (Lang == dwarf::DW_LANG_C_plus_plus || Lang == dwarf::DW_LANG_C_plus_plus_03 || Lang == dwarf::DW_LANG_C_plus_plus_11 || @@ -1556,7 +1557,9 @@ // Do not unique anything inside CU local functions. if ((Context.getTag() == dwarf::DW_TAG_namespace || Context.getTag() == dwarf::DW_TAG_compile_unit) && - !DIE.getAttributeValueAsUnsignedConstant(dwarf::DW_AT_external, 0)) + !OptionalDefault( + DIE.getAttributeValueAsUnsignedConstant(dwarf::DW_AT_external), + 0ULL)) return PointerIntPair(nullptr); LLVM_FALLTHROUGH; case dwarf::DW_TAG_member: @@ -1570,7 +1573,9 @@ // created on demand. For example implicitely defined constructors // are ambiguous because of the way we identify contexts, and they // won't be generated everytime everywhere. - if (DIE.getAttributeValueAsUnsignedConstant(dwarf::DW_AT_artificial, 0)) + if (OptionalDefault( + DIE.getAttributeValueAsUnsignedConstant(dwarf::DW_AT_artificial), + 0ULL)) return PointerIntPair(nullptr); break; } @@ -1610,11 +1615,12 @@ // namespaces, use these additional data points to make the process // safer. This is disabled for clang modules, because forward // declarations of module-defined types do not have a file and line. - ByteSize = DIE.getAttributeValueAsUnsignedConstant( - dwarf::DW_AT_byte_size, UINT64_MAX); + ByteSize = OptionalDefault(DIE.getAttributeValueAsUnsignedConstant( + dwarf::DW_AT_byte_size), UINT64_MAX); if (Tag != dwarf::DW_TAG_namespace || !Name) { - if (unsigned FileNum = DIE.getAttributeValueAsUnsignedConstant( - dwarf::DW_AT_decl_file, 0)) { + if (unsigned FileNum = OptionalDefault( + DIE.getAttributeValueAsUnsignedConstant( dwarf::DW_AT_decl_file), + 0ULL)) { if (const auto *LT = U.getOrigUnit().getContext().getLineTableForUnit( &U.getOrigUnit())) { // FIXME: dsymutil-classic compatibility. I'd rather not @@ -1627,8 +1633,8 @@ // instead of "" would allow more uniquing, but for now, do // it this way to match dsymutil-classic. if (LT->hasFileAtIndex(FileNum)) { - Line = DIE.getAttributeValueAsUnsignedConstant( - dwarf::DW_AT_decl_line, 0); + Line = OptionalDefault(DIE.getAttributeValueAsUnsignedConstant( + dwarf::DW_AT_decl_line), 0ULL); // Cache the resolved paths, because calling realpath is expansive. StringRef ResolvedPath = U.getResolvedPath(FileNum); if (!ResolvedPath.empty()) { @@ -1804,8 +1810,8 @@ // DW_TAG_module or a DW_TAG_module that contains nothing but // forward declarations. Info.Prune &= (DIE.getTag() == dwarf::DW_TAG_module) || - DIE.getAttributeValueAsUnsignedConstant( - dwarf::DW_AT_declaration, 0); + OptionalDefault(DIE.getAttributeValueAsUnsignedConstant( + dwarf::DW_AT_declaration), 0ULL); // Don't prune it if there is no definition for the DIE. Info.Prune &= Info.Ctxt && Info.Ctxt->getCanonicalDIEOffset(); @@ -2739,13 +2745,13 @@ // file might be start address of another function which got moved // independantly by the linker). The computation of the actual // high_pc value is done in cloneAddressAttribute(). - AttrInfo.OrigHighPc = - InputDIE.getAttributeValueAsAddress(dwarf::DW_AT_high_pc, 0); + AttrInfo.OrigHighPc = OptionalDefault( + InputDIE.getAttributeValueAsAddress(dwarf::DW_AT_high_pc), 0ULL); // Also store the low_pc. It might get relocated in an // inline_subprogram that happens at the beginning of its // inlining function. - AttrInfo.OrigLowPc = - InputDIE.getAttributeValueAsAddress(dwarf::DW_AT_low_pc, UINT64_MAX); + AttrInfo.OrigLowPc = OptionalDefault( + InputDIE.getAttributeValueAsAddress(dwarf::DW_AT_low_pc), UINT64_MAX); } // Reset the Offset to 0 as we will be working on the local copy of @@ -2864,8 +2870,8 @@ auto InvalidRange = FunctionRanges.end(), CurrRange = InvalidRange; DWARFUnit &OrigUnit = Unit.getOrigUnit(); auto OrigUnitDie = OrigUnit.getUnitDIE(false); - uint64_t OrigLowPc = OrigUnitDie.getAttributeValueAsAddress( - dwarf::DW_AT_low_pc, -1ULL); + uint64_t OrigLowPc = OptionalDefault( + OrigUnitDie.getAttributeValueAsAddress(dwarf::DW_AT_low_pc), -1ULL); // Ranges addresses are based on the unit's low_pc. Compute the // offset we need to apply to adapt to the new unit's low_pc. int64_t UnitPcOffset = 0; Index: unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp =================================================================== --- unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp +++ unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp @@ -228,8 +228,8 @@ //---------------------------------------------------------------------- // Test address forms //---------------------------------------------------------------------- - EXPECT_EQ(DieDG.getAttributeValueAsAddress(Attr_DW_FORM_addr, 0), - AddrValue); + EXPECT_EQ(OptionalDefault(DieDG.getAttributeValueAsAddress(Attr_DW_FORM_addr), + 0ULL), AddrValue); //---------------------------------------------------------------------- // Test block forms @@ -273,18 +273,14 @@ //---------------------------------------------------------------------- // Test data forms //---------------------------------------------------------------------- - EXPECT_EQ( - DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_data1, 0), - Data1); - EXPECT_EQ( - DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_data2, 0), - Data2); - EXPECT_EQ( - DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_data4, 0), - Data4); - EXPECT_EQ( - DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_data8, 0), - Data8); + EXPECT_EQ(*DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_data1), + Data1); + EXPECT_EQ(*DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_data2), + Data2); + EXPECT_EQ(*DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_data4), + Data4); + EXPECT_EQ(*DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_data8), + Data8); //---------------------------------------------------------------------- // Test string forms @@ -302,64 +298,56 @@ //---------------------------------------------------------------------- // Test reference forms //---------------------------------------------------------------------- - EXPECT_EQ(DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref_addr, 0), + EXPECT_EQ(*DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref_addr), RefAddr); - EXPECT_EQ(DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref1, 0), - Data1); - EXPECT_EQ(DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref2, 0), - Data2); - EXPECT_EQ(DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref4, 0), - Data4); - EXPECT_EQ(DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref8, 0), - Data8); - EXPECT_EQ(DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref_sig8, 0), + EXPECT_EQ(*DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref1), Data1); + EXPECT_EQ(*DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref2), Data2); + EXPECT_EQ(*DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref4), Data4); + EXPECT_EQ(*DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref8), Data8); + EXPECT_EQ(*DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref_sig8), Data8_2); - EXPECT_EQ(DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref_udata, 0), + EXPECT_EQ(*DieDG.getAttributeValueAsReference(Attr_DW_FORM_ref_udata), UData[0]); //---------------------------------------------------------------------- // Test flag forms //---------------------------------------------------------------------- - EXPECT_EQ(DieDG.getAttributeValueAsUnsignedConstant( - Attr_DW_FORM_flag_true, 0ULL), + EXPECT_EQ(*DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_flag_true), 1ULL); - EXPECT_EQ(DieDG.getAttributeValueAsUnsignedConstant( - Attr_DW_FORM_flag_false, 1ULL), + EXPECT_EQ(*DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_flag_false), 0ULL); - EXPECT_EQ(DieDG.getAttributeValueAsUnsignedConstant( - Attr_DW_FORM_flag_present, 0ULL), + EXPECT_EQ(*DieDG.getAttributeValueAsUnsignedConstant( + Attr_DW_FORM_flag_present), 1ULL); //---------------------------------------------------------------------- // Test SLEB128 based forms //---------------------------------------------------------------------- - EXPECT_EQ(DieDG.getAttributeValueAsSignedConstant(Attr_DW_FORM_sdata, 0), + EXPECT_EQ(*DieDG.getAttributeValueAsSignedConstant(Attr_DW_FORM_sdata), SData); if (Version >= 5) - EXPECT_EQ(DieDG.getAttributeValueAsSignedConstant( - Attr_DW_FORM_implicit_const, 0), ICSData); + EXPECT_EQ(*DieDG.getAttributeValueAsSignedConstant( + Attr_DW_FORM_implicit_const), ICSData); //---------------------------------------------------------------------- // Test ULEB128 based forms //---------------------------------------------------------------------- - EXPECT_EQ( - DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_udata, 0), - UData[0]); + EXPECT_EQ(*DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_FORM_udata), + UData[0]); //---------------------------------------------------------------------- // Test DWARF32/DWARF64 forms //---------------------------------------------------------------------- - EXPECT_EQ( - DieDG.getAttributeValueAsReference(Attr_DW_FORM_GNU_ref_alt, 0), - Dwarf32Values[0]); - EXPECT_EQ( - DieDG.getAttributeValueAsSectionOffset(Attr_DW_FORM_sec_offset, 0), - Dwarf32Values[1]); + EXPECT_EQ(*DieDG.getAttributeValueAsReference(Attr_DW_FORM_GNU_ref_alt), + Dwarf32Values[0]); + EXPECT_EQ(*DieDG.getAttributeValueAsSectionOffset(Attr_DW_FORM_sec_offset), + Dwarf32Values[1]); //---------------------------------------------------------------------- // Add an address at the end to make sure we can decode this value //---------------------------------------------------------------------- - EXPECT_EQ(DieDG.getAttributeValueAsAddress(Attr_Last, 0), AddrValue); + EXPECT_EQ(OptionalDefault(DieDG.getAttributeValueAsAddress(Attr_Last), 0ULL), + AddrValue); } TEST(DWARFDebugInfo, TestDWARF32Version2Addr4AllForms) { @@ -666,7 +654,7 @@ EXPECT_TRUE(CU1TypeDieDG.isValid()); EXPECT_EQ(CU1TypeDieDG.getTag(), DW_TAG_base_type); EXPECT_EQ( - CU1TypeDieDG.getAttributeValueAsUnsignedConstant(DW_AT_encoding, 0), + *CU1TypeDieDG.getAttributeValueAsUnsignedConstant(DW_AT_encoding), DW_ATE_signed); // Verify the first child of the compile unit 2 DIE is our float base type. @@ -674,7 +662,7 @@ EXPECT_TRUE(CU2TypeDieDG.isValid()); EXPECT_EQ(CU2TypeDieDG.getTag(), DW_TAG_base_type); EXPECT_EQ( - CU2TypeDieDG.getAttributeValueAsUnsignedConstant(DW_AT_encoding, 0), + *CU2TypeDieDG.getAttributeValueAsUnsignedConstant(DW_AT_encoding), DW_ATE_float); // Verify the sibling of the base type DIE is our Ref1 DIE and that its @@ -682,14 +670,14 @@ auto CU1Ref1DieDG = CU1TypeDieDG.getSibling(); EXPECT_TRUE(CU1Ref1DieDG.isValid()); EXPECT_EQ(CU1Ref1DieDG.getTag(), DW_TAG_variable); - EXPECT_EQ(CU1Ref1DieDG.getAttributeValueAsReference(DW_AT_type, -1ULL), + EXPECT_EQ(*CU1Ref1DieDG.getAttributeValueAsReference(DW_AT_type), CU1TypeDieDG.getOffset()); // Verify the sibling is our Ref2 DIE and that its DW_AT_type points to our // base type DIE in CU1. auto CU1Ref2DieDG = CU1Ref1DieDG.getSibling(); EXPECT_TRUE(CU1Ref2DieDG.isValid()); EXPECT_EQ(CU1Ref2DieDG.getTag(), DW_TAG_variable); - EXPECT_EQ(CU1Ref2DieDG.getAttributeValueAsReference(DW_AT_type, -1ULL), + EXPECT_EQ(*CU1Ref2DieDG.getAttributeValueAsReference(DW_AT_type), CU1TypeDieDG.getOffset()); // Verify the sibling is our Ref4 DIE and that its DW_AT_type points to our @@ -697,7 +685,7 @@ auto CU1Ref4DieDG = CU1Ref2DieDG.getSibling(); EXPECT_TRUE(CU1Ref4DieDG.isValid()); EXPECT_EQ(CU1Ref4DieDG.getTag(), DW_TAG_variable); - EXPECT_EQ(CU1Ref4DieDG.getAttributeValueAsReference(DW_AT_type, -1ULL), + EXPECT_EQ(*CU1Ref4DieDG.getAttributeValueAsReference(DW_AT_type), CU1TypeDieDG.getOffset()); // Verify the sibling is our Ref8 DIE and that its DW_AT_type points to our @@ -705,7 +693,7 @@ auto CU1Ref8DieDG = CU1Ref4DieDG.getSibling(); EXPECT_TRUE(CU1Ref8DieDG.isValid()); EXPECT_EQ(CU1Ref8DieDG.getTag(), DW_TAG_variable); - EXPECT_EQ(CU1Ref8DieDG.getAttributeValueAsReference(DW_AT_type, -1ULL), + EXPECT_EQ(*CU1Ref8DieDG.getAttributeValueAsReference(DW_AT_type), CU1TypeDieDG.getOffset()); // Verify the sibling is our RefAddr DIE and that its DW_AT_type points to our @@ -713,17 +701,15 @@ auto CU1RefAddrDieDG = CU1Ref8DieDG.getSibling(); EXPECT_TRUE(CU1RefAddrDieDG.isValid()); EXPECT_EQ(CU1RefAddrDieDG.getTag(), DW_TAG_variable); - EXPECT_EQ( - CU1RefAddrDieDG.getAttributeValueAsReference(DW_AT_type, -1ULL), - CU1TypeDieDG.getOffset()); + EXPECT_EQ(*CU1RefAddrDieDG.getAttributeValueAsReference(DW_AT_type), + CU1TypeDieDG.getOffset()); // Verify the sibling of the Ref4 DIE is our RefAddr DIE and that its // DW_AT_type points to our base type DIE. auto CU1ToCU2RefAddrDieDG = CU1RefAddrDieDG.getSibling(); EXPECT_TRUE(CU1ToCU2RefAddrDieDG.isValid()); EXPECT_EQ(CU1ToCU2RefAddrDieDG.getTag(), DW_TAG_variable); - EXPECT_EQ(CU1ToCU2RefAddrDieDG.getAttributeValueAsReference(DW_AT_type, - -1ULL), + EXPECT_EQ(*CU1ToCU2RefAddrDieDG.getAttributeValueAsReference(DW_AT_type), CU2TypeDieDG.getOffset()); // Verify the sibling of the base type DIE is our Ref1 DIE and that its @@ -731,14 +717,14 @@ auto CU2Ref1DieDG = CU2TypeDieDG.getSibling(); EXPECT_TRUE(CU2Ref1DieDG.isValid()); EXPECT_EQ(CU2Ref1DieDG.getTag(), DW_TAG_variable); - EXPECT_EQ(CU2Ref1DieDG.getAttributeValueAsReference(DW_AT_type, -1ULL), + EXPECT_EQ(*CU2Ref1DieDG.getAttributeValueAsReference(DW_AT_type), CU2TypeDieDG.getOffset()); // Verify the sibling is our Ref2 DIE and that its DW_AT_type points to our // base type DIE in CU2. auto CU2Ref2DieDG = CU2Ref1DieDG.getSibling(); EXPECT_TRUE(CU2Ref2DieDG.isValid()); EXPECT_EQ(CU2Ref2DieDG.getTag(), DW_TAG_variable); - EXPECT_EQ(CU2Ref2DieDG.getAttributeValueAsReference(DW_AT_type, -1ULL), + EXPECT_EQ(*CU2Ref2DieDG.getAttributeValueAsReference(DW_AT_type), CU2TypeDieDG.getOffset()); // Verify the sibling is our Ref4 DIE and that its DW_AT_type points to our @@ -746,7 +732,7 @@ auto CU2Ref4DieDG = CU2Ref2DieDG.getSibling(); EXPECT_TRUE(CU2Ref4DieDG.isValid()); EXPECT_EQ(CU2Ref4DieDG.getTag(), DW_TAG_variable); - EXPECT_EQ(CU2Ref4DieDG.getAttributeValueAsReference(DW_AT_type, -1ULL), + EXPECT_EQ(*CU2Ref4DieDG.getAttributeValueAsReference(DW_AT_type), CU2TypeDieDG.getOffset()); // Verify the sibling is our Ref8 DIE and that its DW_AT_type points to our @@ -754,7 +740,7 @@ auto CU2Ref8DieDG = CU2Ref4DieDG.getSibling(); EXPECT_TRUE(CU2Ref8DieDG.isValid()); EXPECT_EQ(CU2Ref8DieDG.getTag(), DW_TAG_variable); - EXPECT_EQ(CU2Ref8DieDG.getAttributeValueAsReference(DW_AT_type, -1ULL), + EXPECT_EQ(*CU2Ref8DieDG.getAttributeValueAsReference(DW_AT_type), CU2TypeDieDG.getOffset()); // Verify the sibling is our RefAddr DIE and that its DW_AT_type points to our @@ -762,17 +748,15 @@ auto CU2RefAddrDieDG = CU2Ref8DieDG.getSibling(); EXPECT_TRUE(CU2RefAddrDieDG.isValid()); EXPECT_EQ(CU2RefAddrDieDG.getTag(), DW_TAG_variable); - EXPECT_EQ( - CU2RefAddrDieDG.getAttributeValueAsReference(DW_AT_type, -1ULL), - CU2TypeDieDG.getOffset()); + EXPECT_EQ(*CU2RefAddrDieDG.getAttributeValueAsReference(DW_AT_type), + CU2TypeDieDG.getOffset()); // Verify the sibling of the Ref4 DIE is our RefAddr DIE and that its // DW_AT_type points to our base type DIE. auto CU2ToCU1RefAddrDieDG = CU2RefAddrDieDG.getSibling(); EXPECT_TRUE(CU2ToCU1RefAddrDieDG.isValid()); EXPECT_EQ(CU2ToCU1RefAddrDieDG.getTag(), DW_TAG_variable); - EXPECT_EQ(CU2ToCU1RefAddrDieDG.getAttributeValueAsReference(DW_AT_type, - -1ULL), + EXPECT_EQ(*CU2ToCU1RefAddrDieDG.getAttributeValueAsReference(DW_AT_type), CU1TypeDieDG.getOffset()); }