Skip to content

Commit f245f18

Browse files
committed
Merge remote-tracking branch 'origin/swift-3-api-guidelines' into swift-3-omit-needless-words
2 parents 2f5f94a + 3fe0c60 commit f245f18

File tree

499 files changed

+5430
-5747
lines changed

Some content is hidden

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

499 files changed

+5430
-5747
lines changed

docs/ABI.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,7 @@ Types
939939
nominal-type-kind ::= 'C' // class
940940
nominal-type-kind ::= 'O' // enum
941941
nominal-type-kind ::= 'V' // struct
942+
declaration-name ::= context decl-name
942943
archetype ::= 'Q' index // archetype with depth=0, idx=N
943944
archetype ::= 'Qd' index index // archetype with depth=M+1, idx=N
944945
archetype ::= associated-type
@@ -1179,8 +1180,8 @@ using its substitution, ``CS1_``. The
11791180
third argument type will mangle using the substitution for ``zim``,
11801181
``CS_7zippity``. (It also acquires substitution ``S2_`` which would be used
11811182
if it mangled again.) The result type will mangle using the substitution for
1182-
``zim.zang``, ``CS0_zoo`` (and acquire substitution ``S3_``). The full
1183-
function type thus mangles as ``fTCC3zim4zang4zungCS1_CS_7zippity_CS0_zoo``.
1183+
``zim.zang``, ``CS0_3zoo`` (and acquire substitution ``S3_``). The full
1184+
function type thus mangles as ``fTCC3zim4zang4zungCS1_CS_7zippity_CS0_3zoo``.
11841185

11851186
::
11861187

docs/OptimizationTips.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ argument drops from being O(n), depending on the size of the tree to O(1).
446446

447447
::
448448

