Skip to content

Commit ecc43f2

Browse files
authored
---
yaml --- r: 314623 b: refs/heads/master c: 5b4cd81 h: refs/heads/master i: 314621: e4adbc9 314619: 10faeb5 314615: 9478eba 314607: 42a75c1 314591: 4df53a3 314559: 0f3a52e 314495: 794a085 314367: 7878ba4
1 parent ad4418a commit ecc43f2

File tree

306 files changed

+5102
-1393
lines changed

Some content is hidden

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

306 files changed

+5102
-1393
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: 433410f0a96ba2d5bd3a36bcc6eed43134d6ce05
2+
refs/heads/master: 5b4cd81782107ec06e9fd78e776b933c4ddc080f
33
refs/heads/master-next: 66a7e661ff8e88e2d4efab3e430197a7a941e352
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL MSVC)
450450
endif()
451451

452452
if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR
453-
EXISTS ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE})
453+
EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
454454
set(SWIFT_BUILD_SYNTAXPARSERLIB_default TRUE)
455455
set(SWIFT_BUILD_SOURCEKIT_default TRUE)
456456
else()

trunk/docs/DebuggingTheCompiler.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ diagnostic engine to assert on the first error/warning:
8686
These allow one to dump a stack trace of where the diagnostic is being emitted
8787
(if run without a debugger) or drop into the debugger if a debugger is attached.
8888

89+
Finding Diagnostic Names
90+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91+
92+
Some diagnostics rely heavily on format string arguments, so it can be difficult
93+
to find their implementation by searching for parts of the emitted message in
94+
the codebase. To print the corresponding diagnostic name at the end of each
95+
emitted message, use the ``-Xfrontend -debug-diagnostic-names`` argument.
96+
8997
Debugging the Type Checker
9098
--------------------------
9199

trunk/docs/SIL.rst

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,8 +2342,8 @@ assign_by_wrapper
23422342
assign_by_wrapper %0 : $S to %1 : $*T, init %2 : $F, set %3 : $G
23432343
// $S can be a value or address type
23442344
// $T must be the type of a property wrapper.
2345-
// $F must be a function type, taking $S as a single argument and returning $T
2346-
// $G must be a function type, taking $S as a single argument and with not return value
2345+
// $F must be a function type, taking $S as a single argument (or multiple arguments in case of a tuple) and returning $T
2346+
// $G must be a function type, taking $S as a single argument (or multiple arguments in case of a tuple) and without a return value
23472347

23482348
Similar to the ``assign`` instruction, but the assignment is done via a
23492349
delegate.
@@ -3484,13 +3484,14 @@ has an escaping function type (not ``[on_stack]``) the closure context will be
34843484
allocated with retain count 1 and initialized to contain the values ``%1``,
34853485
``%2``, etc. The closed-over values will not be retained; that must be done
34863486
separately before the ``partial_apply``. The closure does however take ownership
3487-
of the partially applied arguments; when the closure reference count reaches
3488-
zero, the contained values will be destroyed. If the ``partial_apply`` has a
3489-
``@noescape`` function type (``partial_apply [on_stack]``) the closure context
3490-
is allocated on the stack and initialized to contain the closed-over values. The
3491-
closed-over values are not retained, lifetime of the closed-over values must be
3492-
managed separately. The lifetime of the stack context of a ``partial_apply
3493-
[on_stack]`` must be terminated with a ``dealloc_stack``.
3487+
of the partially applied arguments (except for ``@inout_aliasable`` parameters);
3488+
when the closure reference count reaches zero, the contained values will be
3489+
destroyed. If the ``partial_apply`` has a ``@noescape`` function type
3490+
(``partial_apply [on_stack]``) the closure context is allocated on the stack and
3491+
initialized to contain the closed-over values. The closed-over values are not
3492+
retained, lifetime of the closed-over values must be managed separately. The
3493+
lifetime of the stack context of a ``partial_apply [on_stack]`` must be
3494+
terminated with a ``dealloc_stack``.
34943495

