/// Returns null if no name is found.
const char *getSubroutineName(DINameKind Kind) const;
- /// Return the DIE name resolving DW_AT_sepcification or DW_AT_abstract_origin
- /// references if necessary. Returns null if no name is found.
+ /// Return the DIE name resolving DW_AT_specification or DW_AT_abstract_origin
+ /// references if necessary. For the LinkageName case it additionaly searches
+ /// for ShortName if LinkageName is not found.
+ /// Returns null if no name is found.
const char *getName(DINameKind Kind) const;
+ /// Return the DIE short name resolving DW_AT_specification or
+ /// DW_AT_abstract_origin references if necessary. Returns null if no name
+ /// is found.
+ const char *getShortName() const;
+
+ /// Return the DIE linkage name resolving DW_AT_specification or
+ /// DW_AT_abstract_origin references if necessary. Returns null if no name
+ /// is found.
+ const char *getLinkageName() const;
+
/// Returns the declaration line (start line) for a DIE, assuming it specifies
/// a subprogram. This may be fetched from specification or abstract origin
/// for this subprogram by resolving DW_AT_sepcification or
if (Die.getTag() == dwarf::DW_TAG_lexical_block)
return false;
- // FIXME: a bit wasteful as the first getName might return the
- // short name.
if (!Info.MangledName)
- if (const char *MangledName = Die.getName(DINameKind::LinkageName))
+ if (const char *MangledName = Die.getLinkageName())
Info.MangledName = StringPool.getEntry(MangledName);
if (!Info.Name)
- if (const char *Name = Die.getName(DINameKind::ShortName))
+ if (const char *Name = Die.getShortName())
Info.Name = StringPool.getEntry(Name);
+ if (!Info.MangledName)
+ Info.MangledName = Info.Name;
+
if (StripTemplate && Info.Name && Info.MangledName != Info.Name) {
StringRef Name = Info.Name.getString();
if (Optional<StringRef> StrippedName = StripTemplateParameters(Name))
break;
}
- const char *Name = DIE.getName(DINameKind::LinkageName);
- const char *ShortName = DIE.getName(DINameKind::ShortName);
+ const char *Name = DIE.getLinkageName();
+ const char *ShortName = DIE.getShortName();
+
+ if (!Name)
+ Name = ShortName;
+
StringRef NameRef;
StringRef ShortNameRef;
StringRef FileRef;
return nullptr;
// Try to get mangled name only if it was asked for.
if (Kind == DINameKind::LinkageName) {
- if (auto Name = dwarf::toString(
- findRecursively({DW_AT_MIPS_linkage_name, DW_AT_linkage_name}),
- nullptr))
+ if (auto Name = getLinkageName())
return Name;
}
- if (auto Name = dwarf::toString(findRecursively(DW_AT_name), nullptr))
- return Name;
- return nullptr;
+ return getShortName();
+}
+
+const char *DWARFDie::getShortName() const {
+ if (!isValid())
+ return nullptr;
+
+ return dwarf::toString(findRecursively(dwarf::DW_AT_name), nullptr);
+}
+
+const char *DWARFDie::getLinkageName() const {
+ if (!isValid())
+ return nullptr;
+
+ return dwarf::toString(findRecursively({dwarf::DW_AT_MIPS_linkage_name,
+ dwarf::DW_AT_linkage_name}),
+ nullptr);
}
uint64_t DWARFDie::getDeclLine() const {