Skip to content

Commit bb1e5d7

Browse files
authored
Merge branch 'main' into dispatch-less
2 parents c9f5676 + 67f978b commit bb1e5d7

File tree

310 files changed

+1226
-908
lines changed

Some content is hidden

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

310 files changed

+1226
-908
lines changed

include/swift/AST/Attr.def

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ SIMPLE_DECL_ATTR(_specializeExtension, SpecializeExtension,
593593
105)
594594

595595
CONTEXTUAL_SIMPLE_DECL_ATTR(async, Async,
596-
DeclModifier | OnVar | OnFunc | ConcurrencyOnly |
596+
DeclModifier | OnVar | OnFunc |
597597
ABIBreakingToAdd | ABIBreakingToRemove |
598598
APIBreakingToAdd | APIBreakingToRemove,
599599
106)
@@ -653,11 +653,7 @@ SIMPLE_DECL_ATTR(_inheritActorContext, InheritActorContext,
653653
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIBreakingToRemove,
654654
116)
655655

656-
CONTEXTUAL_SIMPLE_DECL_ATTR(spawn, Spawn,
657-
DeclModifier | OnVar | ConcurrencyOnly |
658-
ABIBreakingToAdd | ABIBreakingToRemove |
659-
APIBreakingToAdd | APIBreakingToRemove,
660-
117)
656+
// 117 was 'spawn' and is now unused
661657

662658
CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor,
663659
DeclModifier | OnClass | OnFunc |

