Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion include/swift/AST/Identifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,20 @@ class ObjCSelector {
} // end namespace swift

namespace llvm {
// A DeclName is "pointer like".
template<typename T> class PointerLikeTypeTraits;
template<>
class PointerLikeTypeTraits<swift::DeclName> {
public:
static inline void *getAsVoidPointer(swift::DeclName name) {
return name.getOpaqueValue();
}
static inline swift::DeclName getFromVoidPointer(void *ptr) {
return swift::DeclName::getFromOpaqueValue(ptr);
}
enum { NumLowBitsAvailable = 0 };
};

// DeclNames hash just like pointers.
template<> struct DenseMapInfo<swift::DeclName> {
static swift::DeclName getEmptyKey() {
Expand All @@ -524,7 +538,21 @@ namespace llvm {
static bool isEqual(swift::DeclName LHS, swift::DeclName RHS) {
return LHS.getOpaqueValue() == RHS.getOpaqueValue();
}
};
};

// An ObjCSelector is "pointer like".
template<typename T> class PointerLikeTypeTraits;
template<>
class PointerLikeTypeTraits<swift::ObjCSelector> {
public:
static inline void *getAsVoidPointer(swift::ObjCSelector name) {
return name.getOpaqueValue();
}
static inline swift::ObjCSelector getFromVoidPointer(void *ptr) {
return swift::ObjCSelector::getFromOpaqueValue(ptr);
}
enum { NumLowBitsAvailable = 0 };
};

// ObjCSelectors hash just like pointers.
template<> struct DenseMapInfo<swift::ObjCSelector> {
Expand Down
16 changes: 0 additions & 16 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1323,22 +1323,6 @@ ClangImporter::Implementation::exportName(Identifier name) {
return ident;
}

namespace llvm {
// An Identifier is "pointer like".
template<typename T> class PointerLikeTypeTraits;
template<>
class PointerLikeTypeTraits<swift::DeclName> {
public:
static inline void *getAsVoidPointer(swift::DeclName name) {
return name.getOpaqueValue();
}
static inline swift::DeclName getFromVoidPointer(void *ptr) {
return swift::DeclName::getFromOpaqueValue(ptr);
}
enum { NumLowBitsAvailable = 0 };
};
} // namespace llvm

Identifier
ClangImporter::Implementation::importIdentifier(
const clang::IdentifierInfo *identifier,
Expand Down
16 changes: 0 additions & 16 deletions lib/ClangImporter/ImportName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,22 +397,6 @@ void ClangImporter::Implementation::printSwiftName(ImportedName name,
os << ")";
}

namespace llvm {
// An Identifier is "pointer like".
template<typename T> class PointerLikeTypeTraits;
template<>
class PointerLikeTypeTraits<swift::DeclName> {
public:
static inline void *getAsVoidPointer(swift::DeclName name) {
return name.getOpaqueValue();
}
static inline swift::DeclName getFromVoidPointer(void *ptr) {
return swift::DeclName::getFromOpaqueValue(ptr);
}
enum { NumLowBitsAvailable = 0 };
};
} // namespace llvm

/// Retrieve the name of the given Clang declaration context for
/// printing.
static StringRef getClangDeclContextName(const clang::DeclContext *dc) {
Expand Down