Skip to content

Commit 9aa4d4a

Browse files
committed
Merge branch 'main' into add_template_tests
2 parents f97e01e + f8f40e0 commit 9aa4d4a

File tree

148 files changed

+1708
-828
lines changed

Some content is hidden

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

148 files changed

+1708
-828
lines changed

docs/ABI/Mangling.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ mangled in to disambiguate.
600600
impl-function-type ::= type* 'I' FUNC-ATTRIBUTES '_'
601601
impl-function-type ::= type* generic-signature 'I' FUNC-ATTRIBUTES '_'
602602

603-
FUNC-ATTRIBUTES ::= PATTERN-SUBS? INVOCATION-SUBS? PSEUDO-GENERIC? CALLEE-ESCAPE? DIFFERENTIABILITY-KIND? CALLEE-CONVENTION FUNC-REPRESENTATION? COROUTINE-KIND? (PARAM-CONVENTION PARAM-DIFFERENTIABILITY?)* RESULT-CONVENTION* ('Y' PARAM-CONVENTION)* ('z' RESULT-CONVENTION RESULT-DIFFERENTIABILITY?)?
603+
FUNC-ATTRIBUTES ::= PATTERN-SUBS? INVOCATION-SUBS? PSEUDO-GENERIC? CALLEE-ESCAPE? DIFFERENTIABILITY-KIND? CALLEE-CONVENTION FUNC-REPRESENTATION? COROUTINE-KIND? ASYNC? (PARAM-CONVENTION PARAM-DIFFERENTIABILITY?)* RESULT-CONVENTION* ('Y' PARAM-CONVENTION)* ('z' RESULT-CONVENTION RESULT-DIFFERENTIABILITY?)?
604604

605605
PATTERN-SUBS ::= 's' // has pattern substitutions
606606
INVOCATION-SUB ::= 'I' // has invocation substitutions
@@ -627,6 +627,8 @@ mangled in to disambiguate.
627627
COROUTINE-KIND ::= 'A' // yield-once coroutine
628628
COROUTINE-KIND ::= 'G' // yield-many coroutine
629629

630+
ASYNC ::= 'H' // @async
631+
630632
PARAM-CONVENTION ::= 'i' // indirect in
631633
PARAM-CONVENTION ::= 'c' // indirect in constant
632634
PARAM-CONVENTION ::= 'l' // indirect inout

