Skip to content

Commit 269f30f

Browse files
committed
[ClangImporter] Add a way to determine whether type is NSNotificationName
1 parent b98d7a5 commit 269f30f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/ClangImporter/ClangAdapter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,13 @@ bool importer::isNSString(clang::QualType qt) {
590590
return qt.getTypePtrOrNull() && isNSString(qt.getTypePtrOrNull());
591591
}
592592

593+
bool importer::isNSNotificationName(clang::QualType type) {
594+
if (auto *typealias = type->getAs<clang::TypedefType>()) {
595+
return typealias->getDecl()->getName() == "NSNotificationName";
596+
}
597+
return false;
598+
}
599+
593600
bool importer::isNSNotificationGlobal(const clang::NamedDecl *decl) {
594601
// Looking for: extern NSString *fooNotification;
595602

lib/ClangImporter/ClangAdapter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ clang::TypedefNameDecl *findSwiftNewtype(const clang::NamedDecl *decl,
129129
bool isNSString(const clang::Type *);
130130
bool isNSString(clang::QualType);
131131

132+
/// Wehther the passed type is `NSNotificationName` typealias
133+
bool isNSNotificationName(clang::QualType);
134+
132135
/// Whether the given declaration was exported from Swift.
133136
///
134137
/// Note that this only checks the immediate declaration being passed.

0 commit comments

Comments
 (0)