Skip to content

Commit bc398ae

Browse files
committed
RequirementMachine: Make Symbols hashable
1 parent 92ac06a commit bc398ae

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/AST/RequirementMachine/Symbol.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ class Symbol final {
163163
return Ptr;
164164
}
165165

166+
static Symbol fromOpaquePointer(void *ptr) {
167+
return Symbol((Storage *) ptr);
168+
}
169+
166170
static Symbol forName(Identifier name,
167171
RewriteContext &ctx);
168172

@@ -223,4 +227,24 @@ class Symbol final {
223227

224228
} // end namespace swift
225229

230+
namespace llvm {
231+
template<> struct DenseMapInfo<swift::rewriting::Symbol> {
232+
static swift::rewriting::Symbol getEmptyKey() {
233+
return swift::rewriting::Symbol::fromOpaquePointer(
234+
llvm::DenseMapInfo<void *>::getEmptyKey());
235+
}
236+
static swift::rewriting::Symbol getTombstoneKey() {
237+
return swift::rewriting::Symbol::fromOpaquePointer(
238+
llvm::DenseMapInfo<void *>::getTombstoneKey());
239+
}
240+
static unsigned getHashValue(swift::rewriting::Symbol Val) {
241+
return DenseMapInfo<void *>::getHashValue(Val.getOpaquePointer());
242+
}
243+
static bool isEqual(swift::rewriting::Symbol LHS,
244+
swift::rewriting::Symbol RHS) {
245+
return LHS == RHS;
246+
}
247+
};
248+
} // end namespace llvm
249+
226250
#endif

0 commit comments

Comments
 (0)