Skip to content

Commit 14e0fe8

Browse files
authored
Merge branch 'main' into reassign-immortal
2 parents ac94d7d + f3557fe commit 14e0fe8

File tree

175 files changed

+4651
-1626
lines changed

Some content is hidden

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

175 files changed

+4651
-1626
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ClosureSpecialization.swift

Lines changed: 132 additions & 149 deletions
Large diffs are not rendered by default.

SwiftCompilerSources/Sources/Optimizer/Utilities/Test.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public func registerOptimizerTests() {
160160
enclosingValuesTest,
161161
forwardingDefUseTest,
162162
forwardingUseDefTest,
163-
gatherCallSitesTest,
163+
getPullbackClosureInfoTest,
164164
interiorLivenessTest,
165165
lifetimeDependenceRootTest,
166166
lifetimeDependenceScopeTest,

include/swift/AST/Attr.h

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ enum : unsigned {
136136
InheritActorContextModifier::Last_InheritActorContextKind))
137137
};
138138

139+
enum : unsigned {
140+
NumNonexhaustiveModeBits = countBitsUsed(
141+
static_cast<unsigned>(NonexhaustiveMode::Last_NonexhaustiveMode))
142+
};
143+
139144
enum : unsigned { NumDeclAttrKindBits = countBitsUsed(NumDeclAttrKinds - 1) };
140145

141146
enum : unsigned { NumTypeAttrKindBits = countBitsUsed(NumTypeAttrKinds - 1) };
@@ -277,6 +282,10 @@ class DeclAttribute : public AttributeBase {
277282
SWIFT_INLINE_BITFIELD(LifetimeAttr, DeclAttribute, 1,
278283
isUnderscored : 1
279284
);
285+
286+
SWIFT_INLINE_BITFIELD(NonexhaustiveAttr, DeclAttribute, NumNonexhaustiveModeBits,
287+
mode : NumNonexhaustiveModeBits
288+
);
280289
} Bits;
281290
// clang-format on
282291

@@ -2925,7 +2934,7 @@ class BackDeployedAttr : public DeclAttribute {
29252934
: DeclAttribute(DeclAttrKind::BackDeployed, AtLoc, Range, Implicit),
29262935
Platform(Platform), Version(Version) {}
29272936

2928-
/// The platform the symbol is available for back deployment on.
2937+
/// The platform the decl is available for back deployment in.
29292938
const PlatformKind Platform;
29302939

29312940
/// The earliest platform version that may use the back deployed implementation.
@@ -2934,6 +2943,12 @@ class BackDeployedAttr : public DeclAttribute {
29342943
/// Returns true if this attribute is active given the current platform.
29352944
bool isActivePlatform(const ASTContext &ctx, bool forTargetVariant) const;
29362945

2946+
/// Returns the `AvailabilityDomain` that the decl is available for back
2947+
/// deployment in.
2948+
AvailabilityDomain getAvailabilityDomain() const {
2949+
return AvailabilityDomain::forPlatform(Platform);
2950+
}
2951+
29372952
static bool classof(const DeclAttribute *DA) {
29382953
return DA->getKind() == DeclAttrKind::BackDeployed;
29392954
}
@@ -3500,6 +3515,36 @@ class ABIAttr : public DeclAttribute {
35003515
}
35013516
};
35023517

3518+
/// Defines a @nonexhaustive attribute.
3519+
class NonexhaustiveAttr : public DeclAttribute {
3520+
public:
3521+
NonexhaustiveAttr(SourceLoc atLoc, SourceRange range, NonexhaustiveMode mode,
3522+
bool implicit = false)
3523+
: DeclAttribute(DeclAttrKind::Nonexhaustive, atLoc, range, implicit) {
3524+
Bits.NonexhaustiveAttr.mode = unsigned(mode);
3525+
}
3526+
3527+
NonexhaustiveAttr(NonexhaustiveMode mode)
3528+
: NonexhaustiveAttr(SourceLoc(), SourceRange(), mode) {}
3529+
3530+
NonexhaustiveMode getMode() const {
3531+
return NonexhaustiveMode(Bits.NonexhaustiveAttr.mode);
3532+
}
3533+
3534+
static bool classof(const DeclAttribute *DA) {
3535+
return DA->getKind() == DeclAttrKind::Nonexhaustive;
3536+
}
3537+
3538+
NonexhaustiveAttr *clone(ASTContext &ctx) const {
3539+
return new (ctx) NonexhaustiveAttr(AtLoc, Range, getMode(), isImplicit());
3540+
}
3541+
3542+
bool isEquivalent(const NonexhaustiveAttr *other, Decl *attachedTo) const {
3543+
return getMode() == other->getMode();
3544+
}
3545+
};
3546+
3547+
35033548
/// The kind of unary operator, if any.
35043549
enum class UnaryOperatorKind : uint8_t { None, Prefix, Postfix };
35053550

include/swift/AST/AttrKind.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ enum class ENUM_EXTENSIBILITY_ATTR(closed)
135135
Last_InheritActorContextKind = Always
136136
};
137137

