@@ -7022,26 +7022,23 @@ void ClangImporter::withSymbolicFeatureEnabled(
7022
7022
oldImportSymbolicCXXDecls.get ());
7023
7023
}
7024
7024
7025
- const clang::TypedefType *ClangImporter::getTypeDefForCXXCFOptionsDefinition (
7026
- const clang::Decl *candidateDecl) {
7027
-
7028
- if (!Impl.SwiftContext .LangOpts .EnableCXXInterop )
7025
+ const clang::TypedefType *ClangImporter::getTypedefForCXXCFOptionsDefinition (
7026
+ const clang::Decl *candidateDecl, const ASTContext &ctx) {
7027
+ if (!ctx.LangOpts .EnableCXXInterop )
7029
7028
return nullptr ;
7030
7029
7031
7030
auto enumDecl = dyn_cast<clang::EnumDecl>(candidateDecl);
7032
7031
if (!enumDecl)
7033
7032
return nullptr ;
7034
-
7035
7033
if (!enumDecl->getDeclName ().isEmpty ())
7036
7034
return nullptr ;
7037
7035
7038
7036
const clang::ElaboratedType *elaboratedType =
7039
- dyn_cast <clang::ElaboratedType>(enumDecl-> getIntegerType (). getTypePtr () );
7037
+ enumDecl-> getIntegerType ()-> getAs <clang::ElaboratedType>();
7040
7038
if (auto typedefType =
7041
7039
elaboratedType
7042
7040
? dyn_cast<clang::TypedefType>(elaboratedType->desugar ())
7043
- : dyn_cast<clang::TypedefType>(
7044
- enumDecl->getIntegerType ().getTypePtr ())) {
7041
+ : enumDecl->getIntegerType ()->getAs <clang::TypedefType>()) {
7045
7042
auto enumExtensibilityAttr =
7046
7043
elaboratedType
7047
7044
? enumDecl->getAttr <clang::EnumExtensibilityAttr>()
@@ -7054,8 +7051,13 @@ const clang::TypedefType *ClangImporter::getTypeDefForCXXCFOptionsDefinition(
7054
7051
enumExtensibilityAttr->getExtensibility () ==
7055
7052
clang::EnumExtensibilityAttr::Open &&
7056
7053
hasFlagEnumAttr) {
7057
- return Impl.isUnavailableInSwift (typedefType->getDecl ()) ? typedefType
7058
- : nullptr ;
7054
+ // Make sure the typedef is marked as unavailable in Swift.
7055
+ auto typedefDecl = typedefType->getDecl ();
7056
+ for (auto *attr :
7057
+ typedefDecl->specific_attrs <clang::AvailabilityAttr>()) {
7058
+ if (attr->getPlatform ()->getName () == " swift" )
7059
+ return typedefType;
7060
+ }
7059
7061
}
7060
7062
}
7061
7063
0 commit comments