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:
92 NameForUniquing = StringPool.internString(
LinkageName);
93 else if (!Name.empty())
94 NameForUniquing = StringPool.internString(Name);
96 bool IsAnonymousNamespace =
97 NameForUniquing.
empty() &&
Tag == dwarf::DW_TAG_namespace;
98 if (IsAnonymousNamespace) {
101 NameForUniquing =
"(anonymous namespace)";
104 if (
Tag != dwarf::DW_TAG_class_type &&
Tag != dwarf::DW_TAG_structure_type &&
105 Tag != dwarf::DW_TAG_union_type &&
106 Tag != dwarf::DW_TAG_enumeration_type && NameForUniquing.
empty())
110 unsigned ByteSize = std::numeric_limits<uint32_t>::max();
112 if (!InClangModule) {
122 std::numeric_limits<uint64_t>::max());
123 if (
Tag != dwarf::DW_TAG_namespace || IsAnonymousNamespace) {
124 if (
unsigned FileNum =
126 if (
const auto *LT = U.getOrigUnit().getContext().getLineTableForUnit(
131 if (IsAnonymousNamespace)
134 if (LT->hasFileAtIndex(FileNum)) {
138 FileRef = getResolvedPath(U, FileNum, *LT);
145 if (!Line && NameForUniquing.
empty())
163 if (IsAnonymousNamespace)
169 auto ContextIter = Contexts.find(&
Key);
171 if (ContextIter == Contexts.end()) {
175 DeclContext(Hash, Line, ByteSize,
Tag, Name, NameForUniquing, FileRef,
176 Context,
DIE, U.getUniqueID());
177 std::tie(ContextIter, Inserted) = Contexts.insert(NewContext);
178 assert(Inserted &&
"Failed to insert DeclContext");
180 }
else if (
Tag != dwarf::DW_TAG_namespace &&
181 !(*ContextIter)->setLastSeenDIE(U,
DIE)) {
187 assert(ContextIter != Contexts.end());
190 if ((
Tag == dwarf::DW_TAG_subprogram &&
191 Context.getTag() != dwarf::DW_TAG_structure_type &&
192 Context.getTag() != dwarf::DW_TAG_class_type) ||
193 (
Tag == dwarf::DW_TAG_union_type))
202 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.