34953496
If the callee is generic, all of its generic parameters must be bound by the
34963497
given substitution list. The arguments are given with these generic
@@ -3499,6 +3500,11 @@ type with the given substitutions applied. The generic parameters themselves
34993500
cannot be partially applied; all of them must be bound. The result is always
35003501
a concrete function.
35013502

3503+
If an address argument has ``@inout_aliasable`` convention, the closure
3504+
obtained from ``partial_apply`` will not own its underlying value.
3505+
The ``@inout_aliasable`` parameter convention is used when a ``@noescape``
3506+
closure captures an ``inout`` argument.
3507+
35023508
TODO: The instruction, when applied to a generic function,
35033509
currently implicitly performs abstraction difference transformations enabled
35043510
by the given substitutions, such as promoting address-only arguments and returns

trunk/include/swift/AST/ASTContext.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,10 +829,6 @@ class ASTContext final {
829829
/// \param IDC The context whose member decls should be lazily parsed.
830830
void parseMembers(IterableDeclContext *IDC);
831831

832-
/// Use the lazy parsers associated with the context to check whether the decl
833-
/// context has been parsed.
834-
bool hasUnparsedMembers(const IterableDeclContext *IDC) const;
835-
836832
/// Get the lazy function data for the given generic context.
837833
///
838834
/// \param lazyLoader If non-null, the lazy loader to use when creating the

trunk/include/swift/AST/Attr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ class TypeAttributes {
101101
AttrLocs[A] = L;
102102
}
103103

104-
void getAttrRanges(SmallVectorImpl<SourceRange> &Ranges) const {
104+
void getAttrLocs(SmallVectorImpl<SourceLoc> &Locs) const {
105105
for (auto Loc : AttrLocs) {
106106
if (Loc.isValid())
107-
Ranges.push_back(Loc);
107+
Locs.push_back(Loc);
108108
}
109109
}
110110

trunk/include/swift/AST/Decl.h

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,9 @@ class alignas(1 << DeclAlignInBits) Decl {
556556

557557
/// \see ClassDecl::ForeignKind
558558
RawForeignKind : 2,
559-
560-
/// Whether this class contains a destructor decl.
561-
///
562-
/// A fully type-checked class always contains a destructor member, even if
563-
/// it is implicit. This bit is used during parsing and type-checking to
564-
/// control inserting the implicit destructor.
565-
HasDestructorDecl : 1,
559+
560+
/// \see ClassDecl::getEmittedMembers()
561+
HasForcedEmittedMembers : 1,
566562

567563
/// Information about the class's ancestry.
568564
Ancestry : 7,
@@ -3765,8 +3761,17 @@ class ClassDecl final : public NominalTypeDecl {
37653761
llvm::PointerIntPair<Type, 1, bool> SuperclassType;
37663762
} LazySemanticInfo;
37673763

3764+
bool hasForcedEmittedMembers() const {
3765+
return Bits.ClassDecl.HasForcedEmittedMembers;
3766+
}
3767+
3768+
void setHasForcedEmittedMembers() {
3769+
Bits.ClassDecl.HasForcedEmittedMembers = true;
3770+
}
3771+
37683772
friend class SuperclassDeclRequest;
37693773
friend class SuperclassTypeRequest;
3774+
friend class EmittedMembersRequest;
37703775
friend class TypeChecker;
37713776

37723777
public:
@@ -3914,23 +3919,9 @@ class ClassDecl final : public NominalTypeDecl {
39143919
/// either from a class itself or its direct or indirect superclasses.
39153920
AbstractFunctionDecl *findImplementingMethod(
39163921
const AbstractFunctionDecl *method) const;
3917-
3918-
/// True if the class has a destructor.
3919-
///
3920-
/// Fully type-checked classes always contain destructors, but during parsing
3921-
/// or type-checking, the implicit destructor may not have been synthesized
3922-
/// yet if one was not explicitly declared.
3923-
bool hasDestructor() const { return Bits.ClassDecl.HasDestructorDecl; }
3924-
3925-
/// Set the 'has destructor' flag.
3926-
void setHasDestructor() { Bits.ClassDecl.HasDestructorDecl = 1; }
39273922

39283923
/// Retrieve the destructor for this class.
3929-
DestructorDecl *getDestructor();
3930-
3931-
/// Synthesize implicit, trivial destructor, add it to this ClassDecl
3932-
/// and return it.
3933-
void addImplicitDestructor();
3924+
DestructorDecl *getDestructor() const;
39343925

39353926
/// Determine whether this class inherits the convenience initializers
39363927
/// from its superclass.
@@ -3993,6 +3984,10 @@ class ClassDecl final : public NominalTypeDecl {
39933984
/// Record the presence of an @objc method with the given selector.
39943985
void recordObjCMethod(AbstractFunctionDecl *method, ObjCSelector selector);
39953986

3987+
/// Get all the members of this class, synthesizing any implicit members
3988+
/// that appear in the vtable if needed.
3989+
DeclRange getEmittedMembers() const;
3990+
39963991
// Implement isa/cast/dyncast/etc.
39973992
static bool classof(const Decl *D) {
39983993
return D->getKind() == DeclKind::Class;

trunk/include/swift/AST/DeclContext.h

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,10 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
459459
/// are used.
460460
ResilienceExpansion getResilienceExpansion() const;
461461

462+
/// Returns true if this context may possibly contain members visible to
463+
/// AnyObject dynamic lookup.
464+
bool mayContainMembersAccessedByDynamicLookup() const;
465+
462466
/// Returns true if lookups within this context could affect downstream files.
463467
///
464468
/// \param functionsAreNonCascading If true, functions are considered non-
@@ -697,7 +701,18 @@ class IterableDeclContext {
697701
/// detect when a member has been added. A bit would suffice,
698702
/// but would be more fragile, The scope code could count the members each
699703
/// time, but I think it's a better trade to just keep a count here.
700-
unsigned memberCount = 0;
704+
unsigned MemberCount : 29;
705+
706+
/// Whether parsing the members of this context has been delayed.
707+
unsigned HasUnparsedMembers : 1;
708+
709+
/// Whether delayed parsing detected a possible operator definition
710+
/// while skipping the body of this context.
711+
unsigned HasOperatorDeclarations : 1;
712+
713+
/// Whether delayed parsing detect a possible nested class definition
714+
/// while skipping the body of this context.
715+
unsigned HasNestedClassDeclarations : 1;
701716

702717
template<class A, class B, class C>
703718
friend struct ::llvm::cast_convert_val;
@@ -709,13 +724,44 @@ class IterableDeclContext {
709724

710725
public:
711726
IterableDeclContext(IterableDeclContextKind kind)
712-
: LastDeclAndKind(nullptr, kind) { }
727+
: LastDeclAndKind(nullptr, kind) {
728+
MemberCount = 0;
729+
HasOperatorDeclarations = 0;
730+
HasUnparsedMembers = 0;
731+
HasNestedClassDeclarations = 0;
732+
}
713733

714734
/// Determine the kind of iterable context we have.
715735
IterableDeclContextKind getIterableContextKind() const {
716736
return LastDeclAndKind.getInt();
717737
}
718738

739+
bool hasUnparsedMembers() const {
740+
return HasUnparsedMembers;
741+
}
742+
743+
void setHasUnparsedMembers() {
744+
HasUnparsedMembers = 1;
745+
}
746+
747+
bool maybeHasOperatorDeclarations() const {
748+
return HasOperatorDeclarations;
749+
}
750+
751+
void setMaybeHasOperatorDeclarations() {
752+
assert(hasUnparsedMembers());
753+
HasOperatorDeclarations = 1;
754+
}
755+
756+
bool maybeHasNestedClassDeclarations() const {
757+
return HasNestedClassDeclarations;
758+
}
759+
760+
void setMaybeHasNestedClassDeclarations() {
761+
assert(hasUnparsedMembers());
762+
HasNestedClassDeclarations = 1;
763+
}
764+
719765
/// Retrieve the set of members in this context.
720766
DeclRange getMembers() const;
721767

@@ -728,8 +774,8 @@ class IterableDeclContext {
728774
/// is inserted immediately after the hint.
729775
void addMember(Decl *member, Decl *hint = nullptr);
730776

731-
/// See \c memberCount
732-
unsigned getMemberCount() const { return memberCount; }
777+
/// See \c MemberCount
778+
unsigned getMemberCount() const { return MemberCount; }
733779

734780
/// Check whether there are lazily-loaded members.
735781
bool hasLazyMembers() const {

trunk/include/swift/AST/DiagnosticEngine.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,9 @@ namespace swift {
583583
/// input being compiled.
584584
/// May be invalid.
585585
SourceLoc bufferIndirectlyCausingDiagnostic;
586+
587+
/// Print diagnostic names after their messages
588+
bool printDiagnosticNames = false;
586589

587590
friend class InFlightDiagnostic;
588591
friend class DiagnosticTransaction;
@@ -618,6 +621,14 @@ namespace swift {
618621
return state.getWarningsAsErrors();
619622
}
620623

624+
/// Whether to print diagnostic names after their messages
625+
void setPrintDiagnosticNames(bool val) {
626+
printDiagnosticNames = val;
627+
}
628+
bool getPrintDiagnosticNames() const {
629+
return printDiagnosticNames;
630+
}
631+
621632
void ignoreDiagnostic(DiagID id) {
622633
state.setDiagnosticBehavior(id, DiagnosticState::Behavior::Ignore);
623634
}
@@ -826,7 +837,8 @@ namespace swift {
826837
void emitTentativeDiagnostics();
827838

828839
public:
829-
static const char *diagnosticStringFor(const DiagID id);
840+
static const char *diagnosticStringFor(const DiagID id,
841+
bool printDiagnosticName);
830842

831843
/// If there is no clear .dia file for a diagnostic, put it in the one
832844
/// corresponding to the SourceLoc given here.

trunk/include/swift/AST/DiagnosticsParse.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ ERROR(lex_illegal_multiline_string_end,none,
163163
"multi-line string literal closing delimiter must begin on a new line", ())
164164
ERROR(lex_multiline_string_indent_inconsistent,none,
165165
"%select{unexpected space in|unexpected tab in|insufficient}2 indentation of "
166-
"%select{line|next %1 lines}0 in multi-line string literal",
166+
"%select{line|next %1 lines}0 in multi-line string literal",
167167
(bool, unsigned, unsigned))
168168
NOTE(lex_multiline_string_indent_should_match_here,none,
169169
"should match %select{space|tab}0 here", (unsigned))
@@ -252,7 +252,7 @@ ERROR(cskeyword_not_attribute,none,
252252
"'%0' is a declaration modifier, not an attribute", (StringRef))
253253

254254
ERROR(decl_already_static,none,
255-
"%0 specified twice", (StaticSpellingKind))
255+
"%0 cannot appear after another 'static' or 'class' keyword", (StaticSpellingKind))
256256

257257
ERROR(enum_case_dot_prefix,none,
258258
"extraneous '.' in enum 'case' declaration", ())
@@ -881,7 +881,7 @@ WARNING(parameter_extraneous_double_up,none,
881881
"extraneous duplicate parameter name; %0 already has an argument "
882882
"label", (Identifier))
883883
ERROR(parameter_operator_keyword_argument,none,
884-
"%select{operator|closure|enum case}0 cannot have keyword arguments",
884+
"%select{operator|closure|enum case}0 cannot have keyword arguments",
885885
(unsigned))
886886

887887
ERROR(parameter_unnamed,none,

trunk/include/swift/AST/DiagnosticsSema.def

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ ERROR(could_not_find_value_member,none,
8181
ERROR(could_not_find_value_member_corrected,none,
8282
"value of type %0 has no member %1; did you mean %2?",
8383
(Type, DeclName, DeclName))
84+
ERROR(could_not_find_value_dynamic_member_corrected,none,
85+
"value of type %0 has no dynamic member %2 using key path from root type %1; did you mean %3?",
86+
(Type, Type, DeclName, DeclName))
87+
ERROR(could_not_find_value_dynamic_member,none,
88+
"value of type %0 has no dynamic member %2 using key path from root type %1",
89+
(Type, Type, DeclName))
90+
8491
ERROR(could_not_find_type_member,none,
8592
"type %0 has no member %1", (Type, DeclName))
8693
ERROR(could_not_find_type_member_corrected,none,
@@ -3393,6 +3400,18 @@ ERROR(pattern_type_mismatch_context,none,
33933400

33943401
ERROR(tuple_pattern_in_non_tuple_context,none,
33953402
"tuple pattern cannot match values of the non-tuple type %0", (Type))
3403+
WARNING(matching_pattern_with_many_assoc_values, none,
3404+
"cannot match several associated values at once, "
3405+
"implicitly tupling the associated values and trying to match that "
3406+
"instead", ())
3407+
WARNING(matching_tuple_pattern_with_many_assoc_values,none,
3408+
"a tuple pattern cannot match several associated values at once, "
3409+
"implicitly tupling the associated values and trying to match "
3410+
"that instead", ())
3411+
WARNING(matching_many_patterns_with_tupled_assoc_value,none,
3412+
"the enum case has a single tuple as an associated value, but "
3413+
"there are several patterns here, implicitly tupling the patterns "
3414+
"and trying to match that instead", ())
33963415
ERROR(closure_argument_list_tuple,none,
33973416
"contextual closure type %0 expects %1 argument%s1, "
33983417
"but %2 %select{were|was}3 used in closure body", (Type, unsigned, unsigned, bool))

trunk/include/swift/AST/NameLookupRequests.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
namespace swift {
2525

2626
class ClassDecl;
27+
class DestructorDecl;
2728
class TypeAliasDecl;
2829
class TypeDecl;
2930

@@ -231,6 +232,28 @@ class CustomAttrNominalRequest :
231232
bool isCached() const { return true; }
232233
};
233234

235+
/// Finds or synthesizes a destructor for the given class.
236+
class GetDestructorRequest :
237+
public SimpleRequest<GetDestructorRequest,
238+
DestructorDecl *(ClassDecl *),
239+
CacheKind::SeparatelyCached> {
240+
public:
241+
using SimpleRequest::SimpleRequest;
242+
243+
private:
244+
friend SimpleRequest;
245+
246+
// Evaluation.
247+
llvm::Expected<DestructorDecl *>
248+
evaluate(Evaluator &evaluator, ClassDecl *classDecl) const;
249+
250+
public:
251+
// Caching
252+
bool isCached() const { return true; }
253+
Optional<DestructorDecl *> getCachedResult() const;
254+
void cacheResult(DestructorDecl *value) const;
255+
};
256+
234257
/// The zone number for name-lookup requests.
235258
#define SWIFT_NAME_LOOKUP_REQUESTS_TYPEID_ZONE 9
236259

trunk/include/swift/AST/NameLookupTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ SWIFT_TYPEID(ExtendedNominalRequest)
2121
SWIFT_TYPEID(SelfBoundsFromWhereClauseRequest)
2222
SWIFT_TYPEID(TypeDeclsFromWhereClauseRequest)
2323
SWIFT_TYPEID(CustomAttrNominalRequest)
24+
SWIFT_TYPEID(GetDestructorRequest)

0 commit comments

Comments
 (0)