Skip to content

Commit d0149ac

Browse files
committed
[llvm][dsymutil] Rename DeclContext::Name to NameForUniquing
Better describes what the `Name` field is. I'm also planning on adding a new `Name` field to the `DeclContext`, so I wanted to differentiate the two.
1 parent 2f87c78 commit d0149ac

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ class DeclContext {
8484
DeclContext() : DefinedInClangModule(0), Parent(*this) {}
8585

8686
DeclContext(unsigned Hash, uint32_t Line, uint32_t ByteSize, uint16_t Tag,
87-
StringRef Name, StringRef File, const DeclContext &Parent,
88-
DWARFDie LastSeenDIE = DWARFDie(), unsigned CUId = 0)
87+
StringRef NameForUniquing, StringRef File,
88+
const DeclContext &Parent, DWARFDie LastSeenDIE = DWARFDie(),
89+
unsigned CUId = 0)
8990
: QualifiedNameHash(Hash), Line(Line), ByteSize(ByteSize), Tag(Tag),
90-
DefinedInClangModule(0), Name(Name), File(File), Parent(Parent),
91-
LastSeenDIE(LastSeenDIE), LastSeenCompileUnitID(CUId) {}
91+
DefinedInClangModule(0), NameForUniquing(NameForUniquing), File(File),
92+
Parent(Parent), LastSeenDIE(LastSeenDIE), LastSeenCompileUnitID(CUId) {}
9293

9394
uint32_t getQualifiedNameHash() const { return QualifiedNameHash; }
9495

@@ -114,7 +115,7 @@ class DeclContext {
114115
uint32_t ByteSize = 0;
115116
uint16_t Tag = dwarf::DW_TAG_compile_unit;
116117
unsigned DefinedInClangModule : 1;
117-
StringRef Name;
118+
StringRef NameForUniquing;
118119
StringRef File;
119120
const DeclContext &Parent;
120121
DWARFDie LastSeenDIE;
@@ -180,7 +181,7 @@ struct DeclMapInfo : private DenseMapInfo<DeclContext *> {
180181
return RHS == LHS;
181182
return LHS->QualifiedNameHash == RHS->QualifiedNameHash &&
182183
LHS->Line == RHS->Line && LHS->ByteSize == RHS->ByteSize &&
183-
LHS->Name.data() == RHS->Name.data() &&
184+
LHS->NameForUniquing.data() == RHS->NameForUniquing.data() &&
184185
LHS->File.data() == RHS->File.data() &&
185186
LHS->Parent.QualifiedNameHash == RHS->Parent.QualifiedNameHash;
186187
}

llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,25 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
8484
break;
8585
}
8686

87-
StringRef NameRef;
87+
StringRef NameForUniquing;
8888
StringRef FileRef;
8989

9090
if (const char *LinkageName = DIE.getLinkageName())
91-
NameRef = StringPool.internString(LinkageName);
91+
NameForUniquing = StringPool.internString(LinkageName);
9292
else if (const char *ShortName = DIE.getShortName())
93-
NameRef = StringPool.internString(ShortName);
93+
NameForUniquing = StringPool.internString(ShortName);
9494

95-
bool IsAnonymousNamespace = NameRef.empty() && Tag == dwarf::DW_TAG_namespace;
95+
bool IsAnonymousNamespace =
96+
NameForUniquing.empty() && Tag == dwarf::DW_TAG_namespace;
9697
if (IsAnonymousNamespace) {
9798
// FIXME: For dsymutil-classic compatibility. I think uniquing within
9899
// anonymous namespaces is wrong. There is no ODR guarantee there.
99-
NameRef = "(anonymous namespace)";
100+
NameForUniquing = "(anonymous namespace)";
100101
}
101102

102103
if (Tag != dwarf::DW_TAG_class_type && Tag != dwarf::DW_TAG_structure_type &&
103104
Tag != dwarf::DW_TAG_union_type &&
104-
Tag != dwarf::DW_TAG_enumeration_type && NameRef.empty())
105+
Tag != dwarf::DW_TAG_enumeration_type && NameForUniquing.empty())
105106
return PointerIntPair<DeclContext *, 1>(nullptr);
106107

107108
unsigned Line = 0;
@@ -140,10 +141,10 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
140141
}
141142
}
142143

143-
if (!Line && NameRef.empty())
144+
if (!Line && NameForUniquing.empty())
144145
return PointerIntPair<DeclContext *, 1>(nullptr);
145146

146-
// We hash NameRef, which is the mangled name, in order to get most
147+
// We hash NameForUniquing, which is the mangled name, in order to get most
147148
// overloaded functions resolve correctly.
148149
//
149150
// Strictly speaking, hashing the Tag is only necessary for a
@@ -153,23 +154,24 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
153154
// FIXME: dsymutil-classic won't unique the same type presented
154155
// once as a struct and once as a class. Using the Tag in the fully
155156
// qualified name hash to get the same effect.
156-
unsigned Hash = hash_combine(Context.getQualifiedNameHash(), Tag, NameRef);
157+
unsigned Hash =
158+
hash_combine(Context.getQualifiedNameHash(), Tag, NameForUniquing);
157159

158160
// FIXME: dsymutil-classic compatibility: when we don't have a name,
159161
// use the filename.
160162
if (IsAnonymousNamespace)
161163
Hash = hash_combine(Hash, FileRef);
162164

163165
// Now look if this context already exists.
164-
DeclContext Key(Hash, Line, ByteSize, Tag, NameRef, FileRef, Context);
166+
DeclContext Key(Hash, Line, ByteSize, Tag, NameForUniquing, FileRef, Context);
165167
auto ContextIter = Contexts.find(&Key);
166168

167169
if (ContextIter == Contexts.end()) {
168170
// The context wasn't found.
169171
bool Inserted;
170172
DeclContext *NewContext =
171-
new (Allocator) DeclContext(Hash, Line, ByteSize, Tag, NameRef, FileRef,
172-
Context, DIE, U.getUniqueID());
173+
new (Allocator) DeclContext(Hash, Line, ByteSize, Tag, NameForUniquing,
174+
FileRef, Context, DIE, U.getUniqueID());
173175
std::tie(ContextIter, Inserted) = Contexts.insert(NewContext);
174176
assert(Inserted && "Failed to insert DeclContext");
175177
(void)Inserted;

0 commit comments

Comments
 (0)