449-
struct tree : P {
449+
struct Tree : P {
450450
var node : [P?]
451451
init() {
452452
node = [ thing ]

docs/proposals/Accessors.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ Are these conditions true?
11071107

11081108
Recall that an addressor is invoked for an l-value of the form::
11091109

1110-
base.memory
1110+
base.pointee
11111111

11121112
or::
11131113

docs/proposals/OptimizerEffects.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ It will see the following calls because methods with attributes are not inlined.
413413
for i in 0 .. A.size {
414414
makeUnique(&A)
415415
addr = getElementAddr(i, &A)
416-
addr.memory = value
416+
addr.pointee = value
417417
f()
418418
}
419419
}

include/swift/AST/ASTContext.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ class ASTContext {
425425
/// Retrieve the declaration of Swift.Unmanaged<T>.
426426
NominalTypeDecl *getUnmanagedDecl() const;
427427

428-
/// Retrieve the declaration of the "memory" property of a pointer type.
429-
VarDecl *getPointerMemoryPropertyDecl(PointerTypeKind ptrKind) const;
428+
/// Retrieve the declaration of the "pointee" property of a pointer type.
429+
VarDecl *getPointerPointeePropertyDecl(PointerTypeKind ptrKind) const;
430430

431431
/// Retrieve the declaration of Swift.Void.
432432
TypeAliasDecl *getVoidDecl() const;

include/swift/AST/Attr.def

+2
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ SIMPLE_DECL_ATTR(indirect, Indirect,
240240
SIMPLE_DECL_ATTR(warn_unqualified_access, WarnUnqualifiedAccess,
241241
OnFunc /*| OnVar*/ | LongAttribute, 61)
242242

243+
DECL_ATTR(_migration_id, MigrationId, OnAnyDecl, 62)
244+
243245
#undef TYPE_ATTR
244246
#undef DECL_ATTR_ALIAS
245247
#undef SIMPLE_DECL_ATTR

include/swift/AST/Attr.h

+25
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,31 @@ class WarnUnusedResultAttr : public DeclAttribute {
11481148
}
11491149
};
11501150

1151+
/// The internal @_migration_id attribute, which is used to keep track of stdlib
1152+
/// changes for migration purposes.
1153+
class MigrationIdAttr : public DeclAttribute {
1154+
StringRef Ident;
1155+
StringRef PatternId;
1156+
1157+
public:
1158+
MigrationIdAttr(SourceLoc atLoc, SourceLoc attrLoc, SourceLoc lParenLoc,
1159+
StringRef ident, StringRef patternId,
1160+
SourceLoc rParenLoc, bool implicit)
1161+
: DeclAttribute(DAK_MigrationId, attrLoc,
1162+
SourceRange(atLoc, rParenLoc), implicit),
1163+
Ident(ident), PatternId(patternId) {}
1164+
1165+
/// Retrieve the migration identifier associated with the symbol.
1166+
StringRef getIdent() const { return Ident; }
1167+
1168+
/// Retrieve pattern identifier associated with the symbol.
1169+
StringRef getPatternId() const { return PatternId; }
1170+
1171+
static bool classof(const DeclAttribute *DA) {
1172+
return DA->getKind() == DAK_MigrationId;
1173+
}
1174+
};
1175+
11511176
/// \brief Attributes that may be applied to declarations.
11521177
class DeclAttributes {
11531178
/// Linked list of declaration attributes.

include/swift/AST/Decl.h

+1-15
Original file line numberDiff line numberDiff line change
@@ -2242,16 +2242,6 @@ class ValueDecl : public Decl {
22422242
/// If \p DC is null, returns true only if this declaration is public.
22432243
bool isAccessibleFrom(const DeclContext *DC) const;
22442244

2245-
/// Get the innermost declaration context that can provide generic
2246-
/// parameters used within this declaration.
2247-
DeclContext *getPotentialGenericDeclContext();
2248-
2249-
/// Get the innermost declaration context that can provide generic
2250-
/// parameters used within this declaration.
2251-
const DeclContext *getPotentialGenericDeclContext() const {
2252-
return const_cast<ValueDecl *>(this)->getPotentialGenericDeclContext();
2253-
}
2254-
22552245
/// Retrieve the "interface" type of this value, which is the type used when
22562246
/// the declaration is viewed from the outside. For a generic function,
22572247
/// this will have generic function type using generic parameters rather than
@@ -4568,11 +4558,7 @@ class AbstractFunctionDecl : public ValueDecl, public DeclContext {
45684558
/// and return the type to be used for the 'self' argument of the type, or an
45694559
/// empty Type() if no 'self' argument should exist. This can
45704560
/// only be used after name binding has resolved types.
4571-
///
4572-
/// \param outerGenericParams If non-NULL, and this function is an instance
4573-
/// of a generic type, will be set to the generic parameter list of that
4574-
/// generic type.
4575-
Type computeSelfType(GenericParamList **outerGenericParams = nullptr);
4561+
Type computeSelfType();
45764562

45774563
/// \brief If this is a method in a type or extension thereof, compute
45784564
/// and return the type to be used for the 'self' argument of the interface

include/swift/AST/DeclContext.h

+5
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,11 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
364364
/// or a concrete type nested inside a generic type context.
365365
bool isGenericTypeContext() const;
366366

367+
/// Determine the maximum depth of the current generic type context's generic
368+
/// parameters. If the current context is not a generic type context, returns
369+
/// the maximum depth of any generic parameter in this context.
370+
unsigned getGenericTypeContextDepth() const;
371+
367372
/// Returns true if lookups within this context could affect downstream files.
368373
///
369374
/// \param functionsAreNonCascading If true, functions are considered non-

include/swift/AST/DiagnosticsParse.def

+19-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ ERROR(lex_expected_binary_exponent_in_hex_float_literal,lexing,none,
126126
"hexadecimal floating point literal must end with an exponent", ())
127127
ERROR(lex_unexpected_block_comment_end,lexing,none,
128128
"unexpected end of block comment", ())
129-
ERROR(lex_unary_equal_is_reserved,lexing,none,
130-
"%select{prefix|postfix}0 '=' is reserved", (unsigned))
129+
ERROR(lex_unary_equal,lexing,none,
130+
"'=' must have consistent whitespace on both sides", ())
131131
ERROR(lex_unary_postfix_dot_is_reserved,lexing,none,
132132
"postfix '.' is reserved", ())
133133
ERROR(lex_editor_placeholder,lexing,none,
@@ -364,6 +364,9 @@ ERROR(operator_decl_inner_scope,decl_parsing,none,
364364
"'operator' may only be declared at file scope", ())
365365
ERROR(expected_operator_name_after_operator,decl_parsing,PointsToFirstBadToken,
366366
"expected operator name in operator declaration", ())
367+
ERROR(identifier_when_expecting_operator,decl_parsing,PointsToFirstBadToken,
368+
"%0 is considered to be an identifier, not an operator", (Identifier))
369+
367370
ERROR(operator_decl_no_fixity,decl_parsing,none,
368371
"operator must be declared as 'prefix', 'postfix', or 'infix'", ())
369372
ERROR(expected_lbrace_after_operator,decl_parsing,PointsToFirstBadToken,
@@ -1174,6 +1177,20 @@ WARNING(attr_warn_unused_result_unknown_parameter,attribute_parsing,none,
11741177
ERROR(attr_warn_unused_result_expected_rparen,attribute_parsing,none,
11751178
"expected ')' after 'warn_unused_result' attribute", ())
11761179

1180+
// _migration_id
1181+
WARNING(attr_migration_id_expected_name,attribute_parsing,none,
1182+
"expected parameter 'pattern'", ())
1183+
WARNING(attr_migration_id_unknown_parameter,attribute_parsing,none,
1184+
"unknown parameter '%0' in '_migration_id' attribute", (StringRef))
1185+
ERROR(attr_migration_id_expected_eq,attribute_parsing,none,
1186+
"expected '=' following '%0' parameter", (StringRef))
1187+
ERROR(attr_migration_id_expected_string,attribute_parsing,none,
1188+
"expected a string following '=' for '%0' parameter", (StringRef))
1189+
WARNING(attr_migration_id_duplicate_parameter,attribute_parsing,none,
1190+
"duplicate '%0' parameter; previous value will be ignored", (StringRef))
1191+
ERROR(attr_migration_id_expected_rparen,attribute_parsing,none,
1192+
"expected ')' after '_migration_id' attribute", ())
1193+
11771194
//------------------------------------------------------------------------------
11781195
// Generics parsing diagnostics
11791196
//------------------------------------------------------------------------------

include/swift/AST/DiagnosticsSIL.def

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ ERROR(invalid_sil_builtin,sil_gen,none,
6060
ERROR(could_not_find_bridge_type,sil_gen,none,
6161
"could not find Objective-C bridge type for type %0; "
6262
"did you forget to import Foundation?", (Type))
63-
ERROR(could_not_find_pointer_memory_property,sil_gen,none,
64-
"could not find 'memory' property of pointer type %0", (Type))
63+
ERROR(could_not_find_pointer_pointee_property,sil_gen,none,
64+
"could not find 'pointee' property of pointer type %0", (Type))
6565

6666
ERROR(writeback_overlap_property,sil_gen,none,
6767
"inout writeback to computed property %0 occurs in multiple arguments to"

include/swift/AST/DiagnosticsSema.def

+23-4
Original file line numberDiff line numberDiff line change
@@ -420,23 +420,42 @@ ERROR(ambiguous_module_type,sema_nb,none,
420420
ERROR(use_nonmatching_operator,sema_nb,none,
421421
"%0 is not a %select{binary|prefix unary|postfix unary}1 operator",
422422
(Identifier, unsigned))
423+
424+
ERROR(unspaced_binary_operator_fixit,sema_nb,none,
425+
"missing whitespace between %0 and %1 operators",
426+
(Identifier, Identifier, bool))
427+
ERROR(unspaced_binary_operator,sema_nb,none,
428+
"ambiguous missing whitespace between unary and binary operators", ())
429+
NOTE(unspaced_binary_operators_candidate,sema_nb,none,
430+
"could be %select{binary|postfix}2 %0 and %select{prefix|binary}2 %1",
431+
(Identifier, Identifier, bool))
432+
ERROR(unspaced_unary_operator,sema_nb,none,
433+
"unary operators may not be juxtaposed; parenthesize inner expression",
434+
())
435+
436+
423437
ERROR(use_unresolved_identifier,sema_nb,none,
424-
"use of unresolved identifier %0", (Identifier))
438+
"use of unresolved %select{identifier|operator}1 %0", (Identifier, bool))
425439
ERROR(use_undeclared_type,sema_nb,none,
426440
"use of undeclared type %0", (Identifier))
427441
ERROR(use_undeclared_type_did_you_mean,sema_nb,none,
428-
"use of undeclared type %0; did you mean to use '%1'?", (Identifier, StringRef))
442+
"use of undeclared type %0; did you mean to use '%1'?", (Identifier, StringRef))
429443
NOTE(note_remapped_type,sema_nb,none,
430-
"did you mean to use '%0'?", (StringRef))
444+
"did you mean to use '%0'?", (StringRef))
431445
ERROR(identifier_init_failure,sema_nb,none,
432-
"could not infer type for %0", (Identifier))
446+
"could not infer type for %0", (Identifier))
433447
ERROR(pattern_used_in_type,sema_nb,none,
434448
"%0 used within its own type", (Identifier))
435449
NOTE(note_module_as_type,sema_nb,none,
436450
"cannot use module %0 as a type", (Identifier))
437451

438452
ERROR(use_unknown_object_literal,sema_nb,none,
439453
"use of unknown object literal name %0", (Identifier))
454+
ERROR(object_literal_default_type_missing,sema_nb,none,
455+
"could not infer type of %0 literal", (StringRef))
456+
NOTE(object_literal_resolve_import,sema_nb,none,
457+
"import %0 to use '%1' as the default %2 literal type",
458+
(StringRef, StringRef, StringRef))
440459

441460
ERROR(use_non_type_value,sema_nb,none,
442461
"%0 is not a type", (Identifier))

include/swift/AST/GenericSignature.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,10 @@ class GenericSignature : public llvm::FoldingSetNode {
202202
/// Determine the superclass bound on the given dependent type.
203203
Type getSuperclassBound(Type type, ModuleDecl &mod);
204204

205+
using ConformsToArray = SmallVector<ProtocolDecl *, 2>;
205206
/// Determine the set of protocols to which the given dependent type
206207
/// must conform.
207-
SmallVector<ProtocolDecl *, 2> getConformsTo(Type type, ModuleDecl &mod);
208+
ConformsToArray getConformsTo(Type type, ModuleDecl &mod);
208209

209210
/// Determine whether the given dependent type is equal to a concrete type.
210211
bool isConcreteType(Type type, ModuleDecl &mod);

include/swift/AST/IRGenOptions.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ class IRGenOptions {
126126
/// Whether we should embed the bitcode file.
127127
IRGenEmbedMode EmbedMode : 2;
128128

129-
/// For resilient access to super's members for testing.
130-
unsigned ForceResilientSuperDispatch: 1;
131-
132129
/// List of backend command-line options for -embed-bitcode.
133130
std::vector<uint8_t> CmdArgs;
134131

@@ -138,8 +135,7 @@ class IRGenOptions {
138135
DisableLLVMARCOpts(false), DisableLLVMSLPVectorizer(false),
139136
DisableFPElim(true), Playground(false),
140137
EmitStackPromotionChecks(false), GenerateProfile(false),
141-
EmbedMode(IRGenEmbedMode::None),
142-
ForceResilientSuperDispatch(false)
138+
EmbedMode(IRGenEmbedMode::None)
143139
{}
144140

145141
/// Gets the name of the specified output filename.

include/swift/AST/Identifier.h

-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ class Identifier {
109109
/// isOperatorContinuationCodePoint - Return true if the specified code point
110110
/// is a valid operator code point.
111111
static bool isOperatorContinuationCodePoint(uint32_t C) {
112-
// '.' is a special case. It can only appear in '..'.
113-
if (C == '.')
114-
return false;
115112
if (isOperatorStartCodePoint(C))
116113
return true;
117114

include/swift/AST/KnownIdentifiers.def

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ IDENTIFIER(allocWithZone)
2727
IDENTIFIER(atIndexedSubscript)
2828
IDENTIFIER_(bridgeToObjectiveC)
2929
IDENTIFIER_WITH_NAME(code_, "_code")
30-
IDENTIFIER(CVarArgType)
30+
IDENTIFIER(CVarArg)
3131
IDENTIFIER(Darwin)
3232
IDENTIFIER(dealloc)
3333
IDENTIFIER(deinit)

include/swift/Basic/DemangleNodes.def

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ NODE(QualifiedArchetype)
128128
NODE(ReabstractionThunk)
129129
NODE(ReabstractionThunkHelper)
130130
NODE(ReturnType)
131+
NODE(SILBoxType)
131132
NODE(SelfTypeRef)
132133
CONTEXT_NODE(Setter)
133134
NODE(SpecializationPassID)

include/swift/Option/FrontendOptions.td

-3
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,6 @@ def emit_verbose_sil : Flag<["-"], "emit-verbose-sil">,
190190
def use_native_super_method : Flag<["-"], "use-native-super-method">,
191191
HelpText<"Use super_method for super calls in native classes">;
192192

193-
def force_resilient_super_dispatch: Flag<["-"], "force-resilient-super-dispatch">,
194-
HelpText<"Assume all super member accesses are resilient">;
195-
196193
def disable_self_type_mangling : Flag<["-"], "disable-self-type-mangling">,
197194
HelpText<"Disable including Self type in method type manglings">;
198195

include/swift/Parse/Lexer.h

+13
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,15 @@ class Lexer {
240240
restoreState(S);
241241
}
242242

243+
/// \brief Retrieve the Token referred to by \c Loc.
244+
///
245+
/// \param SM The source manager in which the given source location
246+
/// resides.
247+
///
248+
/// \param Loc The source location of the beginning of a token.
249+
static Token getTokenAtLocation(const SourceManager &SM, SourceLoc Loc);
250+
251+
243252
/// \brief Retrieve the source location that points just past the
244253
/// end of the token referred to by \c Loc.
245254
///
@@ -299,6 +308,10 @@ class Lexer {
299308
/// reserved word.
300309
static tok kindOfIdentifier(StringRef Str, bool InSILMode);
301310

311+
/// \brief Determines if the given string is a valid operator identifier,
312+
/// without escaping characters.
313+
static bool isOperator(StringRef string);
314+
302315
SourceLoc getLocForStartOfBuffer() const {
303316
return SourceLoc(llvm::SMLoc::getFromPointer(BufferStart));
304317
}

include/swift/Runtime/Concurrent.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ template <class KeyTy, class ValueTy> struct ConcurrentMapNode {
145145
/// The method findOrAllocateNode searches the binary tree in search of the
146146
/// exact Key value. If it finds an edge that points to NULL that should
147147
/// contain the value then it tries to compare and swap the new node into
148-
/// place. If it looses the race to a different thread it de-allocates
148+
/// place. If it loses the race to a different thread it de-allocates
149149
/// the node and starts the search again since the new node should
150150
/// be placed (or found) on the new link. See findOrAllocateNode for more
151151
/// details.
@@ -164,7 +164,7 @@ template <class KeyTy, class ValueTy> class ConcurrentMap {
164164
/// accelerating the search of the same value again and again.
165165
std::atomic<NodeTy *> LastSearch;
166166

167-
/// Search a for a node with key value \p. If the node does not exist then
167+
/// Search for a node with key value \p. If the node does not exist then
168168
/// allocate a new bucket and add it to the tree.
169169
ConcurrentList<ValueTy> &findOrAllocateNode(KeyTy Key) {
170170
// Try looking at the last node we searched.

include/swift/SILOptimizer/PassManager/PassManager.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/ADT/DenseMap.h"
1818
#include "llvm/ADT/SmallVector.h"
1919
#include "llvm/Support/ErrorHandling.h"
20+
#include <vector>
2021

2122
#ifndef SWIFT_SILOPTIMIZER_PASSMANAGER_PASSMANAGER_H
2223
#define SWIFT_SILOPTIMIZER_PASSMANAGER_PASSMANAGER_H
@@ -41,6 +42,9 @@ class SILPassManager {
4142
/// A list of registered analysis.
4243
llvm::SmallVector<SILAnalysis *, 16> Analysis;
4344

45+
/// The worklist of functions to be processed by function passes.
46+
std::vector<SILFunction *> FunctionWorklist;
47+
4448
// Name of the current optimization stage for diagnostics.
4549
std::string StageName;
4650

@@ -164,7 +168,11 @@ class SILPassManager {
164168
/// Run the passes in \p FuncTransforms. Return true
165169
/// if the pass manager requested to stop the execution
166170
/// of the optimization cycle (this is a debug feature).
167-
bool runFunctionPasses(PassList FuncTransforms);
171+
void runFunctionPasses(PassList FuncTransforms);
172+
173+
/// A helper function that returns (based on SIL stage and debug
174+
/// options) whether we should continue running passes.
175+
bool continueTransforming();
168176

169177
/// Displays the call graph in an external dot-viewer.
170178
/// This function is meant for use from the debugger.

include/swift/Serialization/ModuleFormat.h

+7
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,13 @@ namespace decls_block {
13391339
// strings, separated by the prior index
13401340
>;
13411341

1342+
using MigrationIdDeclAttrLayout = BCRecordLayout<
1343+
MigrationId_DECL_ATTR,
1344+
BCVBR<6>, // index at the end of the ident,
1345+
BCBlob // blob contains the ident and pattern
1346+
// strings, separated by the prior index
1347+
>;
1348+
13421349
#define SIMPLE_DECL_ATTR(X, CLASS, ...) \
13431350
using CLASS##DeclAttrLayout = BCRecordLayout< \
13441351
CLASS##_DECL_ATTR, \

0 commit comments

Comments
 (0)