Skip to content

Commit 74ff4da

Browse files
committed
Merge remote-tracking branch 'upstream/master' into SR-755-linux-fatal-stacktrace-symbolication
2 parents e819ae9 + 95616f6 commit 74ff4da

File tree

504 files changed

+16908
-11849
lines changed

Some content is hidden

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

504 files changed

+16908
-11849
lines changed

.pep8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[flake8]
2-
filename = *.py,80+-check,Benchmark_Driver,Benchmark_DTrace.in,Benchmark_GuardMalloc.in,Benchmark_RuntimeLeaksRunner.in,build-script,check-incremental,gyb,line-directive,mock-distcc,ns-html2rst,recursive-lipo,rth,run-test,submit-benchmark-results,update-checkout,viewcfg,backtrace-check,symbolicate-linux-fatal
2+
filename = *.py,80+-check,Benchmark_Driver,Benchmark_DTrace.in,Benchmark_GuardMalloc.in,Benchmark_RuntimeLeaksRunner.in,build-script,check-incremental,gyb,line-directive,mock-distcc,ns-html2rst,recursive-lipo,rth,run-test,submit-benchmark-results,update-checkout,viewcfg,backtrace-check,coverage-build-db,coverage-generate-data,coverage-touch-tests,symbolicate-linux-fatal

CHANGELOG.md

Lines changed: 493 additions & 307 deletions
Large diffs are not rendered by default.

docs/ABI.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ Globals
741741
global ::= 'Mm' type // class metaclass
742742
global ::= 'Mn' nominal-type // nominal type descriptor
743743
global ::= 'Mp' protocol // protocol descriptor
744+
global ::= 'MR' remote-reflection-record // metadata for remote mirrors
744745
global ::= 'PA' .* // partial application forwarder
745746
global ::= 'PAo' .* // ObjC partial application forwarder
746747
global ::= 'w' value-witness-kind type // value witness
@@ -822,6 +823,10 @@ Globals
822823
addressor-kind ::= 'o' // owning addressor (native owner)
823824
addressor-kind ::= 'p' // pinning addressor (native owner)
824825

826+
remote-reflection-record ::= 'f' type // field descriptor
827+
remote-reflection-record ::= 'a' protocol-conformance // associated type descriptor
828+
remote-reflection-record ::= 'b' type // builtin type descriptor
829+
825830
An ``entity`` starts with a ``nominal-type-kind`` (``[COPV]``), a
826831
substitution (``[Ss]``) of a nominal type, or an ``entity-kind``
827832
(``[FIiv]``).

docs/GenericsManifesto.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ Associated type inference is a useful feature. It's used throughout the standard
687687

688688
## Existentials
689689

690-
Existentials aren't really generics per se, but the two systems are closely intertwined due to their mutable dependence on protocols.
690+
Existentials aren't really generics per se, but the two systems are closely intertwined due to their mutual dependence on protocols.
691691

692692
### Generalized existentials
693693

docs/SIL.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,14 @@ A type ``T`` is a *legal SIL type* if:
347347
- it is a function type which satisfies the constraints (below) on
348348
function types in SIL,
349349

350+
- it is a metatype type which describes its representation,
351+
350352
- it is a tuple type whose element types are legal SIL types,
351353

352-
- it is a legal Swift type that is not a function, tuple, or l-value type, or
354+
- it is ``Optional<U>``, where ``U`` is a legal SIL type,
355+
356+
- it is a legal Swift type that is not a function, tuple, optional,
357+
metatype, or l-value type, or
353358

354359
- it is a ``@box`` containing a legal SIL type.
355360

@@ -394,6 +399,22 @@ a box containing a mutable value of type ``T``. Boxes always use Swift-native
394399
reference counting, so they can be queried for uniqueness and cast to the
395400
``Builtin.NativeObject`` type.
396401

