23#define DEBUG_TYPE "Element"
26 {LVElementKind::Discarded, &LVElement::getIsDiscarded},
27 {LVElementKind::Global, &LVElement::getIsGlobalReference},
28 {LVElementKind::Optimized, &LVElement::getIsOptimized}};
49 if (
options().getAttributeArgument()) {
84 if (!
options().getAttributePathname()) {
87 size_t Pos = Basename.
rfind(
'/');
88 if (Pos != std::string::npos)
89 Basename = Basename.
substr(Pos + 1);
117 if (
options().getAttributeOffset()) {
140 case MemberAccess::Private:
142 case MemberAccess::Protected:
144 case MemberAccess::Public:
152 return getIsExternal() ?
"extern" :
StringRef();
159 return "not_inlined";
163 return "declared_not_inlined";
165 return "declared_inlined";
174 case dwarf::DW_VIRTUALITY_none:
176 case dwarf::DW_VIRTUALITY_virtual:
178 case dwarf::DW_VIRTUALITY_pure_virtual:
179 return "pure virtual";
186 switch (Virtuality) {
187 case MethodKind::Virtual:
188 return dwarf::DW_VIRTUALITY_virtual;
189 case MethodKind::PureVirtual:
190 return dwarf::DW_VIRTUALITY_pure_virtual;
191 case MethodKind::IntroducingVirtual:
192 case MethodKind::PureIntroducingVirtual:
194 return dwarf::DW_VIRTUALITY_virtual;
212void LVElement::setFileLine(
LVElement *Specification) {
217 setIsLineFromReference();
221 setIsFileFromReference();
227 if (
options().getAttributeQualified())
228 resolveQualifiedName();
239 if (Parent && !Parent->getIsCompileUnit())
264 setIsGeneratedName();
286 bool GetBaseTypename =
false;
287 bool UseBaseTypename =
true;
288 bool UseNameText =
true;
291 case dwarf::DW_TAG_pointer_type:
295 case dwarf::DW_TAG_const_type:
296 case dwarf::DW_TAG_ptr_to_member_type:
297 case dwarf::DW_TAG_rvalue_reference_type:
298 case dwarf::DW_TAG_reference_type:
299 case dwarf::DW_TAG_restrict_type:
300 case dwarf::DW_TAG_volatile_type:
303 case dwarf::DW_TAG_base_type:
304 case dwarf::DW_TAG_compile_unit:
305 case dwarf::DW_TAG_class_type:
306 case dwarf::DW_TAG_enumerator:
307 case dwarf::DW_TAG_namespace:
308 case dwarf::DW_TAG_skeleton_unit:
309 case dwarf::DW_TAG_structure_type:
310 case dwarf::DW_TAG_union_type:
311 case dwarf::DW_TAG_unspecified_type:
312 case dwarf::DW_TAG_GNU_template_parameter_pack:
313 GetBaseTypename =
true;
315 case dwarf::DW_TAG_array_type:
316 case dwarf::DW_TAG_call_site:
317 case dwarf::DW_TAG_entry_point:
318 case dwarf::DW_TAG_enumeration_type:
319 case dwarf::DW_TAG_GNU_call_site:
320 case dwarf::DW_TAG_imported_module:
321 case dwarf::DW_TAG_imported_declaration:
322 case dwarf::DW_TAG_inlined_subroutine:
323 case dwarf::DW_TAG_label:
324 case dwarf::DW_TAG_subprogram:
325 case dwarf::DW_TAG_subrange_type:
326 case dwarf::DW_TAG_subroutine_type:
327 case dwarf::DW_TAG_typedef:
328 GetBaseTypename =
true;
329 UseBaseTypename =
false;
331 case dwarf::DW_TAG_template_type_parameter:
332 case dwarf::DW_TAG_template_value_parameter:
333 UseBaseTypename =
false;
335 case dwarf::DW_TAG_GNU_template_template_param:
337 case dwarf::DW_TAG_catch_block:
338 case dwarf::DW_TAG_lexical_block:
339 case dwarf::DW_TAG_try_block:
350 if (
Name.empty() && GetBaseTypename)
355 std::string Fullname;
357 if (UseNameText &&
Name.size())
358 Fullname.append(std::string(
Name));
359 if (UseBaseTypename && BaseTypename.
size()) {
360 if (UseNameText &&
Name.size())
361 Fullname.append(
" ");
362 Fullname.append(std::string(BaseTypename));
367 assert((Fullname.find(
" ", 0) == std::string::npos) &&
368 "Extra double spaces in name.");
375 if (!
options().getAttributeAnySource())
402 if (getIsFileFromReference() &&
Reference) {
405 setInvalidFilename();
421 while (Parent && !(Parent->*GetFunction)())
435void LVElement::resolveQualifiedName() {
436 if (!getIsReferencedType() ||
isBase() || getQualifiedResolved() ||
437 !getIncludeInPrint())
444 if (Parent && !Parent->getIsRoot()) {
445 while (Parent && !Parent->getIsCompileUnit()) {
446 Name.insert(0,
"::");
452 Name.insert(0, Temp);
460 setQualifiedResolved();
471 return (getHasReference() &&
Element->getHasReference()) ||
472 (!getHasReference() && !
Element->getHasReference());
479 dbgs() <<
"\n[Element::equals]\n";
480 if (
options().getAttributeOffset()) {
484 dbgs() <<
"Reference: "
521 if (
options().getPrintFormatting() &&
options().getAttributeAnySource() &&
532 if (getInvalidFilename())
542 if (
options().getPrintFormatting() &&
options().getAttributeReference())
550 if (
options().getPrintFormatting() &&
options().getAttributeLinkage()) {
558 if (
options().getPrintFormatting() &&
options().getAttributeLinkage()) {
static size_t getStringIndex(StringRef Name)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr size_t size() const
size - Get the string size.
size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Twine utohexstr(const uint64_t &Val)
LLVM Value Representation.
size_t getNameIndex() const
std::string discriminatorAsString() const
LVScope * traverseParents(LVScopeGetFunction GetFunction) const
virtual bool isTemplateParam() const
virtual LVScope * getCompileUnitParent() const
StringRef getQualifiedName() const
void resolveFullname(LVElement *BaseType, StringRef Name=emptyString())
LVScope * getFunctionParent() const
virtual bool isRoot() const
virtual void updateLevel(LVScope *Parent, bool Moved=false)
virtual void resolveName()
StringRef virtualityString(uint32_t Virtuality=dwarf::DW_VIRTUALITY_none) const
bool isFiled() const override
uint32_t getInlineCode() const
StringRef typeAsString() const
virtual uint32_t getDiscriminator() const
virtual bool isBase() const
void setFilename(StringRef Filename)
void setQualifiedName(StringRef Name)
StringRef externalString() const
bool getIsKindScope() const
virtual StringRef getLinkageName() const
void setName(StringRef ElementName) override
void setGenericType(LVElement *Element)
virtual bool isCompileUnit() const
StringRef getName() const override
void generateName(std::string &Prefix) const
LVType * getTypeAsType() const
LVElement * getType() const
bool referenceMatch(const LVElement *Element) const
uint32_t getAccessibilityCode() const
void setFile(LVElement *Reference=nullptr)
void setType(LVElement *Element=nullptr)
StringRef getTypeName() const
void printLinkageName(raw_ostream &OS, bool Full, LVElement *Parent, LVScope *Scope) const
bool getIsKindType() const
StringRef accessibilityString(uint32_t Access=dwarf::DW_ACCESS_private) const
void setFilenameIndex(size_t Index)
bool equals(const LVElement *Element) const
StringRef inlineCodeString(uint32_t Code) const
uint32_t getVirtualityCode() const
size_t getFilenameIndex() const
std::string typeOffsetAsString() const
void printFileIndex(raw_ostream &OS, bool Full=true) const override
StringRef getPathname() const
size_t getQualifiedNameIndex() const
bool isNamed() const override
void printReference(raw_ostream &OS, bool Full, LVElement *Parent) const
virtual void resolveExtra()
LVScope * getTypeAsScope() const
virtual void resolveReferences()
std::string referenceAsString(uint32_t LineNumber, bool Spaces) const
virtual const char * kind() const
LVScope * getParentScope() const
dwarf::Tag getTag() const
void setLevel(LVLevel Level)
void printAttributes(raw_ostream &OS, bool Full=true) const
virtual std::string lineNumberAsString(bool ShowZero=false) const
uint32_t getLineNumber() const
LVOffset getOffset() const
void setLineNumber(uint32_t Number)
StringRef getFilename(LVObject *Object, size_t Index) const
virtual LVSectionIndex getSectionIndex(LVScope *Scope)
size_t getIndex(StringRef Key)
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
MethodKind
Part of member attribute flags. (CV_methodprop_e)
MemberAccess
Source-level access specifier. (CV_access_e)
@ DW_INL_declared_not_inlined
@ DW_INL_declared_inlined
constexpr Tag DW_TAG_unaligned
LVStringPool & getStringPool()
std::string formattedKind(StringRef Kind)
std::string hexSquareString(uint64_t Value)
bool(LVScope::*)() const LVScopeGetFunction
std::string transformPath(StringRef Path)
LVLexicalComponent getInnerComponent(StringRef Name)
std::string formattedName(StringRef Name)
std::map< LVElementKind, LVElementGetFunction > LVElementDispatch
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...