20static std::optional<std::string>
22 std::string Result = Name.str();
25 Printer.appendAndTerminateTemplateParameters(
DIE);
41 DWARFDie Type =
DIE.getAttributeValueAsReferencedDie(dwarf::DW_AT_type);
45 if (
const char *Name =
Type.getShortName()) {
65 if (
const char *Name = Child.getShortName())
72using namespace dwarf_linker;
73using namespace dwarf_linker::classic;
90 if (LastSeenCompileUnitID == U.getUniqueID()) {
93 U.getInfo(FirstIdx).Ctxt =
nullptr;
97 LastSeenCompileUnitID = U.getUniqueID();
115 case dwarf::DW_TAG_module:
117 case dwarf::DW_TAG_compile_unit:
119 case dwarf::DW_TAG_subprogram:
121 if ((Context.getTag() == dwarf::DW_TAG_namespace ||
122 Context.getTag() == dwarf::DW_TAG_compile_unit) &&
126 case dwarf::DW_TAG_member:
127 case dwarf::DW_TAG_namespace:
128 case dwarf::DW_TAG_structure_type:
129 case dwarf::DW_TAG_class_type:
130 case dwarf::DW_TAG_union_type:
131 case dwarf::DW_TAG_enumeration_type:
132 case dwarf::DW_TAG_typedef:
147 NameForUniquing = StringPool.internString(
LinkageName);
148 }
else if (!Name.empty()) {
153 bool HasTemplateParamsInName =
154 Name.ends_with(
">") && !Name.ends_with(
"<=>") && Name.contains(
'<');
155 std::optional<std::string> FullName;
156 if (!HasTemplateParamsInName)
158 NameForUniquing = StringPool.internString(FullName ? *FullName : Name);
168 if (
Tag == dwarf::DW_TAG_typedef && !NameForUniquing.
empty()) {
184 StringRef RefName = RefDie.getShortName();
185 if (!RefName.
empty()) {
192 if (Combined.
size() != NameForUniquing.
size())
193 NameForUniquing = StringPool.internString(Combined);
196 bool IsAnonymousNamespace =
197 NameForUniquing.
empty() &&
Tag == dwarf::DW_TAG_namespace;
198 if (IsAnonymousNamespace) {
201 NameForUniquing =
"(anonymous namespace)";
204 if (
Tag != dwarf::DW_TAG_class_type &&
Tag != dwarf::DW_TAG_structure_type &&
205 Tag != dwarf::DW_TAG_union_type &&
206 Tag != dwarf::DW_TAG_enumeration_type && NameForUniquing.
empty())
210 unsigned ByteSize = std::numeric_limits<uint32_t>::max();
212 if (!InClangModule) {
222 std::numeric_limits<uint64_t>::max());
223 if (
Tag != dwarf::DW_TAG_namespace || IsAnonymousNamespace) {
224 if (
unsigned FileNum =
226 if (
const auto *LT = U.getOrigUnit().getContext().getLineTableForUnit(
231 if (IsAnonymousNamespace)
234 if (LT->hasFileAtIndex(FileNum)) {
238 FileRef = getResolvedPath(U, FileNum, *LT);
246 if (NameForUniquing.
empty() && Line) {
250 NameForUniquing = StringPool.internString(Contents);
253 if (!Line && NameForUniquing.
empty())
271 if (IsAnonymousNamespace)
277 auto ContextIter = Contexts.find(&
Key);
279 if (ContextIter == Contexts.end()) {
283 DeclContext(Hash, Line, ByteSize,
Tag, Name, NameForUniquing, FileRef,
284 Context,
DIE, U.getUniqueID());
285 std::tie(ContextIter, Inserted) = Contexts.insert(NewContext);
286 assert(Inserted &&
"Failed to insert DeclContext");
288 }
else if (
Tag != dwarf::DW_TAG_namespace &&
289 !(*ContextIter)->setLastSeenDIE(U,
DIE)) {
295 assert(ContextIter != Contexts.end());
298 if ((
Tag == dwarf::DW_TAG_subprogram &&
299 Context.getTag() != dwarf::DW_TAG_structure_type &&
300 Context.getTag() != dwarf::DW_TAG_class_type) ||
301 (
Tag == dwarf::DW_TAG_union_type))
308DeclContextTree::getResolvedPath(
CompileUnit &
CU,
unsigned FileNum,
310 std::pair<unsigned, unsigned>
Key = {
CU.getUniqueID(), FileNum};
312 ResolvedPathsMap::const_iterator It = ResolvedPaths.find(
Key);
313 if (It == ResolvedPaths.end()) {
314 std::string FileName;
316 FileNum,
CU.getOrigUnit().getCompilationDir(),
319 assert(FoundFileName &&
"Must get file name from line table");
325 It = ResolvedPaths.insert(std::make_pair(
Key, ResolvedPath)).first;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
amdgpu next use AMDGPU Next Use Analysis Printer
static dwarf::Attribute TypeAttr[]
A structured debug information entry.
dwarf::Tag getTag() const
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
LLVM_ABI DWARFDie getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE as the referenced DIE.
LLVM_ABI std::optional< DWARFFormValue > find(dwarf::Attribute Attr) const
Extract the specified attribute from this DIE.
uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) const
Return the index of a Die entry inside the unit's DIE vector.
PointerIntPair - This class implements a pair of a pointer and small integer.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void append(StringRef RHS)
Append from a StringRef.
void push_back(const T &Elt)
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
constexpr size_t size() const
Get the string size.
The instances of the Type class are immutable: once they are created, they are never changed.
StringRef resolve(const std::string &Path, NonRelocatableStringpool &StringPool)
Resolve a path by calling realpath and cache its result.
Stores all information relating to a compile unit, be it in its original instance in the object file ...
LLVM_ABI PointerIntPair< DeclContext *, 1 > getChildDeclContext(DeclContext &Context, const DWARFDie &DIE, CompileUnit &Unit, bool InClangModule)
Get the child of Context described by DIE in Unit.
A DeclContext is a named program scope that is used for ODR uniquing of types.
LLVM_ABI bool setLastSeenDIE(CompileUnit &U, const DWARFDie &Die)
Set the last DIE/CU a context was seen in and, possibly invalidate the context if it is ambiguous.
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.
A raw_ostream that writes to an SmallVector or SmallString.
LLVM_ABI StringRef TagString(unsigned Tag)
LLVM_ABI bool isIdentifiedByChildren(dwarf::Tag Tag)
Test if an unnamed type with tag Tag is identified by its children, which tell it apart from other un...
LLVM_ABI bool isIdentifyingChild(const DWARFDie &Die)
Test if Die is a child that identifies its unnamed parent type.
std::optional< uint64_t > toUnsigned(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an unsigned constant.
This is an optimization pass for GlobalISel generic memory operations.
static std::optional< std::string > makeSimpleTemplateNameWithParams(StringRef Name, const DWARFDie &DIE)
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
static void appendUnqualifiedTypeName(DWARFDie DIE, raw_ostream &OS, unsigned Depth)
Appends the type DIE refers to, through unnamed types up to a named one.
static void appendUnnamedTypeContents(const DWARFDie &DIE, raw_ostream &OS, unsigned Depth)
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
static constexpr unsigned MaxTypeReferenceDepth
Bounds walks along DW_AT_type, which malformed input can make cyclic.
bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, DILineInfoSpecifier::FileLineInfoKind Kind, std::string &Result) const
Extracts filename by its index in filename table in prologue.