Skip to content

Commit 38477ad

Browse files
committed
ClangImporter: Replace some calls to getDeclaredType() with getDeclaredInterfaceType()
1 parent 0ef12ec commit 38477ad

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ synthesizeEnumRawValueGetterBody(AbstractFunctionDecl *afd, void *context) {
552552
auto getterDecl = cast<AccessorDecl>(afd);
553553
auto enumDecl = static_cast<EnumDecl *>(context);
554554
auto rawTy = enumDecl->getRawType();
555-
auto enumTy = enumDecl->getDeclaredType();
555+
auto enumTy = enumDecl->getDeclaredInterfaceType();
556556

557557
ASTContext &ctx = getterDecl->getASTContext();
558558
auto *selfDecl = getterDecl->getImplicitSelfDecl();
@@ -1892,7 +1892,7 @@ static bool addErrorDomain(NominalTypeDecl *swiftDecl,
18921892
auto &C = importer.SwiftContext;
18931893
auto swiftValueDecl = dyn_cast_or_null<ValueDecl>(
18941894
importer.importDecl(errorDomainDecl, importer.CurrentVersion));
1895-
auto stringTy = C.getStringDecl()->getDeclaredType();
1895+
auto stringTy = C.getStringDecl()->getDeclaredInterfaceType();
18961896
assert(stringTy && "no string type available");
18971897
if (!swiftValueDecl || !swiftValueDecl->getInterfaceType()->isEqual(stringTy)) {
18981898
// Couldn't actually import it as an error enum, fall back to enum
@@ -6962,7 +6962,8 @@ void SwiftDeclConverter::importObjCProtocols(
69626962
if (auto proto = castIgnoringCompatibilityAlias<ProtocolDecl>(
69636963
Impl.importDecl(*cp, getActiveSwiftVersion()))) {
69646964
addProtocols(proto, protocols, knownProtocols);
6965-
inheritedTypes.push_back(TypeLoc::withoutLoc(proto->getDeclaredType()));
6965+
inheritedTypes.push_back(
6966+
TypeLoc::withoutLoc(proto->getDeclaredInterfaceType()));
69666967
}
69676968
}
69686969

@@ -7013,7 +7014,8 @@ Optional<GenericParamList *> SwiftDeclConverter::importObjCGenericParams(
70137014
if (!proto) {
70147015
return None;
70157016
}
7016-
inherited.push_back(TypeLoc::withoutLoc(proto->getDeclaredType()));
7017+
inherited.push_back(
7018+
TypeLoc::withoutLoc(proto->getDeclaredInterfaceType()));
70177019
}
70187020
}
70197021
if (inherited.empty()) {

lib/ClangImporter/ImportMacro.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,38 +558,38 @@ static ValueDecl *importMacro(ClangImporter::Implementation &impl,
558558
} else if (tokenI[1].is(clang::tok::pipepipe)) {
559559
bool result = firstValue.getBoolValue() || secondValue.getBoolValue();
560560
resultValue = llvm::APSInt::get(result);
561-
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredType();
561+
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredInterfaceType();
562562

563563
// Logical AND.
564564
} else if (tokenI[1].is(clang::tok::ampamp)) {
565565
bool result = firstValue.getBoolValue() && secondValue.getBoolValue();
566566
resultValue = llvm::APSInt::get(result);
567-
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredType();
567+
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredInterfaceType();
568568

569569
// Equality.
570570
} else if (tokenI[1].is(clang::tok::equalequal)) {
571571
resultValue = llvm::APSInt::get(firstValue == secondValue);
572-
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredType();
572+
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredInterfaceType();
573573

574574
// Less than.
575575
} else if (tokenI[1].is(clang::tok::less)) {
576576
resultValue = llvm::APSInt::get(firstValue < secondValue);
577-
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredType();
577+
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredInterfaceType();
578578

579579
// Less than or equal.
580580
} else if (tokenI[1].is(clang::tok::lessequal)) {
581581
resultValue = llvm::APSInt::get(firstValue <= secondValue);
582-
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredType();
582+
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredInterfaceType();
583583

584584
// Greater than.
585585
} else if (tokenI[1].is(clang::tok::greater)) {
586586
resultValue = llvm::APSInt::get(firstValue > secondValue);
587-
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredType();
587+
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredInterfaceType();
588588

589589
// Greater than or equal.
590590
} else if (tokenI[1].is(clang::tok::greaterequal)) {
591591
resultValue = llvm::APSInt::get(firstValue >= secondValue);
592-
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredType();
592+
resultSwiftType = impl.SwiftContext.getBoolDecl()->getDeclaredInterfaceType();
593593

594594
// Unhandled operators.
595595
} else {

lib/ClangImporter/ImportType.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ namespace {
180180
if (!opaquePointer) {
181181
return Type();
182182
}
183-
return {opaquePointer->getDeclaredType(),
183+
return {opaquePointer->getDeclaredInterfaceType(),
184184
type.isReferenceType() ? ImportHint::None
185185
: ImportHint::OtherPointer};
186186
}
@@ -417,7 +417,7 @@ namespace {
417417
: Impl.SwiftContext.getUnsafeMutableRawPointerDecl());
418418
if (!pointerTypeDecl)
419419
return Type();
420-
return {pointerTypeDecl->getDeclaredType(),
420+
return {pointerTypeDecl->getDeclaredInterfaceType(),
421421
ImportHint::OtherPointer};
422422
}
423423

@@ -964,7 +964,7 @@ namespace {
964964
memberTypes.push_back(superclassType);
965965

966966
for (auto protocolDecl : typeParam->getConformingProtocols())
967-
memberTypes.push_back(protocolDecl->getDeclaredType());
967+
memberTypes.push_back(protocolDecl->getDeclaredInterfaceType());
968968

969969
bool hasExplicitAnyObject = false;
970970
if (memberTypes.empty())
@@ -980,7 +980,7 @@ namespace {
980980
importedType = BoundGenericClassType::get(
981981
imported, nullptr, importedTypeArgs);
982982
} else {
983-
importedType = imported->getDeclaredType();
983+
importedType = imported->getDeclaredInterfaceType();
984984
}
985985

986986
if (!type->qual_empty()) {
@@ -1028,7 +1028,7 @@ namespace {
10281028
if (auto objcClassDef = objcClass->getDefinition())
10291029
bridgedType = mapSwiftBridgeAttr(objcClassDef);
10301030
else if (objcClass->getName() == "NSString")
1031-
bridgedType = Impl.SwiftContext.getStringDecl()->getDeclaredType();
1031+
bridgedType = Impl.SwiftContext.getStringDecl()->getDeclaredInterfaceType();
10321032

10331033
if (bridgedType) {
10341034
// Gather the type arguments.
@@ -1083,7 +1083,7 @@ namespace {
10831083
keyStructDecl == Impl.SwiftContext.getDictionaryDecl() ||
10841084
keyStructDecl == Impl.SwiftContext.getArrayDecl()) {
10851085
if (auto anyHashable = Impl.SwiftContext.getAnyHashableDecl())
1086-
keyType = anyHashable->getDeclaredType();
1086+
keyType = anyHashable->getDeclaredInterfaceType();
10871087
else
10881088
keyType = Type();
10891089
}
@@ -1124,7 +1124,7 @@ namespace {
11241124
if (!proto)
11251125
return Type();
11261126

1127-
members.push_back(proto->getDeclaredType());
1127+
members.push_back(proto->getDeclaredInterfaceType());
11281128
}
11291129

11301130
importedType = ProtocolCompositionType::get(Impl.SwiftContext,
@@ -1409,14 +1409,14 @@ static ImportedType adjustTypeForConcreteImport(
14091409
// Turn BOOL and DarwinBoolean into Bool in contexts that can bridge types
14101410
// losslessly.
14111411
if (bridging == Bridgeability::Full && canBridgeTypes(importKind))
1412-
importedType = impl.SwiftContext.getBoolDecl()->getDeclaredType();
1412+
importedType = impl.SwiftContext.getBoolDecl()->getDeclaredInterfaceType();
14131413
break;
14141414

14151415
case ImportHint::NSUInteger:
14161416
// When NSUInteger is used as an enum's underlying type or if it does not
14171417
// come from a system module, make sure it stays unsigned.
14181418
if (importKind == ImportTypeKind::Enum || !allowNSUIntegerAsInt)
1419-
importedType = impl.SwiftContext.getUIntDecl()->getDeclaredType();
1419+
importedType = impl.SwiftContext.getUIntDecl()->getDeclaredInterfaceType();
14201420
break;
14211421

14221422
case ImportHint::CFPointer:
@@ -1647,7 +1647,7 @@ ImportedType ClangImporter::Implementation::importFunctionReturnType(
16471647
switch (getClangASTContext().BuiltinInfo.getTypeString(builtinID)[0]) {
16481648
case 'z': // size_t
16491649
case 'Y': // ptrdiff_t
1650-
return {SwiftContext.getIntDecl()->getDeclaredType(), false};
1650+
return {SwiftContext.getIntDecl()->getDeclaredInterfaceType(), false};
16511651
default:
16521652
break;
16531653
}
@@ -2462,7 +2462,7 @@ Type ClangImporter::Implementation::getNSObjectType() {
24622462
return NSObjectTy;
24632463

24642464
if (auto decl = dyn_cast_or_null<ClassDecl>(importDeclByName("NSObject"))) {
2465-
NSObjectTy = decl->getDeclaredType();
2465+
NSObjectTy = decl->getDeclaredInterfaceType();
24662466
return NSObjectTy;
24672467
}
24682468

@@ -2528,7 +2528,7 @@ static Type getNamedProtocolType(ClangImporter::Implementation &impl,
25282528
impl.importDecl(decl->getUnderlyingDecl(), impl.CurrentVersion)) {
25292529
if (auto protoDecl =
25302530
dynCastIgnoringCompatibilityAlias<ProtocolDecl>(swiftDecl)) {
2531-
return protoDecl->getDeclaredType();
2531+
return protoDecl->getDeclaredInterfaceType();
25322532
}
25332533
}
25342534
}

0 commit comments

Comments
 (0)