Skip to content

Commit 34c349b

Browse files
committed
---
yaml --- r: 285695 b: refs/heads/master c: ec1ab21 h: refs/heads/master i: 285693: 646abfa 285691: 1107603 285687: 8268833 285679: a72ee6c 285663: 80b8d91 285631: f6885e2 285567: 9081c32 285439: 2e0c895 285183: 94c3d90 284671: 9eeb9ff
1 parent 12d1c1a commit 34c349b

File tree

160 files changed

+1035
-2304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+1035
-2304
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1069fc2c44e8bfc0c354f7ba5bfd5856d9b449f8
2+
refs/heads/master: ec1ab21325f3903364fc8a4ee87888aae36f049f
33
refs/heads/master-next: 90f691eef4aee378af27084030679214a1a39d50
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/docs/CompilerPerformance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ $ cat /tmp/stats/*.json
717717
"AST.NumSourceLinesPerSecond": 3,
718718
"AST.NumLinkLibraries": 0,
719719
"AST.NumLoadedModules": 4,
720+
"AST.NumImportedExternalDefinitions": 0,
720721
"AST.NumTotalClangImportedEntities": 0,
721722
...
722723
"time.swift.Parsing.wall": 5.038023e-03,

trunk/include/swift/AST/ASTContext.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ class ASTContext final {
255255
#define IDENTIFIER_WITH_NAME(Name, IdStr) Identifier Id_##Name;
256256
#include "swift/AST/KnownIdentifiers.def"
257257

258+
/// The list of external definitions imported by this context.
259+
llvm::SetVector<Decl *> ExternalDefinitions;
260+
261+
/// FIXME: HACK HACK HACK
262+
/// This state should be tracked somewhere else.
263+
unsigned LastCheckedExternalDefinition = 0;
264+
258265
/// A consumer of type checker debug output.
259266
std::unique_ptr<TypeCheckerDebugConsumer> TypeCheckerDebug;
260267

@@ -573,8 +580,14 @@ class ASTContext final {
573580
ForeignLanguage language,
574581
const DeclContext *dc);
575582

583+
/// Add a declaration to a list of declarations that need to be emitted
584+
/// as part of the current module or source file, but are otherwise not
585+
/// nested within it.
586+
void addExternalDecl(Decl *decl);
587+
576588
/// Add a declaration that was synthesized to a per-source file list if
577-
/// if is part of a source file.
589+
/// if is part of a source file, or the external declarations list if
590+
/// it is part of an imported type context.
578591
void addSynthesizedDecl(Decl *decl);
579592

580593
/// Add a cleanup function to be called when the ASTContext is deallocated.

trunk/include/swift/AST/LazyResolver.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ class LazyResolver {
7474

7575
/// Resolve an implicitly-generated member with the given name.
7676
virtual void resolveImplicitMember(NominalTypeDecl *nominal, DeclName member) = 0;
77+
78+
/// Mark the given conformance as "used" from the given declaration context.
79+
virtual void markConformanceUsed(ProtocolConformanceRef conformance,
80+
DeclContext *dc) = 0;
81+
82+
/// Fill in the signature conformances of the given protocol conformance.
83+
virtual void checkConformanceRequirements(
84+
NormalProtocolConformance *conformance) = 0;
7785
};
7886

7987
class LazyMemberLoader;

trunk/include/swift/AST/ProtocolConformance.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "llvm/ADT/DenseMap.h"
2828
#include "llvm/ADT/FoldingSet.h"
2929
#include "llvm/ADT/SmallPtrSet.h"
30-
#include "llvm/ADT/TinyPtrVector.h"
3130
#include <utility>
3231

3332
namespace swift {
@@ -175,8 +174,9 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance {
175174
template<typename F>
176175
bool forEachTypeWitness(LazyResolver *resolver, F f) const {
177176
const ProtocolDecl *protocol = getProtocol();
178-
for (auto assocTypeReq : protocol->getAssociatedTypeMembers()) {
179-
if (assocTypeReq->isInvalid())
177+
for (auto req : protocol->getMembers()) {
178+
auto assocTypeReq = dyn_cast<AssociatedTypeDecl>(req);
179+
if (!assocTypeReq || req->isInvalid())
180180
continue;
181181

182182
// If we don't have and cannot resolve witnesses, skip it.

trunk/include/swift/AST/SILOptions.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,6 @@ class SILOptions {
129129
/// Emit extra exclusvity markers for memory access and verify coverage.
130130
bool VerifyExclusivity = false;
131131

132-
/// Calls to the replaced method inside of the replacement method will call
133-
/// the previous implementation.
134-
///
135-
/// @_dynamicReplacement(for: original())
136-
/// func replacement() {
137-
/// if (...)
138-
/// original() // calls original() implementation if true
139-
/// }
140-
bool EnableDynamicReplacementCanCallPreviousImplementation = true;
141-
142132
/// Enable large loadable types IRGen pass.
143133
bool EnableLargeLoadableTypes = true;
144134

trunk/include/swift/Basic/OwnedString.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ class OwnedString {
4646
return new (data) TextOwner(Text);
4747
}
4848

49-
/// Disable sized deallocation for TextOwner, because it has tail-allocated
50-
/// data.
51-
void operator delete(void *p) { ::operator delete(p); }
52-
5349
const char *getText() const { return getTrailingObjects<char>(); }
5450
};
5551

trunk/include/swift/Basic/Statistics.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ FRONTEND_STATISTIC(AST, NumLinkLibraries)
105105
/// Number of top-level modules loaded in the AST context.
106106
FRONTEND_STATISTIC(AST, NumLoadedModules)
107107

108+
/// Number of external definitions imported into the AST context.
109+
FRONTEND_STATISTIC(AST, NumImportedExternalDefinitions)
110+
108111
/// Number of Clang entities imported into the AST context.
109112
FRONTEND_STATISTIC(AST, NumTotalClangImportedEntities)
110113

trunk/include/swift/IRGen/Linking.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,11 @@ class LinkEntity {
480480
static AssociatedTypeDecl *
481481
getAssociatedTypeByIndex(const ProtocolConformance *conformance,
482482
unsigned index) {
483-
for (auto associate : conformance->getProtocol()->getAssociatedTypeMembers()) {
484-
if (index == 0) return associate;
485-
index--;
483+
for (auto requirement : conformance->getProtocol()->getMembers()) {
484+
if (auto associate = dyn_cast<AssociatedTypeDecl>(requirement)) {
485+
if (index == 0) return associate;
486+
index--;
487+
}
486488
}
487489
llvm_unreachable("didn't find associated type in protocol?");
488490
}

trunk/include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,6 @@ def enable_implicit_dynamic : Flag<["-"], "enable-implicit-dynamic">,
357357
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,
358358
HelpText<"Add 'dynamic' to all declarations">;
359359

360-
def disable_previous_implementation_calls_in_dynamic_replacements :
361-
Flag<["-"], "disable-previous-implementation-calls-in-dynamic-replacements">,
362-
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,
363-
HelpText<"Disable calling the previous implementation in dynamic replacements">;
364-
365360
def enable_dynamic_replacement_chaining :
366361
Flag<["-"], "enable-dynamic-replacement-chaining">,
367362
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,

trunk/include/swift/Option/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,4 @@ def vfsoverlay : JoinedOrSeparate<["-"], "vfsoverlay">,
888888
def vfsoverlay_EQ : Joined<["-"], "vfsoverlay=">,
889889
Alias<vfsoverlay>;
890890

891-
// Runtime compatibility version
892-
def runtime_compatibility_version : Separate<["-"], "runtime-compatibility-version">,
893-
Flags<[FrontendOption]>,
894-
HelpText<"Link compatibility library for Swift runtime version, or 'none'">;
895891
include "FrontendOptions.td"

trunk/include/swift/SIL/SILWitnessVisitor.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ template <class T> class SILWitnessVisitor : public ASTVisitor<T> {
9191
}
9292

9393
// Add the associated types.
94-
for (auto *associatedType : protocol->getAssociatedTypeMembers()) {
95-
// If this is a new associated type (which does not override an
96-
// existing associated type), add it.
97-
if (associatedType->getOverriddenDecls().empty())
98-
asDerived().addAssociatedType(AssociatedType(associatedType));
94+
for (Decl *member : protocol->getMembers()) {
95+
if (auto associatedType = dyn_cast<AssociatedTypeDecl>(member)) {
96+
// If this is a new associated type (which does not override an
97+
// existing associated type), add it.
98+
if (associatedType->getOverriddenDecls().empty())
99+
asDerived().addAssociatedType(AssociatedType(associatedType));
100+
}
99101
}
100102

101103
if (asDerived().shouldVisitRequirementSignatureOnly())

trunk/lib/AST/ASTContext.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,10 +1362,20 @@ bool ASTContext::hasArrayLiteralIntrinsics() const {
13621362
&& getDeallocateUninitializedArray();
13631363
}
13641364

1365+
void ASTContext::addExternalDecl(Decl *decl) {
1366+
ExternalDefinitions.insert(decl);
1367+
}
1368+
13651369
void ASTContext::addSynthesizedDecl(Decl *decl) {
1366-
auto *fileUnit = decl->getDeclContext()->getModuleScopeContext();
1367-
if (auto *sf = dyn_cast<SourceFile>(fileUnit))
1368-
sf->SynthesizedDecls.push_back(decl);
1370+
auto *mod = cast<FileUnit>(decl->getDeclContext()->getModuleScopeContext());
1371+
if (mod->getKind() == FileUnitKind::ClangModule ||
1372+
mod->getKind() == FileUnitKind::DWARFModule ||
1373+
mod->getKind() == FileUnitKind::SerializedAST) {
1374+
ExternalDefinitions.insert(decl);
1375+
return;
1376+
}
1377+
1378+
cast<SourceFile>(mod)->SynthesizedDecls.push_back(decl);
13691379
}
13701380

13711381
void ASTContext::addCleanup(std::function<void(void)> cleanup) {
@@ -2040,6 +2050,7 @@ ASTContext::takeDelayedConformanceDiags(NormalProtocolConformance *conformance){
20402050
size_t ASTContext::getTotalMemory() const {
20412051
size_t Size = sizeof(*this) +
20422052
// LoadedModules ?
2053+
// ExternalDefinitions ?
20432054
llvm::capacity_in_bytes(CanonicalGenericTypeParamTypeNames) +
20442055
// RemappedTypes ?
20452056
sizeof(getImpl()) +

trunk/lib/AST/GenericSignatureBuilder.cpp

Lines changed: 82 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3730,8 +3730,12 @@ GenericSignatureBuilder::lookupConformance(CanType dependentType,
37303730
// FIXME: When lookupConformance() starts respecting modules, we'll need
37313731
// to do some filtering here.
37323732
ModuleDecl *searchModule = conformedProtocol->getParentModule();
3733-
return searchModule->lookupConformance(conformingReplacementType,
3734-
conformedProtocol);
3733+
auto result = searchModule->lookupConformance(conformingReplacementType,
3734+
conformedProtocol);
3735+
if (result && getLazyResolver())
3736+
getLazyResolver()->markConformanceUsed(*result, searchModule);
3737+
3738+
return result;
37353739
}
37363740

37373741
LazyResolver *GenericSignatureBuilder::getLazyResolver() const {
@@ -4238,90 +4242,92 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
42384242
};
42394243

42404244
// Add requirements for each of the associated types.
4241-
for (auto assocTypeDecl : proto->getAssociatedTypeMembers()) {
4242-
// Add requirements placed directly on this associated type.
4243-
Type assocType =
4244-
DependentMemberType::get(selfType.getDependentType(*this), assocTypeDecl);
4245-
if (!onlySameTypeConstraints) {
4246-
auto assocResult =
4247-
addInheritedRequirements(assocTypeDecl, assocType, source,
4248-
/*inferForModule=*/nullptr);
4249-
if (isErrorResult(assocResult))
4250-
return assocResult;
4251-
}
4252-
4253-
// Add requirements from this associated type's where clause.
4254-
RequirementRequest::visitRequirements(assocTypeDecl,
4255-
TypeResolutionStage::Structural,
4256-
[&](const Requirement &req, RequirementRepr *reqRepr) {
4257-
// If we're only looking at same-type constraints, skip everything else.
4258-
if (onlySameTypeConstraints &&
4259-
req.getKind() != RequirementKind::SameType)
4245+
for (auto Member : proto->getMembers()) {
4246+
if (auto assocTypeDecl = dyn_cast<AssociatedTypeDecl>(Member)) {
4247+
// Add requirements placed directly on this associated type.
4248+
Type assocType =
4249+
DependentMemberType::get(selfType.getDependentType(*this), assocTypeDecl);
4250+
if (!onlySameTypeConstraints) {
4251+
auto assocResult =
4252+
addInheritedRequirements(assocTypeDecl, assocType, source,
4253+
/*inferForModule=*/nullptr);
4254+
if (isErrorResult(assocResult))
4255+
return assocResult;
4256+
}
4257+
4258+
// Add requirements from this associated type's where clause.
4259+
RequirementRequest::visitRequirements(assocTypeDecl,
4260+
TypeResolutionStage::Structural,
4261+
[&](const Requirement &req, RequirementRepr *reqRepr) {
4262+
// If we're only looking at same-type constraints, skip everything else.
4263+
if (onlySameTypeConstraints &&
4264+
req.getKind() != RequirementKind::SameType)
4265+
return false;
4266+
4267+
auto innerSource = FloatingRequirementSource::viaProtocolRequirement(
4268+
source, proto, reqRepr, /*inferred=*/false);
4269+
addRequirement(req, reqRepr, innerSource, &protocolSubMap,
4270+
/*inferForModule=*/nullptr);
42604271
return false;
4272+
});
42614273

4262-
auto innerSource = FloatingRequirementSource::viaProtocolRequirement(
4263-
source, proto, reqRepr, /*inferred=*/false);
4264-
addRequirement(req, reqRepr, innerSource, &protocolSubMap,
4265-
/*inferForModule=*/nullptr);
4266-
return false;
4267-
});
4274+
// Check whether we inherited any types with the same name.
4275+
auto knownInherited =
4276+
inheritedTypeDecls.find(assocTypeDecl->getFullName());
4277+
if (knownInherited == inheritedTypeDecls.end()) continue;
4278+
4279+
bool shouldWarnAboutRedeclaration =
4280+
source->kind == RequirementSource::RequirementSignatureSelf &&
4281+
!assocTypeDecl->getAttrs().hasAttribute<NonOverrideAttr>() &&
4282+
!assocTypeDecl->getAttrs().hasAttribute<OverrideAttr>() &&
4283+
!assocTypeDecl->hasDefaultDefinitionType() &&
4284+
(!assocTypeDecl->getInherited().empty() ||
4285+
assocTypeDecl->getTrailingWhereClause() ||
4286+
getASTContext().LangOpts.WarnImplicitOverrides);
4287+
for (auto inheritedType : knownInherited->second) {
4288+
// If we have inherited associated type...
4289+
if (auto inheritedAssocTypeDecl =
4290+
dyn_cast<AssociatedTypeDecl>(inheritedType)) {
4291+
// Complain about the first redeclaration.
4292+
if (shouldWarnAboutRedeclaration) {
4293+
auto inheritedFromProto = inheritedAssocTypeDecl->getProtocol();
4294+
auto fixItWhere = getProtocolWhereLoc();
4295+
Diags.diagnose(assocTypeDecl,
4296+
diag::inherited_associated_type_redecl,
4297+
assocTypeDecl->getFullName(),
4298+
inheritedFromProto->getDeclaredInterfaceType())
4299+
.fixItInsertAfter(
4300+
fixItWhere.first,
4301+
getAssociatedTypeReqs(assocTypeDecl, fixItWhere.second))
4302+
.fixItRemove(assocTypeDecl->getSourceRange());
4303+
4304+
Diags.diagnose(inheritedAssocTypeDecl, diag::decl_declared_here,
4305+
inheritedAssocTypeDecl->getFullName());
4306+
4307+
shouldWarnAboutRedeclaration = false;
4308+
}
4309+
4310+
continue;
4311+
}
42684312

4269-
// Check whether we inherited any types with the same name.
4270-
auto knownInherited =
4271-
inheritedTypeDecls.find(assocTypeDecl->getFullName());
4272-
if (knownInherited == inheritedTypeDecls.end()) continue;
4273-
4274-
bool shouldWarnAboutRedeclaration =
4275-
source->kind == RequirementSource::RequirementSignatureSelf &&
4276-
!assocTypeDecl->getAttrs().hasAttribute<NonOverrideAttr>() &&
4277-
!assocTypeDecl->getAttrs().hasAttribute<OverrideAttr>() &&
4278-
!assocTypeDecl->hasDefaultDefinitionType() &&
4279-
(!assocTypeDecl->getInherited().empty() ||
4280-
assocTypeDecl->getTrailingWhereClause() ||
4281-
getASTContext().LangOpts.WarnImplicitOverrides);
4282-
for (auto inheritedType : knownInherited->second) {
4283-
// If we have inherited associated type...
4284-
if (auto inheritedAssocTypeDecl =
4285-
dyn_cast<AssociatedTypeDecl>(inheritedType)) {
4286-
// Complain about the first redeclaration.
4287-
if (shouldWarnAboutRedeclaration) {
4288-
auto inheritedFromProto = inheritedAssocTypeDecl->getProtocol();
4289-
auto fixItWhere = getProtocolWhereLoc();
4313+
// We inherited a type; this associated type will be identical
4314+
// to that typealias.
4315+
if (source->kind == RequirementSource::RequirementSignatureSelf) {
4316+
auto inheritedOwningDecl =
4317+
inheritedType->getDeclContext()->getSelfNominalTypeDecl();
42904318
Diags.diagnose(assocTypeDecl,
4291-
diag::inherited_associated_type_redecl,
4319+
diag::associated_type_override_typealias,
42924320
assocTypeDecl->getFullName(),
4293-
inheritedFromProto->getDeclaredInterfaceType())
4294-
.fixItInsertAfter(
4295-
fixItWhere.first,
4296-
getAssociatedTypeReqs(assocTypeDecl, fixItWhere.second))
4297-
.fixItRemove(assocTypeDecl->getSourceRange());
4298-
4299-
Diags.diagnose(inheritedAssocTypeDecl, diag::decl_declared_here,
4300-
inheritedAssocTypeDecl->getFullName());
4301-
4302-
shouldWarnAboutRedeclaration = false;
4321+
inheritedOwningDecl->getDescriptiveKind(),
4322+
inheritedOwningDecl->getDeclaredInterfaceType());
43034323
}
43044324

4305-
continue;
4325+
addInferredSameTypeReq(assocTypeDecl, inheritedType);
43064326
}
43074327

4308-
// We inherited a type; this associated type will be identical
4309-
// to that typealias.
4310-
if (source->kind == RequirementSource::RequirementSignatureSelf) {
4311-
auto inheritedOwningDecl =
4312-
inheritedType->getDeclContext()->getSelfNominalTypeDecl();
4313-
Diags.diagnose(assocTypeDecl,
4314-
diag::associated_type_override_typealias,
4315-
assocTypeDecl->getFullName(),
4316-
inheritedOwningDecl->getDescriptiveKind(),
4317-
inheritedOwningDecl->getDeclaredInterfaceType());
4318-
}
4319-
4320-
addInferredSameTypeReq(assocTypeDecl, inheritedType);
4328+
inheritedTypeDecls.erase(knownInherited);
4329+
continue;
43214330
}
4322-
4323-
inheritedTypeDecls.erase(knownInherited);
4324-
continue;
43254331
}
43264332

43274333
// Check all remaining inherited type declarations to determine if

trunk/lib/AST/ProtocolConformance.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,9 +904,8 @@ NormalProtocolConformance::getAssociatedConformance(Type assocType,
904904
// Fill in the signature conformances, if we haven't done so yet.
905905
if (getSignatureConformances().empty()) {
906906
assocType->getASTContext().getLazyResolver()
907-
->resolveTypeWitness(
908-
const_cast<NormalProtocolConformance *>(this),
909-
nullptr);
907+
->checkConformanceRequirements(
908+
const_cast<NormalProtocolConformance *>(this));
910909
}
911910

912911
assert(!getSignatureConformances().empty() &&

0 commit comments

Comments
 (0)