73 case dwarf::DW_TAG_module:
75 case dwarf::DW_TAG_compile_unit:
77 case dwarf::DW_TAG_subprogram:
79 if ((Context.getTag() == dwarf::DW_TAG_namespace ||
80 Context.getTag() == dwarf::DW_TAG_compile_unit) &&
84 case dwarf::DW_TAG_member:
85 case dwarf::DW_TAG_namespace:
86 case dwarf::DW_TAG_structure_type:
87 case dwarf::DW_TAG_class_type:
88 case dwarf::DW_TAG_union_type:
89 case dwarf::DW_TAG_enumeration_type:
90 case dwarf::DW_TAG_typedef:
105 NameForUniquing = StringPool.internString(
LinkageName);
106 }
else if (!Name.empty()) {
111 bool HasTemplateParamsInName =
112 Name.ends_with(
">") && !Name.ends_with(
"<=>") && Name.contains(
'<');
113 std::optional<std::string> FullName;
114 if (!HasTemplateParamsInName)
116 NameForUniquing = StringPool.internString(FullName ? *FullName : Name);
119 bool IsAnonymousNamespace =
120 NameForUniquing.
empty() &&
Tag == dwarf::DW_TAG_namespace;
121 if (IsAnonymousNamespace) {
124 NameForUniquing =
"(anonymous namespace)";
127 if (
Tag != dwarf::DW_TAG_class_type &&
Tag != dwarf::DW_TAG_structure_type &&
128 Tag != dwarf::DW_TAG_union_type &&
129 Tag != dwarf::DW_TAG_enumeration_type && NameForUniquing.
empty())
133 unsigned ByteSize = std::numeric_limits<uint32_t>::max();
135 if (!InClangModule) {
145 std::numeric_limits<uint64_t>::max());
146 if (
Tag != dwarf::DW_TAG_namespace || IsAnonymousNamespace) {
147 if (
unsigned FileNum =
149 if (
const auto *LT = U.getOrigUnit().getContext().getLineTableForUnit(
154 if (IsAnonymousNamespace)
157 if (LT->hasFileAtIndex(FileNum)) {
161 FileRef = getResolvedPath(U, FileNum, *LT);
168 if (!Line && NameForUniquing.
empty())
186 if (IsAnonymousNamespace)
192 auto ContextIter = Contexts.find(&
Key);
194 if (ContextIter == Contexts.end()) {
198 DeclContext(Hash, Line, ByteSize,
Tag, Name, NameForUniquing, FileRef,
199 Context,
DIE, U.getUniqueID());
200 std::tie(ContextIter, Inserted) = Contexts.insert(NewContext);
201 assert(Inserted &&
"Failed to insert DeclContext");
203 }
else if (
Tag != dwarf::DW_TAG_namespace &&
204 !(*ContextIter)->setLastSeenDIE(U,
DIE)) {
210 assert(ContextIter != Contexts.end());
213 if ((
Tag == dwarf::DW_TAG_subprogram &&
214 Context.getTag() != dwarf::DW_TAG_structure_type &&
215 Context.getTag() != dwarf::DW_TAG_class_type) ||
216 (
Tag == dwarf::DW_TAG_union_type))
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.