include/swift/AST/ASTScope.h

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ class ASTScopeImpl {
280280
public:
281281
virtual NullablePtr<ClosureExpr> getClosureIfClosureScope() const;
282282
virtual ASTContext &getASTContext() const;
283-
virtual NullablePtr<DeclContext> getDeclContext() const;
284283
virtual NullablePtr<Decl> getDeclIfAny() const { return nullptr; };
285284
virtual NullablePtr<Stmt> getStmtIfAny() const { return nullptr; };
286285
virtual NullablePtr<Expr> getExprIfAny() const { return nullptr; };
@@ -354,7 +353,7 @@ class ASTScopeImpl {
354353

355354
/// Entry point into ASTScopeImpl-land for lookups
356355
static void
357-
unqualifiedLookup(SourceFile *, DeclNameRef, SourceLoc, DeclConsumer);
356+
unqualifiedLookup(SourceFile *, SourceLoc, DeclConsumer);
358357

359358
/// Entry point into ASTScopeImpl-land for labeled statement lookups.
360359
static llvm::SmallVector<LabeledStmt *, 4>
@@ -366,7 +365,6 @@ class ASTScopeImpl {
366365
#pragma mark - - lookup- starting point
367366
private:
368367
static const ASTScopeImpl *findStartingScopeForLookup(SourceFile *,
369-
const DeclNameRef name,
370368
const SourceLoc where);
371369

372370
protected:
@@ -487,8 +485,6 @@ class ASTSourceFileScope final : public ASTScopeImpl {
487485
void printSpecifics(llvm::raw_ostream &out) const override;
488486

489487
public:
490-
NullablePtr<DeclContext> getDeclContext() const override;
491-
492488
void buildFullyExpandedTree();
493489
void
494490
buildEnoughOfTreeForTopLevelExpressionsButDontRequestGenericsOrExtendedNominals();
@@ -497,7 +493,8 @@ class ASTSourceFileScope final : public ASTScopeImpl {
497493

498494
const SourceFile *getSourceFile() const override;
499495
NullablePtr<const void> addressForPrinting() const override { return SF; }
500-
bool crossCheckWithAST();
496+
497+
ASTContext &getASTContext() const override;
501498

502499
protected:
503500
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
@@ -684,7 +681,6 @@ class GenericTypeOrExtensionScope : public ASTScopeImpl {
684681
// Returns the where clause scope, or the parent if none
685682
virtual ASTScopeImpl *createTrailingWhereClauseScope(ASTScopeImpl *parent,
686683
ScopeCreator &);
687-
NullablePtr<DeclContext> getDeclContext() const override;
688684
virtual NullablePtr<NominalTypeDecl> getCorrespondingNominalTypeDecl() const {
689685
return nullptr;
690686
}
@@ -829,7 +825,6 @@ class GenericParamScope final : public ASTScopeImpl {
829825

830826
/// Actually holder is always a GenericContext, need to test if
831827
/// ProtocolDecl or SubscriptDecl but will refactor later.
832-
NullablePtr<DeclContext> getDeclContext() const override;
833828
NullablePtr<const void> getReferrent() const override;
834829
std::string getClassName() const override;
835830
SourceRange
@@ -870,8 +865,6 @@ class AbstractFunctionDeclScope final : public ASTScopeImpl {
870865
void printSpecifics(llvm::raw_ostream &out) const override;
871866

872867
public:
873-
virtual NullablePtr<DeclContext> getDeclContext() const override;
874-
875868
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
876869
Decl *getDecl() const { return decl; }
877870

@@ -906,7 +899,6 @@ class ParameterListScope final : public ASTScopeImpl {
906899
std::string getClassName() const override;
907900
SourceRange
908901
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
909-
virtual NullablePtr<DeclContext> getDeclContext() const override;
910902

911903
NullablePtr<const void> addressForPrinting() const override { return params; }
912904
};
@@ -929,9 +921,6 @@ class FunctionBodyScope : public ASTScopeImpl {
929921
public:
930922
SourceRange
931923
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
932-
virtual NullablePtr<DeclContext> getDeclContext() const override {
933-
return decl;
934-
}
935924
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
936925
Decl *getDecl() const { return decl; }
937926

@@ -959,7 +948,6 @@ class DefaultArgumentInitializerScope final : public ASTScopeImpl {
959948
std::string getClassName() const override;
960949
SourceRange
961950
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
962-
virtual NullablePtr<DeclContext> getDeclContext() const override;
963951
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
964952
Decl *getDecl() const { return decl; }
965953
};
@@ -1002,7 +990,6 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
1002990
SourceRange
1003991
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
1004992
NullablePtr<const void> addressForPrinting() const override { return decl; }
1005-
virtual NullablePtr<DeclContext> getDeclContext() const override;
1006993

1007994
NullablePtr<DeclAttribute> getDeclAttributeIfAny() const override {
1008995
return attr;
@@ -1101,7 +1088,6 @@ class PatternEntryInitializerScope final : public AbstractPatternEntryScope {
11011088
std::string getClassName() const override;
11021089
SourceRange
11031090
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
1104-
virtual NullablePtr<DeclContext> getDeclContext() const override;
11051091

11061092
protected:
11071093
bool lookupLocalsOrMembers(DeclConsumer) const override;
@@ -1189,7 +1175,6 @@ class CaptureListScope final : public ASTScopeImpl {
11891175
std::string getClassName() const override;
11901176
SourceRange
11911177
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
1192-
NullablePtr<DeclContext> getDeclContext() const override;
11931178
NullablePtr<Expr> getExprIfAny() const override { return expr; }
11941179
Expr *getExpr() const { return expr; }
11951180
NullablePtr<const void> getReferrent() const override;
@@ -1212,9 +1197,6 @@ class ClosureParametersScope final : public ASTScopeImpl {
12121197
NullablePtr<ClosureExpr> getClosureIfClosureScope() const override {
12131198
return closureExpr;
12141199
}
1215-
NullablePtr<DeclContext> getDeclContext() const override {
1216-
return closureExpr;
1217-
}
12181200
NullablePtr<Expr> getExprIfAny() const override { return closureExpr; }
12191201
Expr *getExpr() const { return closureExpr; }
12201202
NullablePtr<const void> getReferrent() const override;
@@ -1247,9 +1229,6 @@ class TopLevelCodeScope final : public ASTScopeImpl {
12471229
std::string getClassName() const override;
12481230
SourceRange
12491231
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
1250-
virtual NullablePtr<DeclContext> getDeclContext() const override {
1251-
return decl;
1252-
}
12531232
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
12541233
Decl *getDecl() const { return decl; }
12551234
NullablePtr<const void> getReferrent() const override;
@@ -1336,9 +1315,6 @@ class SubscriptDeclScope final : public ASTScopeImpl {
13361315
void printSpecifics(llvm::raw_ostream &out) const override;
13371316

13381317
public:
1339-
virtual NullablePtr<DeclContext> getDeclContext() const override {
1340-
return decl;
1341-
}
13421318
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
13431319
Decl *getDecl() const { return decl; }
13441320
NullablePtr<const void> getReferrent() const override;
@@ -1358,7 +1334,6 @@ class EnumElementScope : public ASTScopeImpl {
13581334

13591335
std::string getClassName() const override;
13601336
ASTScopeImpl *expandSpecifically(ScopeCreator &) override;
1361-
NullablePtr<DeclContext> getDeclContext() const override { return decl; }
13621337
NullablePtr<Decl> getDeclIfAny() const override { return decl; }
13631338
Decl *getDecl() const { return decl; }
13641339

@@ -1700,7 +1675,6 @@ class BraceStmtScope final : public AbstractStmtScope {
17001675
std::string getClassName() const override;
17011676
SourceRange
17021677
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
1703-
virtual NullablePtr<DeclContext> getDeclContext() const override;
17041678

17051679
NullablePtr<ClosureExpr> parentClosureIfAny() const; // public??
17061680
Stmt *getStmt() const override { return stmt; }

include/swift/AST/ASTTypeIDZone.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
SWIFT_TYPEID(ActorIsolation)
1919
SWIFT_TYPEID(AncestryFlags)
20+
SWIFT_TYPEID(BodyInitKind)
21+
SWIFT_TYPEID(BodyInitKindAndExpr)
2022
SWIFT_TYPEID(CtorInitializerKind)
2123
SWIFT_TYPEID(FunctionBuilderBodyPreCheck)
2224
SWIFT_TYPEID(GenericSignature)
@@ -35,6 +37,7 @@ SWIFT_TYPEID(TypePair)
3537
SWIFT_TYPEID(TypeWitnessAndDecl)
3638
SWIFT_TYPEID(Witness)
3739
SWIFT_TYPEID_NAMED(AbstractFunctionDecl *, AbstractFunctionDecl)
40+
SWIFT_TYPEID_NAMED(ApplyExpr *, ApplyExpr)
3841
SWIFT_TYPEID_NAMED(ClosureExpr *, ClosureExpr)
3942
SWIFT_TYPEID_NAMED(CodeCompletionCallbacksFactory *,
4043
CodeCompletionCallbacksFactory)

include/swift/AST/ASTTypeIDs.h

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

2525
class AbstractFunctionDecl;
2626
class ActorIsolation;
27+
class ApplyExpr;
28+
enum class BodyInitKind;
29+
struct BodyInitKindAndExpr;
2730
class BraceStmt;
2831
class ClosureExpr;
2932
class CodeCompletionCallbacksFactory;

include/swift/AST/Decl.h

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,7 @@ class alignas(1 << DeclAlignInBits) Decl {
451451
/// Whether we have computed the above.
452452
IsTransparentComputed : 1);
453453

454-
SWIFT_INLINE_BITFIELD(ConstructorDecl, AbstractFunctionDecl, 3+1+1,
455-
/// The body initialization kind (+1), or zero if not yet computed.
456-
///
457-
/// This value is cached but is not serialized, because it is a property
458-
/// of the definition of the constructor that is useful only to semantic
459-
/// analysis and SIL generation.
460-
ComputedBodyInitKind : 3,
461-
454+
SWIFT_INLINE_BITFIELD(ConstructorDecl, AbstractFunctionDecl, 1+1,
462455
/// Whether this constructor can fail, by building an Optional type.
463456
Failable : 1,
464457

@@ -5953,7 +5946,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
59535946
/// Returns true if the function is an @asyncHandler.
59545947
bool isAsyncHandler() const;
59555948

5956-
/// Returns true if the function if the signature matches the form of an
5949+
/// Returns true if the function signature matches the form of an
59575950
/// @asyncHandler.
59585951
bool canBeAsyncHandler() const;
59595952

@@ -6770,6 +6763,37 @@ enum class CtorInitializerKind {
67706763
Factory
67716764
};
67726765

6766+
/// Specifies the kind of initialization call performed within the body
6767+
/// of the constructor, e.g., self.init or super.init.
6768+
enum class BodyInitKind {
6769+
/// There are no calls to self.init or super.init.
6770+
None,
6771+
/// There is a call to self.init, which delegates to another (peer)
6772+
/// initializer.
6773+
Delegating,
6774+
/// There is a call to super.init, which chains to a superclass initializer.
6775+
Chained,
6776+
/// There are no calls to self.init or super.init explicitly in the body of
6777+
/// the constructor, but a 'super.init' call will be implicitly added
6778+
/// by semantic analysis.
6779+
ImplicitChained
6780+
};
6781+
6782+
struct BodyInitKindAndExpr {
6783+
BodyInitKind initKind;
6784+
ApplyExpr *initExpr;
6785+
6786+
BodyInitKindAndExpr() : initKind(BodyInitKind::None), initExpr(nullptr) {}
6787+
6788+
BodyInitKindAndExpr(BodyInitKind initKind, ApplyExpr *initExpr)
6789+
: initKind(initKind), initExpr(initExpr) {}
6790+
6791+
friend bool operator==(BodyInitKindAndExpr lhs, BodyInitKindAndExpr rhs) {
6792+
return (lhs.initKind == rhs.initKind &&
6793+
lhs.initExpr == rhs.initExpr);
6794+
}
6795+
};
6796+
67736797
/// ConstructorDecl - Declares a constructor for a type. For example:
67746798
///
67756799
/// \code
@@ -6818,38 +6842,11 @@ class ConstructorDecl : public AbstractFunctionDecl {
68186842

68196843
ParamDecl **getImplicitSelfDeclStorage() { return &SelfDecl; }
68206844

6821-
/// Specifies the kind of initialization call performed within the body
6822-
/// of the constructor, e.g., self.init or super.init.
6823-
enum class BodyInitKind {
6824-
/// There are no calls to self.init or super.init.
6825-
None,
6826-
/// There is a call to self.init, which delegates to another (peer)
6827-
/// initializer.
6828-
Delegating,
6829-
/// There is a call to super.init, which chains to a superclass initializer.
6830-
Chained,
6831-
/// There are no calls to self.init or super.init explicitly in the body of
6832-
/// the constructor, but a 'super.init' call will be implicitly added
6833-
/// by semantic analysis.
6834-
ImplicitChained
6835-
};
6836-
68376845
/// Determine whether the body of this constructor contains any delegating
68386846
/// or superclass initializations (\c self.init or \c super.init,
68396847
/// respectively) within its body.
6840-
///
6841-
/// \param diags If non-null, this check will ensure that the constructor
6842-
/// body is consistent in its use of delegation vs. chaining and emit any
6843-
/// diagnostics through the given diagnostic engine.
6844-
///
6845-
/// \param init If non-null and there is an explicit \c self.init or
6846-
/// \c super.init within the body, will be set to point at that
6847-
/// initializer.
6848-
BodyInitKind getDelegatingOrChainedInitKind(DiagnosticEngine *diags,
6849-
ApplyExpr **init = nullptr) const;
6850-
void clearCachedDelegatingOrChainedInitKind() {
6851-
Bits.ConstructorDecl.ComputedBodyInitKind = 0;
6852-
}
6848+
BodyInitKindAndExpr getDelegatingOrChainedInitKind() const;
6849+
void clearCachedDelegatingOrChainedInitKind();
68536850

68546851
/// Whether this constructor is required.
68556852
bool isRequired() const {

include/swift/AST/Evaluator.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,13 @@ class Evaluator {
322322
cache.insert({AnyRequest(request), std::move(output)});
323323
}
324324

325+
/// Do not introduce new callers of this function.
326+
template<typename Request,
327+
typename std::enable_if<!Request::hasExternalCache>::type* = nullptr>
328+
void clearCachedOutput(const Request &request) {
329+
cache.erase(AnyRequest(request));
330+
}
331+
325332
/// Clear the cache stored within this evaluator.
326333
///
327334
/// Note that this does not clear the caches of requests that use external

include/swift/AST/Expr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5793,6 +5793,7 @@ Expr *packSingleArgument(
57935793

57945794
void simple_display(llvm::raw_ostream &out, const ClosureExpr *CE);
57955795
void simple_display(llvm::raw_ostream &out, const DefaultArgumentExpr *expr);
5796+
void simple_display(llvm::raw_ostream &out, const Expr *expr);
57965797

57975798
SourceLoc extractNearestSourceLoc(const DefaultArgumentExpr *expr);
57985799

include/swift/AST/FineGrainedDependencies.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ class BiIndexedTwoStageMap {
346346
// MARK: Start of fine-grained-dependency-specific code
347347
//==============================================================================
348348

349+
/// Uses the provided module or source file to construct a dependency graph,
350+
/// which is provided back to the caller in the continuation callback.
351+
///
352+
/// \Note The returned graph should not be escaped from the callback.
349353
bool withReferenceDependencies(
350354
llvm::PointerUnion<ModuleDecl *, SourceFile *> MSF,
351355
const DependencyTracker &depTracker, StringRef outputPath,
@@ -847,6 +851,8 @@ class SourceFileDepGraph {
847851
/// Read a swiftdeps file from \p buffer and return a SourceFileDepGraph if
848852
/// successful.
849853
Optional<SourceFileDepGraph> static loadFromBuffer(llvm::MemoryBuffer &);
854+
Optional<SourceFileDepGraph> static loadFromSwiftModuleBuffer(
855+
llvm::MemoryBuffer &);
850856

851857
void verifySame(const SourceFileDepGraph &other) const;
852858

include/swift/AST/FineGrainedDependencyFormat.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ using NodeKindField = BCFixed<3>;
4848
using DeclAspectField = BCFixed<1>;
4949

5050
const unsigned RECORD_BLOCK_ID = llvm::bitc::FIRST_APPLICATION_BLOCKID;
51+
const unsigned INCREMENTAL_INFORMATION_BLOCK_ID = 196;
5152

5253
/// The swiftdeps file format consists of a METADATA record, followed by zero or more
5354
/// IDENTIFIER_NODE records.
@@ -113,10 +114,16 @@ namespace record_block {
113114
}
114115

115116
/// Tries to read the dependency graph from the given buffer.
116-
/// Returns true if there was an error.
117+
/// Returns \c true if there was an error.
117118
bool readFineGrainedDependencyGraph(llvm::MemoryBuffer &buffer,
118119
SourceFileDepGraph &g);
119120

121+
/// Tries to read the dependency graph from the given buffer, assuming that it
122+
/// is in the format of a swiftmodule file.
123+
/// Returns \c true if there was an error.
124+
bool readFineGrainedDependencyGraphFromSwiftModule(llvm::MemoryBuffer &buffer,
125+
SourceFileDepGraph &g);
126+
120127
/// Tries to read the dependency graph from the given path name.
121128
/// Returns true if there was an error.
122129
bool readFineGrainedDependencyGraph(llvm::StringRef path,

0 commit comments

Comments
 (0)