402+
Metatype Types
403+
``````````````
404+
405+
A concrete or existential metatype in SIL must describe its representation.
406+
This can be:
407+
408+
- ``@thin``, meaning that it requires no storage and thus necessarily
409+
represents an exact type (only allowed for concrete metatypes);
410+
411+
- ``@thick``, meaning that it stores a reference to a type or (if a
412+
concrete class) a subclass of that type; or
413+
414+
- ``@objc``, meaning that it stores a reference to a class type (or a
415+
subclass thereof) using an Objective-C class object representation
416+
rather than the native Swift type-object representation.
417+
397418
Function Types
398419
``````````````
399420

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,6 @@ class ASTContext {
230230

231231
/// Cache of remapped types (useful for diagnostics).
232232
llvm::StringMap<Type> RemappedTypes;
233-
234-
/// Cache for generic mangling signatures.
235-
llvm::DenseMap<std::pair<GenericSignature*, ModuleDecl*>,
236-
CanGenericSignature> ManglingSignatures;
237233

238234
private:
239235
/// \brief The current generation number, which reflects the number of
@@ -838,12 +834,6 @@ class ASTContext {
838834
ArchetypeBuilder *getOrCreateArchetypeBuilder(CanGenericSignature sig,
839835
ModuleDecl *mod);
840836

841-
/// Set the stored archetype builder for the given canonical generic
842-
/// signature and module.
843-
void setArchetypeBuilder(CanGenericSignature sig,
844-
ModuleDecl *mod,
845-
std::unique_ptr<ArchetypeBuilder> builder);
846-
847837
/// Retrieve the inherited name set for the given class.
848838
const InheritedNameSet *getAllPropertyNames(ClassDecl *classDecl,
849839
bool forInstance);

include/swift/AST/ASTScope.h

Lines changed: 119 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Stmt;
5151
class StmtConditionElement;
5252
class SwitchStmt;
5353
class TopLevelCodeDecl;
54+
class TypeDecl;
5455
class WhileStmt;
5556

5657
/// Describes kind of scope that occurs within the AST.
@@ -61,6 +62,10 @@ enum class ASTScopeKind : uint8_t {
6162
Preexpanded,
6263
/// A source file, which is the root of a scope.
6364
SourceFile,
65+
/// The declaration of a type.
66+
TypeDecl,
67+
/// The generic parameters of an extension declaration.
68+
ExtensionGenericParams,
6469
/// The body of a type or extension thereof.
6570
TypeOrExtensionBody,
6671
/// The generic parameters of a declaration.
@@ -71,17 +76,18 @@ enum class ASTScopeKind : uint8_t {
7176
AbstractFunctionParams,
7277
/// The default argument for a parameter.
7378
DefaultArgument,
79+
/// The body of a function.
80+
AbstractFunctionBody,
7481
/// A specific pattern binding.
7582
PatternBinding,
7683
/// The scope introduced for an initializer of a pattern binding.
7784
PatternInitializer,
78-
/// The scope introduced by a particular clause in a pattern binding
79-
/// declaration.
85+
/// The scope following a particular clause in a pattern binding declaration,
86+
/// which is the outermost scope in which the variables introduced by that
87+
/// clause will be visible.
8088
AfterPatternBinding,
8189
/// The scope introduced by a brace statement.
8290
BraceStmt,
83-
/// The scope introduced by a local declaration.
84-
LocalDeclaration,
8591
/// Node describing an "if" statement.
8692
IfStmt,
8793
/// The scope introduced by a conditional clause in an if/guard/while
@@ -150,8 +156,27 @@ class ASTScope {
150156
/// whether the children of this node have already been expanded.
151157
mutable llvm::PointerIntPair<const ASTScope *, 1, bool> parentAndExpanded;
152158

153-
/// The cached source range.
154-
mutable SourceRange CachedSourceRange;
159+
/// Describes the kind of continuation stored in the continuation field.
160+
enum class ContinuationKind {
161+
/// The continuation is historical: if the continuation is non-null, we
162+
/// preserve it so we know which scope to look at to compute the end of the
163+
/// source range.
164+
Historical = 0,
165+
/// The continuation is active.
166+
Active = 1,
167+
/// The continuation stored in the pointer field is active, and replaced a
168+
/// \c SourceFile continuation.
169+
ActiveThenSourceFile = 2,
170+
};
171+
172+
/// The scope from which the continuation child nodes will be populated.
173+
///
174+
/// The enumeration bits indicate whether the continuation pointer represents
175+
/// an active continuation (vs. a historical one) and whether the former
176+
/// continuation was for a \c SourceFile (which can be stacked behind another
177+
/// continuation).
178+
mutable llvm::PointerIntPair<const ASTScope *, 2, ContinuationKind>
179+
continuation = { nullptr, ContinuationKind::Historical };
155180

156181
/// Union describing the various kinds of AST nodes that can introduce
157182
/// scopes.
@@ -167,8 +192,15 @@ class ASTScope {
167192
mutable unsigned nextElement;
168193
} sourceFile;
169194

195+
/// A type declaration, for \c kind == ASTScopeKind::TypeDecl.
196+
TypeDecl *typeDecl;
197+
198+
/// An extension declaration, for
199+
/// \c kind == ASTScopeKind::ExtensionGenericParams.
200+
ExtensionDecl *extension;
201+
170202
/// An iterable declaration context, which covers nominal type declarations
171-
/// and extensions.
203+
/// and extension bodies.
172204
///
173205
/// For \c kind == ASTScopeKind::TypeOrExtensionBody.
174206
IterableDeclContext *iterableDeclContext;
@@ -185,10 +217,11 @@ class ASTScope {
185217
unsigned index;
186218
} genericParams;
187219

188-
/// An abstract function, for \c kind == ASTScopeKind::AbstractFunctionDecl.
220+
/// An abstract function, for \c kind == ASTScopeKind::AbstractFunctionDecl
221+
/// or \c kind == ASTScopeKind::AbstractFunctionBody.
189222
AbstractFunctionDecl *abstractFunction;
190223

191-
/// An parameter for an abstract function (init/func/deinit).
224+
/// A parameter for an abstract function (init/func/deinit).
192225
///
193226
/// For \c kind == ASTScopeKind::AbstractFunctionParams.
194227
struct {
@@ -222,11 +255,6 @@ class ASTScope {
222255
mutable unsigned nextElement;
223256
} braceStmt;
224257

225-
/// The declaration introduced within a local scope.
226-
///
227-
/// For \c kind == ASTScopeKind::LocalDeclaration.
228-
Decl *localDeclaration;
229-
230258
/// The 'if' statement, for \c kind == ASTScopeKind::IfStmt.
231259
IfStmt *ifStmt;
232260

@@ -286,6 +314,26 @@ class ASTScope {
286314
/// Child scopes, sorted by source range.
287315
mutable SmallVector<ASTScope *, 4> storedChildren;
288316

317+
/// Retrieve the active continuation.
318+
const ASTScope *getActiveContinuation() const;
319+
320+
/// Retrieve the historical continuation (which might also be active).
321+
///
322+
/// This is the oldest historical continuation, so a \c SourceFile
323+
/// continuation will be returned even if it's been replaced by a more local
324+
/// continuation.
325+
const ASTScope *getHistoricalContinuation() const;
326+
327+
/// Set the active continuation.
328+
void addActiveContinuation(const ASTScope *newContinuation) const;
329+
330+
/// Remove the active continuation.
331+
void removeActiveContinuation() const;
332+
333+
/// Clear out the continuation, because it has been stolen been transferred to
334+
/// a child node.
335+
void clearActiveContinuation() const;
336+
289337
/// Constructor that only initializes the kind and parent, leaving the
290338
/// pieces to be initialized by the caller.
291339
ASTScope(ASTScopeKind kind, const ASTScope *parent)
@@ -300,6 +348,16 @@ class ASTScope {
300348
/// Constructor that initializes a preexpanded node.
301349
ASTScope(const ASTScope *parent, ArrayRef<ASTScope *> children);
302350

351+
ASTScope(const ASTScope *parent, TypeDecl *typeDecl)
352+
: ASTScope(ASTScopeKind::TypeDecl, parent) {
353+
this->typeDecl = typeDecl;
354+
}
355+
356+
ASTScope(const ASTScope *parent, ExtensionDecl *extension)
357+
: ASTScope(ASTScopeKind::ExtensionGenericParams, parent) {
358+
this->extension = extension;
359+
}
360+
303361
ASTScope(const ASTScope *parent, IterableDeclContext *idc)
304362
: ASTScope(ASTScopeKind::TypeOrExtensionBody, parent) {
305363
this->iterableDeclContext = idc;
@@ -313,8 +371,11 @@ class ASTScope {
313371
this->genericParams.index = index;
314372
}
315373

316-
ASTScope(const ASTScope *parent, AbstractFunctionDecl *abstractFunction)
317-
: ASTScope(ASTScopeKind::AbstractFunctionDecl, parent) {
374+
ASTScope(ASTScopeKind kind, const ASTScope *parent,
375+
AbstractFunctionDecl *abstractFunction)
376+
: ASTScope(kind, parent) {
377+
assert(kind == ASTScopeKind::AbstractFunctionDecl ||
378+
kind == ASTScopeKind::AbstractFunctionBody);
318379
this->abstractFunction = abstractFunction;
319380
}
320381

@@ -429,7 +490,8 @@ class ASTScope {
429490
/// Expand the children of this AST scope so they can be queried.
430491
void expand() const;
431492

432-
/// Determine whether the given scope has already been expanded.
493+
/// Determine whether the given scope has already been completely expanded,
494+
/// and cannot create any new children.
433495
bool isExpanded() const;
434496

435497
/// Create a new AST scope if one is needed for the given declaration.
@@ -456,25 +518,28 @@ class ASTScope {
456518
/// introduced by this AST node.
457519
static ASTScope *createIfNeeded(const ASTScope *parent, ASTNode node);
458520

459-
/// Determine whether this is a scope from which we can perform a
460-
/// continuation.
461-
bool isContinuationScope() const;
521+
/// Determine whether this scope can steal a continuation from its parent,
522+
/// because (e.g.) it introduces some name binding that should be visible
523+
/// in the continuation.
524+
bool canStealContinuation() const;
462525

463-
/// Enumerate the continuation scopes for the given parent,
526+
/// Enumerate the continuation child scopes for the given scope.
464527
///
465-
/// Statements, such as 'guard' and local declarations, introduce scopes
466-
/// that extend to the end of an enclosing brace-stmt. This
467-
/// operation finds each of the "continuation" scopes in the nearest
468-
/// enclosing brace statement.
528+
/// \param addChild Function that will be invoked to add the continuation
529+
/// child. This function should return true if the child steals the
530+
/// continuation, which terminates the enumeration.
469531
void enumerateContinuationScopes(
470-
llvm::function_ref<void(ASTScope *)> fn) const;
532+
llvm::function_ref<bool(ASTScope *)> addChild) const;
471533

472534
/// Compute the source range of this scope.
473535
SourceRange getSourceRangeImpl() const;
474536

475537
/// Retrieve the ASTContext in which this scope exists.
476538
ASTContext &getASTContext() const;
477539

540+
/// Retrieve the source file scope, which is the root of the tree.
541+
const ASTScope *getSourceFileScope() const;
542+
478543
/// Retrieve the source file in which this scope exists.
479544
SourceFile &getSourceFile() const;
480545

@@ -497,24 +562,29 @@ class ASTScope {
497562

498563
/// Determine the source range covered by this scope.
499564
SourceRange getSourceRange() const {
500-
if (CachedSourceRange.isInvalid() ||
501-
getKind() == ASTScopeKind::SourceFile) {
502-
CachedSourceRange = getSourceRangeImpl();
565+
SourceRange range = getSourceRangeImpl();
566+
567+
// If there was ever a continuation, use it's end range.
568+
if (auto historical = getHistoricalContinuation()) {
569+
if (historical != this)
570+
range.End = historical->getSourceRange().End;
503571
}
504-
return CachedSourceRange;
572+
573+
return range;
505574
}
506575

507-
/// Retrieve the local declatation when
508-
/// \c getKind() == ASTScopeKind::LocalDeclaration.
509-
Decl *getLocalDeclaration() const {
510-
assert(getKind() == ASTScopeKind::LocalDeclaration);
511-
return localDeclaration;
576+
/// Retrieve the type declaration when \c getKind() == ASTScopeKind::TypeDecl.
577+
TypeDecl *getTypeDecl() const {
578+
assert(getKind() == ASTScopeKind::TypeDecl);
579+
return typeDecl;
512580
}
513581

514582
/// Retrieve the abstract function declaration when
515-
/// \c getKind() == ASTScopeKind::AbstractFunctionDecl;
583+
/// \c getKind() == ASTScopeKind::AbstractFunctionDecl or
584+
/// \c getKind() == ASTScopeKind::AbstractFunctionBody;
516585
AbstractFunctionDecl *getAbstractFunctionDecl() const {
517-
assert(getKind() == ASTScopeKind::AbstractFunctionDecl);
586+
assert(getKind() == ASTScopeKind::AbstractFunctionDecl ||
587+
getKind() == ASTScopeKind::AbstractFunctionBody);
518588
return abstractFunction;
519589
}
520590

@@ -543,6 +613,18 @@ class ASTScope {
543613
/// \seealso getDeclContext().
544614
DeclContext *getInnermostEnclosingDeclContext() const;
545615

616+
/// Retrueve the declarations whose names are directly bound by this scope.
617+
///
618+
/// The declarations bound in this scope aren't available in the immediate
619+
/// parent of this scope, but will still be visible in child scopes (unless
620+
/// shadowed there).
621+
///
622+
/// Note that this routine does not produce bindings for anything that can
623+
/// be found via qualified name lookup in a \c DeclContext, such as nominal
624+
/// type declarations or extensions thereof, or the source file itself. The
625+
/// client can perform such lookups using the result of \c getDeclContext().
626+
SmallVector<ValueDecl *, 4> getLocalBindings() const;
627+
546628
/// Expand the entire scope map.
547629
///
548630
/// Normally, the scope map will be expanded only as needed by its queries,

0 commit comments

Comments
 (0)