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:
93 NameRef = StringPool.internString(
ShortName);
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())
156 unsigned Hash =
hash_combine(Context.getQualifiedNameHash(),
Tag, NameRef);
160 if (IsAnonymousNamespace)
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)) {
183 assert(ContextIter != Contexts.end());
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))
198 std::pair<unsigned, unsigned>
Key = {
CU.getUniqueID(), FileNum};
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.
bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, DILineInfoSpecifier::FileLineInfoKind Kind, std::string &Result) const
Extracts filename by its index in filename table in prologue.