Skip to content

Commit f926a5b

Browse files
committed
[AST] Use a proper “empty key” encoding for CanType in DenseMaps.
… rather than co-opting NULL, which is a valid CanType type.
1 parent 0353bc1 commit f926a5b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

include/swift/AST/Type.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ namespace llvm {
647647
template<> struct DenseMapInfo<swift::CanType>
648648
: public DenseMapInfo<swift::Type> {
649649
static swift::CanType getEmptyKey() {
650-
return swift::CanType(nullptr);
650+
return swift::CanType(llvm::DenseMapInfo<swift::
651+
TypeBase*>::getEmptyKey());
651652
}
652653
static swift::CanType getTombstoneKey() {
653654
return swift::CanType(llvm::DenseMapInfo<swift::

include/swift/AST/Types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5281,6 +5281,7 @@ inline CanType CanType::getNominalParent() const {
52815281

52825282
inline bool CanType::isActuallyCanonicalOrNull() const {
52835283
return getPointer() == nullptr ||
5284+
getPointer() == llvm::DenseMapInfo<TypeBase *>::getEmptyKey() ||
52845285
getPointer() == llvm::DenseMapInfo<TypeBase *>::getTombstoneKey() ||
52855286
getPointer()->isCanonical();
52865287
}

0 commit comments

Comments
 (0)