Skip to content

Commit f40ae37

Browse files
authored
Merge pull request #6721 from jrose-apple/PointerLikeTypeTraits-DeclName
Pull PointerLikeTypeTraits<DeclName> up to Identifier.h
2 parents 2ebdb7f + c011aa0 commit f40ae37

File tree

3 files changed

+29
-33
lines changed

3 files changed

+29
-33
lines changed

include/swift/AST/Identifier.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,20 @@ class ObjCSelector {
510510
} // end namespace swift
511511

512512
namespace llvm {
513+
// A DeclName is "pointer like".
514+
template<typename T> class PointerLikeTypeTraits;
515+
template<>
516+
class PointerLikeTypeTraits<swift::DeclName> {
517+
public:
518+
static inline void *getAsVoidPointer(swift::DeclName name) {
519+
return name.getOpaqueValue();
520+
}
521+
static inline swift::DeclName getFromVoidPointer(void *ptr) {
522+
return swift::DeclName::getFromOpaqueValue(ptr);
523+
}
524+
enum { NumLowBitsAvailable = 0 };
525+
};
526+
513527
// DeclNames hash just like pointers.
514528
template<> struct DenseMapInfo<swift::DeclName> {
515529
static swift::DeclName getEmptyKey() {
@@ -524,7 +538,21 @@ namespace llvm {
524538
static bool isEqual(swift::DeclName LHS, swift::DeclName RHS) {
525539
return LHS.getOpaqueValue() == RHS.getOpaqueValue();
526540
}
527-
};
541+
};
542+
543+
// An ObjCSelector is "pointer like".
544+
template<typename T> class PointerLikeTypeTraits;
545+
template<>
546+
class PointerLikeTypeTraits<swift::ObjCSelector> {
547+
public:
548+
static inline void *getAsVoidPointer(swift::ObjCSelector name) {
549+
return name.getOpaqueValue();
550+
}
551+
static inline swift::ObjCSelector getFromVoidPointer(void *ptr) {
552+
return swift::ObjCSelector::getFromOpaqueValue(ptr);
553+
}
554+
enum { NumLowBitsAvailable = 0 };
555+
};
528556

529557
// ObjCSelectors hash just like pointers.
530558
template<> struct DenseMapInfo<swift::ObjCSelector> {

lib/ClangImporter/ClangImporter.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,22 +1323,6 @@ ClangImporter::Implementation::exportName(Identifier name) {
13231323
return ident;
13241324
}
13251325

1326-
namespace llvm {
1327-
// An Identifier is "pointer like".
1328-
template<typename T> class PointerLikeTypeTraits;
1329-
template<>
1330-
class PointerLikeTypeTraits<swift::DeclName> {
1331-
public:
1332-
static inline void *getAsVoidPointer(swift::DeclName name) {
1333-
return name.getOpaqueValue();
1334-
}
1335-
static inline swift::DeclName getFromVoidPointer(void *ptr) {
1336-
return swift::DeclName::getFromOpaqueValue(ptr);
1337-
}
1338-
enum { NumLowBitsAvailable = 0 };
1339-
};
1340-
} // namespace llvm
1341-
13421326
Identifier
13431327
ClangImporter::Implementation::importIdentifier(
13441328
const clang::IdentifierInfo *identifier,

lib/ClangImporter/ImportName.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -397,22 +397,6 @@ void ClangImporter::Implementation::printSwiftName(ImportedName name,
397397
os << ")";
398398
}
399399

400-
namespace llvm {
401-
// An Identifier is "pointer like".
402-
template<typename T> class PointerLikeTypeTraits;
403-
template<>
404-
class PointerLikeTypeTraits<swift::DeclName> {
405-
public:
406-
static inline void *getAsVoidPointer(swift::DeclName name) {
407-
return name.getOpaqueValue();
408-
}
409-
static inline swift::DeclName getFromVoidPointer(void *ptr) {
410-
return swift::DeclName::getFromOpaqueValue(ptr);
411-
}
412-
enum { NumLowBitsAvailable = 0 };
413-
};
414-
} // namespace llvm
415-
416400
/// Retrieve the name of the given Clang declaration context for
417401
/// printing.
418402
static StringRef getClangDeclContextName(const clang::DeclContext *dc) {

0 commit comments

Comments
 (0)