17using namespace dwarf_linker;
18using namespace dwarf_linker::classic;
35 if (LastSeenCompileUnitID == U.getUniqueID()) {
38 U.getInfo(FirstIdx).Ctxt =
nullptr;
42 LastSeenCompileUnitID = U.getUniqueID();
60 case dwarf::DW_TAG_module:
62 case dwarf::DW_TAG_compile_unit:
64 case dwarf::DW_TAG_subprogram:
66 if ((Context.
getTag() == dwarf::DW_TAG_namespace ||
67 Context.
getTag() == dwarf::DW_TAG_compile_unit) &&
71 case dwarf::DW_TAG_member:
72 case dwarf::DW_TAG_namespace:
73 case dwarf::DW_TAG_structure_type:
74 case dwarf::DW_TAG_class_type:
75 case dwarf::DW_TAG_union_type:
76 case dwarf::DW_TAG_enumeration_type:
77 case dwarf::DW_TAG_typedef:
95 bool IsAnonymousNamespace = NameRef.
empty() &&
Tag == dwarf::DW_TAG_namespace;
96 if (IsAnonymousNamespace) {
99 NameRef =
"(anonymous namespace)";
102 if (
Tag != dwarf::DW_TAG_class_type &&
Tag != dwarf::DW_TAG_structure_type &&
103 Tag != dwarf::DW_TAG_union_type &&
104 Tag != dwarf::DW_TAG_enumeration_type && NameRef.
empty())
108 unsigned ByteSize = std::numeric_limits<uint32_t>::max();
110 if (!InClangModule) {
120 std::numeric_limits<uint64_t>::max());
121 if (
Tag != dwarf::DW_TAG_namespace || IsAnonymousNamespace) {
122 if (
unsigned FileNum =
124 if (
const auto *LT = U.getOrigUnit().getContext().getLineTableForUnit(
129 if (IsAnonymousNamespace)
132 if (LT->hasFileAtIndex(FileNum)) {
136 FileRef = getResolvedPath(U, FileNum, *LT);
143 if (!Line && NameRef.
empty())
160 if (IsAnonymousNamespace)
164 DeclContext Key(Hash, Line, ByteSize,
Tag, NameRef, FileRef, Context);
165 auto ContextIter = Contexts.
find(&Key);
167 if (ContextIter == Contexts.
end()) {
171 new (Allocator)
DeclContext(Hash, Line, ByteSize,
Tag, NameRef, FileRef,
172 Context,
DIE, U.getUniqueID());
173 std::tie(ContextIter, Inserted) = Contexts.
insert(NewContext);
174 assert(Inserted &&
"Failed to insert DeclContext");
176 }
else if (
Tag != dwarf::DW_TAG_namespace &&
177 !(*ContextIter)->setLastSeenDIE(U,
DIE)) {
186 if ((
Tag == dwarf::DW_TAG_subprogram &&
187 Context.
getTag() != dwarf::DW_TAG_structure_type &&
188 Context.
getTag() != dwarf::DW_TAG_class_type) ||
189 (
Tag == dwarf::DW_TAG_union_type))
196DeclContextTree::getResolvedPath(
CompileUnit &
CU,
unsigned FileNum,
198 std::pair<unsigned, unsigned> Key = {
CU.getUniqueID(), FileNum};
201 if (It == ResolvedPaths.
end()) {
202 std::string FileName;
204 FileNum,
CU.getOrigUnit().getCompilationDir(),
205 DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, FileName);
207 assert(FoundFileName &&
"Must get file name from line table");
213 It = ResolvedPaths.
insert(std::make_pair(Key, ResolvedPath)).first;
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
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)
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)
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 ...
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.
uint32_t getQualifiedNameHash() const
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.
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.