Skip to content

Commit aa5dc6c

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 fbf4bb7 commit aa5dc6c

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
@@ -5346,6 +5346,7 @@ inline CanType CanType::getNominalParent() const {
53465346

53475347
inline bool CanType::isActuallyCanonicalOrNull() const {
53485348
return getPointer() == nullptr ||
5349+
getPointer() == llvm::DenseMapInfo<TypeBase *>::getEmptyKey() ||
53495350
getPointer() == llvm::DenseMapInfo<TypeBase *>::getTombstoneKey() ||
53505351
getPointer()->isCanonical();
53515352
}

0 commit comments

Comments
 (0)