summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2018-12-12 19:23:55 +0000
committerDavid Blaikie <dblaikie@gmail.com>2018-12-12 19:23:55 +0000
commit92b5493a14d86bbf28abfda2616994a4e2dbdf62 (patch)
treeec74743c2abd53080661433cf799bf9b0e5280a2 /llvm/lib/DebugInfo
parent4937adf75f024f5cbd3cc190d5bd57d1761aefc3 (diff)
downloadbcm5719-llvm-92b5493a14d86bbf28abfda2616994a4e2dbdf62.tar.gz
bcm5719-llvm-92b5493a14d86bbf28abfda2616994a4e2dbdf62.zip
DebugInfo/DWARF: Refactor getAttributeValueAsReferencedDie to accept a DWARFFormValue
Save searching for the attribute again when you already have the DWARFFormValue at hand. llvm-svn: 348960
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDie.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index b86f96ae808..e88ea354d9f 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -289,8 +289,9 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
// 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) {
- if (const char *Name = Die.getAttributeValueAsReferencedDie(Attr).getName(
- DINameKind::LinkageName))
+ if (const char *Name =
+ Die.getAttributeValueAsReferencedDie(formValue).getName(
+ DINameKind::LinkageName))
OS << Space << "\"" << Name << '\"';
} else if (Attr == DW_AT_type) {
OS << Space << "\"";
@@ -390,7 +391,14 @@ DWARFDie::findRecursively(ArrayRef<dwarf::Attribute> Attrs) const {
DWARFDie
DWARFDie::getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const {
- if (auto SpecRef = toReference(find(Attr))) {
+ if (Optional<DWARFFormValue> F = find(Attr))
+ return getAttributeValueAsReferencedDie(*F);
+ return DWARFDie();
+}
+
+DWARFDie
+DWARFDie::getAttributeValueAsReferencedDie(const DWARFFormValue &V) const {
+ if (auto SpecRef = toReference(V)) {
if (auto SpecUnit = U->getUnitVector().getUnitForOffset(*SpecRef))
return SpecUnit->getDIEForOffset(*SpecRef);
}
OpenPOWER on IntegriCloud