From d6b67eb15c3640c38d2e12f83373def07ca6fae9 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Mon, 27 Nov 2017 22:12:44 +0000 Subject: Fixed the ability to recursively get an attribute value from a DWARFDie. The previous implementation would only look 1 DW_AT_specification or DW_AT_abstract_origin deep. This means DWARFDie::getName() would fail in certain cases. I ran into such a case while creating a tool that used the LLVM DWARF parser to generate a symbolication format so I have seen this in the wild. Differential Revision: https://reviews.llvm.org/D40156 llvm-svn: 319104 --- llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'llvm/lib/DebugInfo') diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp index 6dd5ecb34e4..c4bb2259244 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -306,17 +306,16 @@ Optional DWARFDie::findRecursively(ArrayRef Attrs) const { if (!isValid()) return None; - auto Die = *this; - if (auto Value = Die.find(Attrs)) - return Value; - if (auto D = Die.getAttributeValueAsReferencedDie(DW_AT_abstract_origin)) - Die = D; - if (auto Value = Die.find(Attrs)) - return Value; - if (auto D = Die.getAttributeValueAsReferencedDie(DW_AT_specification)) - Die = D; - if (auto Value = Die.find(Attrs)) + if (auto Value = find(Attrs)) return Value; + if (auto Die = getAttributeValueAsReferencedDie(DW_AT_abstract_origin)) { + if (auto Value = Die.findRecursively(Attrs)) + return Value; + } + if (auto Die = getAttributeValueAsReferencedDie(DW_AT_specification)) { + if (auto Value = Die.findRecursively(Attrs)) + return Value; + } return None; } -- cgit v1.2.3