32 if (LastSeenCompileUnitID == U.getUniqueID()) {
35 U.getInfo(FirstIdx).Ctxt =
nullptr;
39 LastSeenCompileUnitID = U.getUniqueID();
57 case dwarf::DW_TAG_module:
59 case dwarf::DW_TAG_compile_unit:
61 case dwarf::DW_TAG_subprogram:
63 if ((
Context.getTag() == dwarf::DW_TAG_namespace ||
64 Context.getTag() == dwarf::DW_TAG_compile_unit) &&
68 case dwarf::DW_TAG_member:
69 case dwarf::DW_TAG_namespace:
70 case dwarf::DW_TAG_structure_type:
71 case dwarf::DW_TAG_class_type:
72 case dwarf::DW_TAG_union_type:
73 case dwarf::DW_TAG_enumeration_type:
74 case dwarf::DW_TAG_typedef:
92 bool IsAnonymousNamespace = NameRef.
empty() &&
Tag == dwarf::DW_TAG_namespace;
93 if (IsAnonymousNamespace) {
96 NameRef =
"(anonymous namespace)";
99 if (
Tag != dwarf::DW_TAG_class_type &&
Tag != dwarf::DW_TAG_structure_type &&
100 Tag != dwarf::DW_TAG_union_type &&
101 Tag != dwarf::DW_TAG_enumeration_type && NameRef.
empty())
105 unsigned ByteSize = std::numeric_limits<uint32_t>::max();
107 if (!InClangModule) {
117 std::numeric_limits<uint64_t>::max());
118 if (
Tag != dwarf::DW_TAG_namespace || IsAnonymousNamespace) {
119 if (
unsigned FileNum =
121 if (
const auto *LT = U.getOrigUnit().getContext().getLineTableForUnit(
126 if (IsAnonymousNamespace)
129 if (LT->hasFileAtIndex(FileNum)) {
133 FileRef = getResolvedPath(U, FileNum, *LT);
140 if (!Line && NameRef.
empty())
157 if (IsAnonymousNamespace)
162 auto ContextIter = Contexts.
find(&Key);
164 if (ContextIter == Contexts.
end()) {
168 new (Allocator)
DeclContext(Hash, Line, ByteSize,
Tag, NameRef, FileRef,
170 std::tie(ContextIter, Inserted) = Contexts.
insert(NewContext);
171 assert(Inserted &&
"Failed to insert DeclContext");
173 }
else if (
Tag != dwarf::DW_TAG_namespace &&
174 !(*ContextIter)->setLastSeenDIE(U,
DIE)) {
183 if ((
Tag == dwarf::DW_TAG_subprogram &&
184 Context.getTag() != dwarf::DW_TAG_structure_type &&
185 Context.getTag() != dwarf::DW_TAG_class_type) ||
186 (
Tag == dwarf::DW_TAG_union_type))
193DeclContextTree::getResolvedPath(
CompileUnit &
CU,
unsigned FileNum,
195 std::pair<unsigned, unsigned> Key = {
CU.getUniqueID(), FileNum};
198 if (It == ResolvedPaths.
end()) {
199 std::string FileName;
201 FileNum,
CU.getOrigUnit().getCompilationDir(),
202 DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, FileName);
204 assert(FoundFileName &&
"Must get file name from line table");
208 StringRef ResolvedPath = PathResolver.
resolve(FileName, StringPool);
210 It = ResolvedPaths.
insert(std::make_pair(Key, ResolvedPath)).first;
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 ...
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.
uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) const
Return the index of a Die entry inside the unit's DIE vector.
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.
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.
iterator find(const_arg_type_t< KeyT > Val)
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT, true > const_iterator
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
StringRef internString(StringRef S)
Get permanent storage for S (but do not necessarily emit S in the output section).
PointerIntPair - This class implements a pair of a pointer and small integer.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
std::pair< iterator, bool > insert(const ValueT &V)
iterator find(const_arg_type_t< ValueT > V)
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.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, DILineInfoSpecifier::FileLineInfoKind Kind, std::string &Result) const
Extracts filename by its index in filename table in prologue.