ABI Checker: diagnose underlying type changes of opaque result types from inlinable decls.

Inlinable decls from swift interface files allow us to construct the underlying types
of opaque result types, whose changes can break ABI.

rdar://52273137
This commit is contained in:
Xi Ge
2019-07-01 11:57:55 -07:00
parent 9ee0a293b7
commit e99fac01ed
4 changed files with 52 additions and 0 deletions

View File

@@ -1368,6 +1368,19 @@ SDKNode *swift::ide::api::
SwiftDeclCollector::constructTypeNode(Type T, TypeInitInfo Info) {
if (Ctx.checkingABI()) {
T = T->getCanonicalType();
// If the type is a opaque result type (some Type) and we're in the ABI mode,
// we should substitute the opaque result type to its underlying type.
// Notice this only works if the opaque result type is from an inlinable
// function where the function body is present in the swift module file, thus
// allowing us to know the concrete type.
if (auto OTA = T->getAs<OpaqueTypeArchetypeType>()) {
if (auto *D = OTA->getDecl()) {
if (auto SubMap = D->getUnderlyingTypeSubstitutions()) {
T = Type(D->getUnderlyingInterfaceType()).
subst(*SubMap)->getCanonicalType();
}
}
}
}
if (auto NAT = dyn_cast<TypeAliasType>(T.getPointer())) {