Skip to content

Commit 192c52f

Browse files
committed
[NFC] Integrate ImportTypeAttrs into importType()
1 parent 8e85e1e commit 192c52f

File tree

4 files changed

+81
-64
lines changed

4 files changed

+81
-64
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,7 +2848,8 @@ namespace {
28482848
SwiftType = Impl.importTypeIgnoreIUO(
28492849
ClangType, ImportTypeKind::Typedef,
28502850
ImportDiagnosticAdder(Impl, Decl, Decl->getLocation()),
2851-
isInSystemModule(DC), getTypedefBridgeability(Decl), OTK_Optional);
2851+
isInSystemModule(DC), getTypedefBridgeability(Decl),
2852+
getImportTypeAttrs(Decl), OTK_Optional);
28522853
}
28532854

28542855
if (!SwiftType)
@@ -2862,14 +2863,6 @@ namespace {
28622863
Loc,
28632864
/*genericparams*/nullptr, DC);
28642865

2865-
// If the typedef is marked with @Sendable and not @_nonSendable, make
2866-
// any function type in it Sendable.
2867-
auto sendability = Result->getAttrs().getEffectiveSendableAttr();
2868-
if (isa_and_nonnull<SendableAttr>(sendability))
2869-
SwiftType = applyToFunctionType(SwiftType, [](ASTExtInfo info) {
2870-
return info.withConcurrent();
2871-
});
2872-
28732866
Result->setUnderlyingType(SwiftType);
28742867

28752868
// Make Objective-C's 'id' unavailable.
@@ -2967,7 +2960,7 @@ namespace {
29672960
// Compute the underlying type of the enumeration.
29682961
auto underlyingType = Impl.importTypeIgnoreIUO(
29692962
decl->getIntegerType(), ImportTypeKind::Enum, addDiag,
2970-
isInSystemModule(dc), Bridgeability::None);
2963+
isInSystemModule(dc), Bridgeability::None, ImportTypeAttrs());
29712964
if (!underlyingType)
29722965
return nullptr;
29732966

@@ -3000,7 +2993,7 @@ namespace {
30002993
// Compute the underlying type.
30012994
auto underlyingType = Impl.importTypeIgnoreIUO(
30022995
decl->getIntegerType(), ImportTypeKind::Enum, addDiag,
3003-
isInSystemModule(dc), Bridgeability::None);
2996+
isInSystemModule(dc), Bridgeability::None, ImportTypeAttrs());
30042997
if (!underlyingType)
30052998
return nullptr;
30062999

@@ -3932,7 +3925,7 @@ namespace {
39323925
auto type = Impl.importTypeIgnoreIUO(
39333926
clangContext.getTagDeclType(clangEnum), ImportTypeKind::Value,
39343927
ImportDiagnosticAdder(Impl, clangEnum, clangEnum->getLocation()),
3935-
isInSystemModule(dc), Bridgeability::None);
3928+
isInSystemModule(dc), Bridgeability::None, ImportTypeAttrs());
39363929
if (!type)
39373930
return nullptr;
39383931

@@ -3999,7 +3992,8 @@ namespace {
39993992
auto importedType =
40003993
Impl.importType(decl->getType(), ImportTypeKind::Variable,
40013994
ImportDiagnosticAdder(Impl, decl, decl->getLocation()),
4002-
isInSystemModule(dc), Bridgeability::None);
3995+
isInSystemModule(dc), Bridgeability::None,
3996+
ImportTypeAttrs());
40033997
if (!importedType)
40043998
return nullptr;
40053999

