diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-06-25 21:42:46 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-06-25 21:42:46 +0000 |
commit | aed187c76e884dcb96e55312c16e1335580a2ed9 (patch) | |
tree | 246aff885ca1735092fbbe00d61e71c553b9543b | |
parent | 1e02a5aac82a41db5092998349f2fc4de459da19 (diff) | |
download | bcm5719-llvm-aed187c76e884dcb96e55312c16e1335580a2ed9.tar.gz bcm5719-llvm-aed187c76e884dcb96e55312c16e1335580a2ed9.zip |
dsymutil: Split out patchStmtList(), NFC
Split out code to patch up the `DW_AT_stmt_list` for the cloned DIE, and
reorganize it so that it doesn't depend on `DIE::values_begin()` and
`DIE::values_end()` (which I'm trying to kill off).
David Blaikie and I talked about adding a range-algorithm version of
`std::find_if()`, but the assertion *still* required getting at the end
iterator. IMO, a separate helper function with an early return is
easier to reason about here.
A follow-up commit that removes `DIE::setValue()` and mutates the
`DIEValue` directly is coming shortly.
llvm-svn: 240701
-rw-r--r-- | llvm/tools/dsymutil/DwarfLinker.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp index 052c1daadbd..a678a01f8da 100644 --- a/llvm/tools/dsymutil/DwarfLinker.cpp +++ b/llvm/tools/dsymutil/DwarfLinker.cpp @@ -2364,6 +2364,17 @@ static void insertLineSequence(std::vector<DWARFDebugLine::Row> &Seq, Seq.clear(); } +static void patchStmtList(DIE &Die, DIEInteger Offset) { + for (auto &V : Die.values()) + if (V.getAttribute() == dwarf::DW_AT_stmt_list) { + Die.setValue(&V - Die.values_begin(), + DIEValue(V.getAttribute(), V.getForm(), Offset)); + return; + } + + llvm_unreachable("Didn't find DW_AT_stmt_list in cloned DIE!"); +} + /// \brief Extract the line table for \p Unit from \p OrigDwarf, and /// recreate a relocated version of these for the address ranges that /// are present in the binary. @@ -2376,18 +2387,8 @@ void DwarfLinker::patchLineTableForUnit(CompileUnit &Unit, return; // Update the cloned DW_AT_stmt_list with the correct debug_line offset. - if (auto *OutputDIE = Unit.getOutputUnitDIE()) { - auto Stmt = - std::find_if(OutputDIE->values_begin(), OutputDIE->values_end(), - [](const DIEValue &Value) { - return Value.getAttribute() == dwarf::DW_AT_stmt_list; - }); - assert(Stmt != OutputDIE->values_end() && - "Didn't find DW_AT_stmt_list in cloned DIE!"); - OutputDIE->setValue(Stmt - OutputDIE->values_begin(), - DIEValue(Stmt->getAttribute(), Stmt->getForm(), - DIEInteger(Streamer->getLineSectionSize()))); - } + if (auto *OutputDIE = Unit.getOutputUnitDIE()) + patchStmtList(*OutputDIE, DIEInteger(Streamer->getLineSectionSize())); // Parse the original line info for the unit. DWARFDebugLine::LineTable LineTable; |