138+
enum class ENUM_EXTENSIBILITY_ATTR(closed) NonexhaustiveMode : uint8_t {
139+
Error SWIFT_NAME("error") = 0,
140+
Warning SWIFT_NAME("warning") = 1,
141+
Last_NonexhaustiveMode = Warning
142+
};
143+
138144
enum class ENUM_EXTENSIBILITY_ATTR(closed) DeclAttrKind : unsigned {
139145
#define DECL_ATTR(_, CLASS, ...) CLASS,
140146
#define LAST_DECL_ATTR(CLASS) Last_DeclAttr = CLASS,

include/swift/AST/AvailabilityQuery.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include "llvm/Support/VersionTuple.h"
2424

2525
namespace swift {
26+
class ASTContext;
27+
class FuncDecl;
28+
2629
/// Represents the information needed to evaluate an `#if available` query
2730
/// (either at runtime or compile-time).
2831
class AvailabilityQuery final {
@@ -121,6 +124,14 @@ class AvailabilityQuery final {
121124
return std::nullopt;
122125
return variantRange->getRawMinimumVersion();
123126
}
127+
128+
/// Returns the `FuncDecl *` that should be invoked at runtime to evaluate
129+
/// the query, and populates `arguments` with the arguments to invoke it with
130+
/// (the integer components of the version tuples that are being tested). If
131+
/// the query does not have a dynamic result, returns `nullptr`.
132+
FuncDecl *
133+
getDynamicQueryDeclAndArguments(llvm::SmallVectorImpl<unsigned> &arguments,
134+
ASTContext &ctx) const;
124135
};
125136

126137
} // end namespace swift

include/swift/AST/Concurrency.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919

2020
namespace swift {
2121

22+
/// Find the imported module that treats the given nominal type as "preconcurrency", or return `nullptr`
23+
/// if there is no such module.
24+
ModuleDecl *moduleImportForPreconcurrency(NominalTypeDecl *nominal,
25+
const DeclContext *fromDC);
26+
2227
/// Determinate the appropriate diagnostic behavior to used when emitting
2328
/// concurrency diagnostics when referencing the given nominal type from the
2429
/// given declaration context.

include/swift/AST/Decl.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,11 +1115,11 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl>, public Swi
11151115
std::optional<llvm::VersionTuple>
11161116
getIntroducedOSVersion(PlatformKind Kind) const;
11171117

1118-
/// Returns the OS version in which the decl became ABI as specified by the
1119-
/// `@backDeployed` attribute.
1120-
std::optional<llvm::VersionTuple>
1121-
getBackDeployedBeforeOSVersion(ASTContext &Ctx,
1122-
bool forTargetVariant = false) const;
1118+
/// Returns the active `@backDeployed` attribute and the `AvailabilityRange`
1119+
/// in which the decl is available as ABI.
1120+
std::optional<std::pair<const BackDeployedAttr *, AvailabilityRange>>
1121+
getBackDeployedAttrAndRange(ASTContext &Ctx,
1122+
bool forTargetVariant = false) const;
11231123

11241124
/// Returns true if the decl has an active `@backDeployed` attribute for the
11251125
/// given context.

include/swift/AST/DeclAttr.def

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -877,22 +877,18 @@ SIMPLE_DECL_ATTR(constInitialized, ConstInitialized,
877877
168)
878878
DECL_ATTR_FEATURE_REQUIREMENT(ConstInitialized, CompileTimeValues)
879879

880-
SIMPLE_DECL_ATTR(extensible, Extensible,
880+
DECL_ATTR(nonexhaustive, Nonexhaustive,
881881
OnEnum,
882882
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove | ForbiddenInABIAttr,
883883
169)
884-
DECL_ATTR_FEATURE_REQUIREMENT(Extensible, ExtensibleAttribute)
884+
DECL_ATTR_FEATURE_REQUIREMENT(Nonexhaustive, NonexhaustiveAttribute)
885885

886886
SIMPLE_DECL_ATTR(concurrent, Concurrent,
887887
OnFunc | OnConstructor | OnSubscript | OnVar,
888888
ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove | UnconstrainedInABIAttr,
889889
170)
890890

891-
SIMPLE_DECL_ATTR(preEnumExtensibility, PreEnumExtensibility,
892-
OnEnum,
893-
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIBreakingToRemove | UnconstrainedInABIAttr,
894-
171)
895-
DECL_ATTR_FEATURE_REQUIREMENT(PreEnumExtensibility, ExtensibleAttribute)
891+
// Unused '171': Used to be `@preEnumExtensibility`
896892

897893
DECL_ATTR(specialized, Specialized,
898894
OnConstructor | OnFunc | OnAccessor,

include/swift/AST/DiagnosticEngine.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,12 @@ namespace swift {
401401
/// until the next major language version.
402402
InFlightDiagnostic &warnUntilFutureSwiftVersion();
403403

404+
InFlightDiagnostic &warnUntilFutureSwiftVersionIf(bool shouldLimit) {
405+
if (!shouldLimit)
406+
return *this;
407+
return warnUntilFutureSwiftVersion();
408+
}
409+
404410
/// Limit the diagnostic behavior to warning until the specified version.
405411
///
406412
/// This helps stage in fixes for stricter diagnostics as warnings

include/swift/AST/DiagnosticsCommon.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ ERROR(scanner_find_cycle, none,
214214
NOTE(scanner_find_cycle_swift_overlay_path, none,
215215
"Swift Overlay dependency of '%0' on '%1' via Clang module dependency: '%2'", (StringRef, StringRef, StringRef))
216216

217+
NOTE(scanner_cycle_source_target_shadow_module, none,
218+
"source target '%0' shadowing a%select{ |n SDK }2Swift module with the same name at: '%1'", (StringRef, StringRef, bool))
219+
217220
ERROR(scanner_arguments_invalid, none,
218221
"dependencies scanner cannot be configured with arguments: '%0'", (StringRef))
219222

0 commit comments

Comments
 (0)