@@ -4522,7 +4516,8 @@ namespace {
45224516
auto importedType =
45234517
Impl.importType(decl->getType(), ImportTypeKind::RecordField,
45244518
ImportDiagnosticAdder(Impl, decl, decl->getLocation()),
4525-
isInSystemModule(dc), Bridgeability::None);
4519+
isInSystemModule(dc), Bridgeability::None,
4520+
ImportTypeAttrs());
45264521
if (!importedType) {
45274522
Impl.addImportDiagnostic(
45284523
decl, Diagnostic(diag::record_field_not_imported, decl),
@@ -4649,7 +4644,8 @@ namespace {
46494644
(isAudited ? ImportTypeKind::AuditedVariable
46504645
: ImportTypeKind::Variable),
46514646
ImportDiagnosticAdder(Impl, decl, decl->getLocation()),
4652-
isInSystemModule(dc), Bridgeability::None);
4647+
isInSystemModule(dc), Bridgeability::None,
4648+
ImportTypeAttrs());
46534649

46544650
if (!importedType)
46554651
return nullptr;
@@ -5852,7 +5848,7 @@ namespace {
58525848
superclassType = Impl.importTypeIgnoreIUO(
58535849
clangSuperclassType, ImportTypeKind::Abstract,
58545850
ImportDiagnosticAdder(Impl, decl, decl->getLocation()),
5855-
isInSystemModule(dc), Bridgeability::None);
5851+
isInSystemModule(dc), Bridgeability::None, ImportTypeAttrs());
58565852
if (superclassType) {
58575853
assert(superclassType->is<ClassType>() ||
58585854
superclassType->is<BoundGenericClassType>());
@@ -6449,7 +6445,7 @@ SwiftDeclConverter::importSwiftNewtype(const clang::TypedefNameDecl *decl,
64496445
ImportDiagnosticAdder addImportDiag(Impl, decl, decl->getLocation());
64506446
auto storedUnderlyingType = Impl.importTypeIgnoreIUO(
64516447
decl->getUnderlyingType(), ImportTypeKind::Value, addImportDiag,
6452-
isInSystemModule(dc), Bridgeability::None, OTK_None);
6448+
isInSystemModule(dc), Bridgeability::None, ImportTypeAttrs(), OTK_None);
64536449

64546450
if (!storedUnderlyingType)
64556451
return nullptr;
@@ -6470,7 +6466,7 @@ SwiftDeclConverter::importSwiftNewtype(const clang::TypedefNameDecl *decl,
64706466
// Find a bridged type, which may be different
64716467
auto computedPropertyUnderlyingType = Impl.importTypeIgnoreIUO(
64726468
decl->getUnderlyingType(), ImportTypeKind::Property, addImportDiag,
6473-
isInSystemModule(dc), Bridgeability::Full, OTK_None);
6469+
isInSystemModule(dc), Bridgeability::Full, ImportTypeAttrs(), OTK_None);
64746470
if (auto objTy = computedPropertyUnderlyingType->getOptionalObjectType())
64756471
computedPropertyUnderlyingType = objTy;
64766472

@@ -6731,7 +6727,7 @@ SwiftDeclConverter::importAsOptionSetType(DeclContext *dc, Identifier name,
67316727
auto underlyingType = Impl.importTypeIgnoreIUO(
67326728
decl->getIntegerType(), ImportTypeKind::Enum,
67336729
ImportDiagnosticAdder(Impl, decl, decl->getLocation()),
6734-
isInSystemModule(dc), Bridgeability::None);
6730+
isInSystemModule(dc), Bridgeability::None, ImportTypeAttrs());
67356731
if (!underlyingType)
67366732
return nullptr;
67376733

@@ -6952,7 +6948,7 @@ SwiftDeclConverter::getImplicitProperty(ImportedName importedName,
69526948
propertyType, ImportTypeKind::Property,
69536949
ImportDiagnosticAdder(Impl, getter, getter->getLocation()),
69546950
Impl.shouldAllowNSUIntegerAsInt(isFromSystemModule, getter),
6955-
Bridgeability::Full, OTK_ImplicitlyUnwrappedOptional);
6951+
Bridgeability::Full, ImportTypeAttrs(), OTK_ImplicitlyUnwrappedOptional);
69566952
if (!importedType)
69576953
return nullptr;
69586954

@@ -8138,7 +8134,7 @@ Optional<GenericParamList *> SwiftDeclConverter::importObjCGenericParams(
81388134
Type superclassType = Impl.importTypeIgnoreIUO(
81398135
clang::QualType(unqualifiedClangBound, 0), ImportTypeKind::Abstract,
81408136
ImportDiagnosticAdder(Impl, decl, decl->getLocation()),
8141-
false, Bridgeability::None);
8137+
false, Bridgeability::None, ImportTypeAttrs());
81428138
if (!superclassType) {
81438139
return None;
81448140
}

lib/ClangImporter/ImportMacro.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static ValueDecl *importNumericLiteral(ClangImporter::Implementation &Impl,
104104
auto literalType = Impl.importTypeIgnoreIUO(
105105
clangTy, ImportTypeKind::Value,
106106
ImportDiagnosticAdder(Impl, MI, tok.getLocation()),
107-
isInSystemModule(DC), Bridgeability::None);
107+
isInSystemModule(DC), Bridgeability::None, ImportTypeAttrs());
108108
if (!literalType)
109109
return nullptr;
110110

@@ -115,7 +115,7 @@ static ValueDecl *importNumericLiteral(ClangImporter::Implementation &Impl,
115115
constantType = Impl.importTypeIgnoreIUO(
116116
castType, ImportTypeKind::Value,
117117
ImportDiagnosticAdder(Impl, MI, MI->getDefinitionLoc()),
118-
isInSystemModule(DC), Bridgeability::None);
118+
isInSystemModule(DC), Bridgeability::None, ImportTypeAttrs());
119119
if (!constantType)
120120
return nullptr;
121121
}
@@ -322,7 +322,7 @@ static Optional<std::pair<llvm::APSInt, Type>>
322322
auto type = impl.importTypeIgnoreIUO(
323323
literal->getType(), ImportTypeKind::Value,
324324
ImportDiagnosticAdder(impl, macro, token.getLocation()),
325-
isInSystemModule(DC), Bridgeability::None);
325+
isInSystemModule(DC), Bridgeability::None, ImportTypeAttrs());
326326
return {{ value, type }};
327327
}
328328

0 commit comments

Comments
 (0)