include/swift/AST/Module.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,6 @@ class ModuleDecl : public DeclContext, public TypeDecl {
774774
void collectBasicSourceFileInfo(
775775
llvm::function_ref<void(const BasicSourceFileInfo &)> callback) const;
776776

777-
public:
778777
/// Retrieve a fingerprint value that summarizes the contents of this module.
779778
///
780779
/// This interface hash a of a module is guaranteed to change if the interface
@@ -787,6 +786,15 @@ class ModuleDecl : public DeclContext, public TypeDecl {
787786
/// contents have been made.
788787
Fingerprint getFingerprint() const;
789788

789+
/// Returns an approximation of whether the given module could be
790+
/// redistributed and consumed by external clients.
791+
///
792+
/// FIXME: The scope of this computation should be limited entirely to
793+
/// RenamedDeclRequest. Unfortunately, it has been co-opted to support the
794+
/// \c SerializeOptionsForDebugging hack. Once this information can be
795+
/// transferred from module files to the dSYMs, remove this.
796+
bool isExternallyConsumed() const;
797+
790798
SourceRange getSourceRange() const { return SourceRange(); }
791799

792800
static bool classof(const DeclContext *DC) {

include/swift/AST/TypeCheckRequests.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,6 +3003,23 @@ class AsyncAlternativeRequest
30033003
bool isCached() const { return true; }
30043004
};
30053005

3006+
class RenamedDeclRequest
3007+
: public SimpleRequest<RenamedDeclRequest,
3008+
ValueDecl *(const ValueDecl *, const AvailableAttr *),
3009+
RequestFlags::Cached> {
3010+
public:
3011+
using SimpleRequest::SimpleRequest;
3012+
3013+
private:
3014+
friend SimpleRequest;
3015+
3016+
ValueDecl *evaluate(Evaluator &evaluator, const ValueDecl *attached,
3017+
const AvailableAttr *attr) const;
3018+
3019+
public:
3020+
bool isCached() const { return true; }
3021+
};
3022+
30063023
void simple_display(llvm::raw_ostream &out, Type value);
30073024
void simple_display(llvm::raw_ostream &out, const TypeRepr *TyR);
30083025
void simple_display(llvm::raw_ostream &out, ImplicitMemberAction action);

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,6 @@ SWIFT_REQUEST(TypeChecker, GetImplicitSendableRequest,
334334
SWIFT_REQUEST(TypeChecker, AsyncAlternativeRequest,
335335
AbstractFunctionDecl *(AbstractFunctionDecl *),
336336
Cached, NoLocationInfo)
337+
SWIFT_REQUEST(TypeChecker, RenamedDeclRequest,
338+
ValueDecl *(const ValueDecl *),
339+
Cached, NoLocationInfo)

include/swift/Frontend/Frontend.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -403,15 +403,6 @@ class CompilerInvocation {
403403
SerializationOptions
404404
computeSerializationOptions(const SupplementaryOutputPaths &outs,
405405
const ModuleDecl *module) const;
406-
407-
/// Returns an approximation of whether the given module could be
408-
/// redistributed and consumed by external clients.
409-
///
410-
/// FIXME: The scope of this computation should be limited entirely to
411-
/// PrintAsObjC. Unfortunately, it has been co-opted to support the
412-
/// \c SerializeOptionsForDebugging hack. Once this information can be
413-
/// transferred from module files to the dSYMs, remove this.
414-
bool isModuleExternallyConsumed(const ModuleDecl *mod) const;
415406
};
416407

417408
/// A class which manages the state and execution of the compiler.

include/swift/PrintAsObjC/PrintAsObjC.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ namespace swift {
2525
/// header.
2626
///
2727
/// Returns true on error.
28-
bool printAsObjC(raw_ostream &out, ModuleDecl *M, StringRef bridgingHeader,
29-
AccessLevel minRequiredAccess);
28+
bool printAsObjC(raw_ostream &out, ModuleDecl *M, StringRef bridgingHeader);
3029
}
3130

3231
#endif

include/swift/Runtime/Exclusivity.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,6 @@ SWIFT_RUNTIME_EXPORT
4040
void swift_beginAccess(void *pointer, ValueBuffer *buffer,
4141
ExclusivityFlags flags, void *pc);
4242

43-
/// Loads the replacement function pointer from \p ReplFnPtr and returns the
44-
/// replacement function if it should be called.
45-
/// Returns null if the original function (which is passed in \p CurrFn) should
46-
/// be called.
47-
#ifdef __APPLE__
48-
__attribute__((weak_import))
49-
#endif
50-
SWIFT_RUNTIME_EXPORT
51-
char *swift_getFunctionReplacement(char **ReplFnPtr, char *CurrFn);
52-
53-
/// Returns the original function of a replaced function, which is loaded from
54-
/// \p OrigFnPtr.
55-
/// This function is called from a replacement function to call the original
56-
/// function.
57-
#ifdef __APPLE__
58-
__attribute__((weak_import))
59-
#endif
60-
SWIFT_RUNTIME_EXPORT
61-
char *swift_getOrigOfReplaceable(char **OrigFnPtr);
6243

6344
/// Stop dynamically tracking an access.
6445
SWIFT_RUNTIME_EXPORT
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//===--- FunctionReplacement.h --------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_RUNTIME_FUNCTIONREPLACEMENT_H
14+
#define SWIFT_RUNTIME_FUNCTIONREPLACEMENT_H
15+
16+
#include "swift/Runtime/Config.h"
17+
18+
namespace swift {
19+
20+
/// Loads the replacement function pointer from \p ReplFnPtr and returns the
21+
/// replacement function if it should be called.
22+
/// Returns null if the original function (which is passed in \p CurrFn) should
23+
/// be called.
24+
#ifdef __APPLE__
25+
__attribute__((weak_import))
26+
#endif
27+
SWIFT_RUNTIME_EXPORT char *
28+
swift_getFunctionReplacement(char **ReplFnPtr, char *CurrFn);
29+
30+
/// Returns the original function of a replaced function, which is loaded from
31+
/// \p OrigFnPtr.
32+
/// This function is called from a replacement function to call the original
33+
/// function.
34+
#ifdef __APPLE__
35+
__attribute__((weak_import))
36+
#endif
37+
SWIFT_RUNTIME_EXPORT char *
38+
swift_getOrigOfReplaceable(char **OrigFnPtr);
39+
40+
} // namespace swift
41+
42+
#endif

include/swift/SIL/AbstractionPattern.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,13 @@ class AbstractionPattern {
13781378
/// Swift type.
13791379
AbstractionPattern getObjCMethodAsyncCompletionHandlerType(
13801380
CanType swiftCompletionHandlerType) const;
1381+
1382+
/// If this pattern refers to a foreign ObjC method that was imported as
1383+
/// async, return the bridged-back-to-ObjC completion handler type.
1384+
CanType getObjCMethodAsyncCompletionHandlerForeignType(
1385+
ForeignAsyncConvention convention,
1386+
Lowering::TypeConverter &TC
1387+
) const;
13811388

13821389
void dump() const LLVM_ATTRIBUTE_USED;
13831390
void print(raw_ostream &OS) const;

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5994,7 +5994,7 @@ bool VarDecl::isMemberwiseInitialized(bool preferDeclaredProperties) const {
59945994
}
59955995

59965996
bool VarDecl::isAsyncLet() const {
5997-
return getAttrs().hasAttribute<AsyncAttr>() || getAttrs().hasAttribute<SpawnAttr>();
5997+
return getAttrs().hasAttribute<AsyncAttr>();
59985998
}
59995999

60006000
void ParamDecl::setSpecifier(Specifier specifier) {

lib/AST/Module.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,32 @@ Fingerprint ModuleDecl::getFingerprint() const {
16381638
return Fingerprint{std::move(hasher)};
16391639
}
16401640

1641+
bool ModuleDecl::isExternallyConsumed() const {
1642+
// Modules for executables aren't expected to be consumed by other modules.
1643+
// This picks up all kinds of entrypoints, including script mode,
1644+
// @UIApplicationMain and @NSApplicationMain.
1645+
if (hasEntryPoint()) {
1646+
return false;
1647+
}
1648+
1649+
// If an implicit Objective-C header was needed to construct this module, it
1650+
// must be the product of a library target.
1651+
if (!getImplicitImportInfo().BridgingHeaderPath.empty()) {
1652+
return false;
1653+
}
1654+
1655+
// App extensions are special beasts because they build without entrypoints
1656+
// like library targets, but they behave like executable targets because
1657+
// their associated modules are not suitable for distribution.
1658+
if (getASTContext().LangOpts.EnableAppExtensionRestrictions) {
1659+
return false;
1660+
}
1661+
1662+
// FIXME: This is still a lousy approximation of whether the module file will
1663+
// be externally consumed.
1664+
return true;
1665+
}
1666+
16411667
//===----------------------------------------------------------------------===//
16421668
// Cross-Import Overlays
16431669
//===----------------------------------------------------------------------===//

lib/ClangImporter/SwiftLookupTable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,6 @@ SwiftNameLookupExtension::hashExtension(llvm::hash_code code) const {
18541854
return llvm::hash_combine(code, StringRef("swift.lookup"),
18551855
SWIFT_LOOKUP_TABLE_VERSION_MAJOR,
18561856
SWIFT_LOOKUP_TABLE_VERSION_MINOR,
1857-
swiftCtx.LangOpts.EnableExperimentalConcurrency,
18581857
version::getSwiftFullVersion());
18591858
}
18601859

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,30 +2126,3 @@ CompilerInvocation::setUpInputForSILTool(
21262126
}
21272127
return fileBufOrErr;
21282128
}
2129-
2130-
bool CompilerInvocation::isModuleExternallyConsumed(
2131-
const ModuleDecl *mod) const {
2132-
// Modules for executables aren't expected to be consumed by other modules.
2133-
// This picks up all kinds of entrypoints, including script mode,
2134-
// @UIApplicationMain and @NSApplicationMain.
2135-
if (mod->hasEntryPoint()) {
2136-
return false;
2137-
}
2138-
2139-
// If an implicit Objective-C header was needed to construct this module, it
2140-
// must be the product of a library target.
2141-
if (!getFrontendOptions().ImplicitObjCHeaderPath.empty()) {
2142-
return false;
2143-
}
2144-
2145-
// App extensions are special beasts because they build without entrypoints
2146-
// like library targets, but they behave like executable targets because
2147-
// their associated modules are not suitable for distribution.
2148-
if (mod->getASTContext().LangOpts.EnableAppExtensionRestrictions) {
2149-
return false;
2150-
}
2151-
2152-
// FIXME: This is still a lousy approximation of whether the module file will
2153-
// be externally consumed.
2154-
return true;
2155-
}

lib/Frontend/Frontend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ SerializationOptions CompilerInvocation::computeSerializationOptions(
180180
// the public.
181181
serializationOpts.SerializeOptionsForDebugging =
182182
opts.SerializeOptionsForDebugging.getValueOr(
183-
!isModuleExternallyConsumed(module));
183+
!module->isExternallyConsumed());
184184

185185
serializationOpts.DisableCrossModuleIncrementalInfo =
186186
opts.DisableCrossModuleIncrementalBuild;

lib/FrontendTool/FrontendTool.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,12 @@ static bool writeSIL(SILModule &SM, const PrimarySpecificPaths &PSPs,
174174
///
175175
/// \see swift::printAsObjC
176176
static bool printAsObjCIfNeeded(StringRef outputPath, ModuleDecl *M,
177-
StringRef bridgingHeader, bool moduleIsPublic) {
177+
StringRef bridgingHeader) {
178178
if (outputPath.empty())
179179
return false;
180180
return withOutputFile(M->getDiags(), outputPath,
181181
[&](raw_ostream &out) -> bool {
182-
auto requiredAccess = moduleIsPublic ? AccessLevel::Public
183-
: AccessLevel::Internal;
184-
return printAsObjC(out, M, bridgingHeader, requiredAccess);
182+
return printAsObjC(out, M, bridgingHeader);
185183
});
186184
}
187185

@@ -853,8 +851,7 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
853851
}
854852
hadAnyError |= printAsObjCIfNeeded(
855853
Invocation.getObjCHeaderOutputPathForAtMostOnePrimary(),
856-
Instance.getMainModule(), BridgingHeaderPathForPrint,
857-
Invocation.isModuleExternallyConsumed(Instance.getMainModule()));
854+
Instance.getMainModule(), BridgingHeaderPathForPrint);
858855
}
859856

860857
// Only want the header if there's been any errors, ie. there's not much

lib/IDE/Refactoring.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3709,7 +3709,7 @@ static CallExpr *findTrailingClosureTarget(
37093709
return nullptr;
37103710
CallExpr *CE = cast<CallExpr>(contexts.back().get<Expr*>());
37113711

3712-
if (CE->hasTrailingClosure())
3712+
if (CE->getUnlabeledTrailingClosureIndex().hasValue())
37133713
// Call expression already has a trailing closure.
37143714
return nullptr;
37153715

lib/IDE/SyntaxModel.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,12 @@ CharSourceRange innerCharSourceRangeFromSourceRange(const SourceManager &SM,
484484
return CharSourceRange(SM, SRS, (SR.End != SR.Start) ? SR.End : SRS);
485485
}
486486

487-
CharSourceRange parameterNameRangeOfCallArg(const TupleExpr *TE,
487+
CharSourceRange parameterNameRangeOfCallArg(const Expr *ArgListExpr,
488488
const Expr *Arg) {
489+
if (isa<ParenExpr>(ArgListExpr))
490+
return CharSourceRange();
491+
492+
auto *TE = cast<TupleExpr>(ArgListExpr);
489493
if (!TE->hasElementNameLocs() || !TE->hasElementNames())
490494
return CharSourceRange();
491495

@@ -547,12 +551,11 @@ std::pair<bool, Expr *> ModelASTWalker::walkToExprPre(Expr *E) {
547551
if (isVisitedBefore(E))
548552
return {false, E};
549553

550-
auto addCallArgExpr = [&](Expr *Elem, TupleExpr *ParentTupleExpr) {
551-
if (isa<DefaultArgumentExpr>(Elem) ||
552-
!isCurrentCallArgExpr(ParentTupleExpr))
554+
auto addCallArgExpr = [&](Expr *Elem, Expr *ArgListExpr) {
555+
if (isa<DefaultArgumentExpr>(Elem) || !isCurrentCallArgExpr(ArgListExpr))
553556
return;
554557

555-
CharSourceRange NR = parameterNameRangeOfCallArg(ParentTupleExpr, Elem);
558+
CharSourceRange NR = parameterNameRangeOfCallArg(ArgListExpr, Elem);
556559
SyntaxStructureNode SN;
557560
SN.Kind = SyntaxStructureKind::Argument;
558561
SN.NameRange = NR;
@@ -568,15 +571,9 @@ std::pair<bool, Expr *> ModelASTWalker::walkToExprPre(Expr *E) {
568571
pushStructureNode(SN, Elem);
569572
};
570573

571-
if (auto *ParentTupleExpr = dyn_cast_or_null<TupleExpr>(Parent.getAsExpr())) {
572-
// the argument value is a tuple expression already, we can just extract it
573-
addCallArgExpr(E, ParentTupleExpr);
574-
} else if (auto *ParentOptionalExpr = dyn_cast_or_null<OptionalEvaluationExpr>(Parent.getAsExpr())) {
575-
// if an argument value is an optional expression, we should extract the
576-
// argument from the subexpression
577-
if (auto *ParentTupleExpr = dyn_cast_or_null<TupleExpr>(ParentOptionalExpr->getSubExpr())) {
578-
addCallArgExpr(E, ParentTupleExpr);
579-
}
574+
if (auto *ParentExpr = Parent.getAsExpr()) {
575+
if (isa<TupleExpr>(ParentExpr) || isa<ParenExpr>(ParentExpr))
576+
addCallArgExpr(E, ParentExpr);
580577
}
581578

582579
if (E->isImplicit())

lib/Parse/ParseExpr.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,13 +1211,17 @@ Parser::parseExprPostfixSuffix(ParserResult<Expr> Result, bool isExprBasic,
12111211
SmallVector<TypeRepr *, 8> args;
12121212
SourceLoc LAngleLoc, RAngleLoc;
12131213
auto argStat = parseGenericArguments(args, LAngleLoc, RAngleLoc);
1214+
Result = makeParserResult(Result | argStat, Result.getPtrOrNull());
12141215
if (argStat.isErrorOrHasCompletion())
12151216
diagnose(LAngleLoc, diag::while_parsing_as_left_angle_bracket);
12161217

12171218
SyntaxContext->createNodeInPlace(SyntaxKind::SpecializeExpr);
1218-
Result = makeParserResult(
1219-
Result, UnresolvedSpecializeExpr::create(
1220-
Context, Result.get(), LAngleLoc, args, RAngleLoc));
1219+
// The result can be empty in error cases.
1220+
if (!args.empty()) {
1221+
Result = makeParserResult(
1222+
Result, UnresolvedSpecializeExpr::create(
1223+
Context, Result.get(), LAngleLoc, args, RAngleLoc));
1224+
}
12211225
}
12221226

12231227
continue;

0 commit comments

Comments
 (0)