Merge remote-tracking branch 'apple/master' into master-next

This commit is contained in:
Xi Ge
2019-10-28 10:19:36 -07:00
609 changed files with 15200 additions and 14950 deletions

View File

@@ -1851,11 +1851,10 @@ void Serializer::writePatternBindingInitializer(PatternBindingDecl *binding,
StringRef initStr;
SmallString<128> scratch;
auto &entry = binding->getPatternList()[bindingIndex];
auto varDecl = entry.getAnchoringVarDecl();
if (entry.hasInitStringRepresentation() &&
auto varDecl = binding->getAnchoringVarDecl(bindingIndex);
if (binding->hasInitStringRepresentation(bindingIndex) &&
varDecl->isInitExposedToClients()) {
initStr = entry.getInitStringRepresentation(scratch);
initStr = binding->getInitStringRepresentation(bindingIndex, scratch);
}
PatternBindingInitializerLayout::emitRecord(Out, ScratchRecord,
@@ -2594,6 +2593,24 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
return count;
}
/// Returns true if a client can still use decls that override \p overridden
/// even if \p overridden itself isn't available (isn't found, can't be
/// imported, can't be deserialized, whatever).
///
/// This should be kept conservative. Compiler crashes are still better than
/// miscompiles.
static bool overriddenDeclAffectsABI(const ValueDecl *overridden) {
if (!overridden)
return false;
// There's one case where we know a declaration doesn't affect the ABI of
// its overrides after they've been compiled: if the declaration is '@objc'
// and 'dynamic'. In that case, all accesses to the method or property will
// go through the Objective-C method tables anyway.
if (overridden->hasClangNode() || overridden->isObjCDynamic())
return false;
return true;
}
public:
DeclSerializer(Serializer &S, DeclID id) : S(S), id(id) {}
~DeclSerializer() {
@@ -2698,7 +2715,7 @@ public:
SmallVector<uint64_t, 2> initContextIDs;
for (unsigned i : range(binding->getNumPatternEntries())) {
auto initContextID =
S.addDeclContextRef(binding->getPatternList()[i].getInitContext());
S.addDeclContextRef(binding->getInitContext(i));
if (!initContextIDs.empty()) {
initContextIDs.push_back(initContextID.getOpaqueValue());
} else if (initContextID) {
@@ -2719,8 +2736,8 @@ public:
if (binding->getDeclContext()->isTypeContext())
owningDC = binding->getDeclContext();
for (auto entry : binding->getPatternList()) {
writePattern(entry.getPattern());
for (auto entryIdx : range(binding->getNumPatternEntries())) {
writePattern(binding->getPattern(entryIdx));
// Ignore initializer; external clients don't need to know about it.
}
}
@@ -3213,6 +3230,7 @@ public:
fn->isImplicitlyUnwrappedOptional(),
S.addDeclRef(fn->getOperatorDecl()),
S.addDeclRef(fn->getOverriddenDecl()),
overriddenDeclAffectsABI(fn->getOverriddenDecl()),
fn->getFullName().getArgumentNames().size() +
fn->getFullName().isCompoundName(),
rawAccessLevel,
@@ -3268,6 +3286,9 @@ public:
uint8_t rawAccessorKind =
uint8_t(getStableAccessorKind(fn->getAccessorKind()));
bool overriddenAffectsABI =
overriddenDeclAffectsABI(fn->getOverriddenDecl());
Type ty = fn->getInterfaceType();
SmallVector<IdentifierID, 4> dependencies;
for (auto dependency : collectDependenciesFromType(ty->getCanonicalType()))
@@ -3289,6 +3310,7 @@ public:
S.addTypeRef(fn->getResultInterfaceType()),
fn->isImplicitlyUnwrappedOptional(),
S.addDeclRef(fn->getOverriddenDecl()),
overriddenAffectsABI,
S.addDeclRef(fn->getStorage()),
rawAccessorKind,
rawAccessLevel,
@@ -3921,28 +3943,28 @@ public:
SmallVector<TypeID, 8> variableData;
for (auto param : fnTy->getParameters()) {
variableData.push_back(S.addTypeRef(param.getType()));
variableData.push_back(S.addTypeRef(param.getInterfaceType()));
unsigned conv = getRawStableParameterConvention(param.getConvention());
variableData.push_back(TypeID(conv));
}
for (auto yield : fnTy->getYields()) {
variableData.push_back(S.addTypeRef(yield.getType()));
variableData.push_back(S.addTypeRef(yield.getInterfaceType()));
unsigned conv = getRawStableParameterConvention(yield.getConvention());
variableData.push_back(TypeID(conv));
}
for (auto result : fnTy->getResults()) {
variableData.push_back(S.addTypeRef(result.getType()));
variableData.push_back(S.addTypeRef(result.getInterfaceType()));
unsigned conv = getRawStableResultConvention(result.getConvention());
variableData.push_back(TypeID(conv));
}
if (fnTy->hasErrorResult()) {
auto abResult = fnTy->getErrorResult();
variableData.push_back(S.addTypeRef(abResult.getType()));
variableData.push_back(S.addTypeRef(abResult.getInterfaceType()));
unsigned conv = getRawStableResultConvention(abResult.getConvention());
variableData.push_back(TypeID(conv));
}
auto sig = fnTy->getGenericSignature();
auto sig = fnTy->getSubstGenericSignature();
auto stableCoroutineKind =
getRawStableSILCoroutineKind(fnTy->getCoroutineKind());