Skip to content

Commit 5d918e5

Browse files
authored
Merge branch 'master' into mracek/arm64e
2 parents 1bd425d + d8e8b3d commit 5d918e5

File tree

245 files changed

+35799
-32201
lines changed

Some content is hidden

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

245 files changed

+35799
-32201
lines changed

docs/ABI/Mangling.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ mangled in to disambiguate.
585585
impl-function-type ::= type* 'I' FUNC-ATTRIBUTES '_'
586586
impl-function-type ::= type* generic-signature 'I' PSEUDO-GENERIC? FUNC-ATTRIBUTES '_'
587587

588-
FUNC-ATTRIBUTES ::= CALLEE-ESCAPE? CALLEE-CONVENTION FUNC-REPRESENTATION? PARAM-CONVENTION* RESULT-CONVENTION* ('z' RESULT-CONVENTION)
588+
FUNC-ATTRIBUTES ::= CALLEE-ESCAPE? CALLEE-CONVENTION FUNC-REPRESENTATION? COROUTINE-KIND? PARAM-CONVENTION* RESULT-CONVENTION* ('Y' PARAM-CONVENTION)* ('z' RESULT-CONVENTION)?
589589

590590
PSEUDO-GENERIC ::= 'P'
591591

@@ -603,6 +603,9 @@ mangled in to disambiguate.
603603
FUNC-REPRESENTATION ::= 'K' // closure
604604
FUNC-REPRESENTATION ::= 'W' // protocol witness
605605

606+
COROUTINE-KIND ::= 'A' // yield-once coroutine
607+
COROUTINE-KIND ::= 'G' // yield-many coroutine
608+
606609
PARAM-CONVENTION ::= 'i' // indirect in
607610
PARAM-CONVENTION ::= 'c' // indirect in constant
608611
PARAM-CONVENTION ::= 'l' // indirect inout

docs/OptimizationTips.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ assuming ``E``, ``F`` do not have any overriding declarations in the same file:
165165
}
166166

167167
Advice: If WMO is enabled, use 'internal' when a declaration does not need to be accessed outside of module
168-
---------------------------------------------------------------------------------------------------------
168+
-----------------------------------------------------------------------------------------------------------
169169

170170
WMO (see section above) causes the compiler to compile a module's
171171
sources all together at once. This allows the optimizer to have module

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ SIMPLE_DECL_ATTR(_inheritsConvenienceInitializers,
520520
93)
521521

522522
DECL_ATTR(_typeEraser, TypeEraser,
523-
OnProtocol | UserInaccessible | NotSerialized |
523+
OnProtocol | UserInaccessible |
524524
ABIStableToAdd | ABIBreakingToRemove | APIStableToAdd | APIBreakingToRemove,
525525
94)
526526

include/swift/AST/Decl.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,10 @@ class alignas(1 << DeclAlignInBits) Decl {
665665
SourceLoc Loc;
666666
SourceLoc StartLoc;
667667
SourceLoc EndLoc;
668+
SmallVector<CharSourceRange, 4> DocRanges;
668669
};
669-
mutable CachedExternalSourceLocs const *CachedLocs = nullptr;
670-
const CachedExternalSourceLocs *calculateSerializedLocs() const;
670+
mutable CachedExternalSourceLocs const *CachedSerializedLocs = nullptr;
671+
const CachedExternalSourceLocs *getSerializedLocs() const;
671672
protected:
672673

673674
Decl(DeclKind kind, llvm::PointerUnion<DeclContext *, ASTContext *> context)
@@ -828,7 +829,7 @@ class alignas(1 << DeclAlignInBits) Decl {
828829
}
829830

830831
/// \returns the unparsed comment attached to this declaration.
831-
RawComment getRawComment() const;
832+
RawComment getRawComment(bool SerializedOK = false) const;
832833

833834
Optional<StringRef> getGroupName() const;
834835

@@ -882,6 +883,9 @@ class alignas(1 << DeclAlignInBits) Decl {
882883
bool hasUnderscoredNaming() const;
883884

884885
bool isPrivateStdlibDecl(bool treatNonBuiltinProtocolsAsPublic = true) const;
886+
887+
/// Check if this is a declaration defined at the top level of the Swift module
888+
bool isStdlibDecl() const;
885889

886890
AvailabilityContext getAvailabilityForLinkage() const;
887891

@@ -916,6 +920,9 @@ class alignas(1 << DeclAlignInBits) Decl {
916920
/// If this returns true, the decl can be safely casted to ValueDecl.
917921
bool isPotentiallyOverridable() const;
918922

923+
/// Returns true if this Decl cannot be seen by any other source file
924+
bool isPrivateToEnclosingFile() const;
925+
919926
/// If an alternative module name is specified for this decl, e.g. using
920927
/// @_originalDefinedIn attribute, this function returns this module name.
921928
StringRef getAlternateModuleName() const;

include/swift/AST/DeclContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ class IterableDeclContext {
814814
/// available.
815815
Optional<std::string> getBodyFingerprint() const;
816816

817-
bool areDependenciesUsingTokenHashesForTypeBodies() const;
817+
bool areTokensHashedForThisBodyInsteadOfInterfaceHash() const;
818818

819819
private:
820820
/// Add a member to the list for iteration purposes, but do not notify the

include/swift/AST/DiagnosticsSema.def

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,9 @@ ERROR(expr_swift_keypath_invalid_component,none,
577577
"invalid component of Swift key path", ())
578578
ERROR(expr_swift_keypath_not_starting_with_type,none,
579579
"a Swift key path must begin with a type", ())
580+
ERROR(expr_swift_keypath_not_starting_with_dot,none,
581+
"a Swift key path with contextual root must begin with a leading dot",
582+
())
580583
ERROR(expr_smart_keypath_value_covert_to_contextual_type,none,
581584
"key path value type %0 cannot be converted to contextual type %1",
582585
(Type, Type))
@@ -3285,14 +3288,16 @@ ERROR(partial_application_of_function_invalid,none,
32853288
"partial application of %select{"
32863289
"'mutating' method|"
32873290
"'super.init' initializer chain|"
3288-
"'self.init' initializer delegation"
3291+
"'self.init' initializer delegation|"
3292+
"'super' instance method with metatype base"
32893293
"}0 is not allowed",
32903294
(unsigned))
32913295
WARNING(partial_application_of_function_invalid_swift4,none,
32923296
"partial application of %select{"
32933297
"'mutating' method|"
32943298
"'super.init' initializer chain|"
3295-
"'self.init' initializer delegation"
3299+
"'self.init' initializer delegation|"
3300+
"'super' instance method with metatype base"
32963301
"}0 is not allowed; calling the function has undefined behavior and will "
32973302
"be an error in future Swift versions",
32983303
(unsigned))
@@ -4795,7 +4800,7 @@ ERROR(property_wrapper_wrong_initial_value_init, none,
47954800
"'wrappedValue' property type (%2) or an @autoclosure thereof",
47964801
(DeclName, Type, Type))
47974802
ERROR(property_wrapper_failable_init, none,
4798-
"%0 cannot be failable", (DeclName))
4803+
"property wrapper initializer %0 cannot be failable", (DeclName))
47994804
ERROR(property_wrapper_type_requirement_not_accessible,none,
48004805
"%select{private|fileprivate|internal|public|open}0 %1 %2 cannot have "
48014806
"more restrictive access than its enclosing property wrapper type %3 "

include/swift/AST/EducationalNotes.def

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,13 @@ EDUCATIONAL_NOTES(invalid_dynamic_callable_type,
3434
EDUCATIONAL_NOTES(missing_dynamic_callable_kwargs_method,
3535
"dynamic-callable-requirements.md")
3636

37+
EDUCATIONAL_NOTES(property_wrapper_no_value_property,
38+
"property-wrapper-requirements.md")
39+
EDUCATIONAL_NOTES(property_wrapper_wrong_initial_value_init,
40+
"property-wrapper-requirements.md")
41+
EDUCATIONAL_NOTES(property_wrapper_failable_init,
42+
"property-wrapper-requirements.md")
43+
EDUCATIONAL_NOTES(property_wrapper_type_requirement_not_accessible,
44+
"property-wrapper-requirements.md")
45+
3746
#undef EDUCATIONAL_NOTES

include/swift/AST/FineGrainedDependencies.h

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "swift/Basic/LLVM.h"
1818
#include "swift/Basic/NullablePtr.h"
1919
#include "swift/Basic/Range.h"
20+
#include "swift/Basic/ReferenceDependencyKeys.h"
2021
#include "llvm/ADT/Hashing.h"
2122
#include "llvm/Support/MD5.h"
2223
#include "llvm/Support/MemoryBuffer.h"
@@ -350,33 +351,6 @@ bool emitReferenceDependencies(DiagnosticEngine &diags, SourceFile *SF,
350351
// MARK: Enums
351352
//==============================================================================
352353

353-
/// Encode the current sorts of dependencies as kinds of nodes in the dependency
354-
/// graph, splitting the current *member* into \ref member and \ref
355-
/// potentialMember and adding \ref sourceFileProvide.
356-
357-
enum class NodeKind {
358-
topLevel,
359-
nominal,
360-
/// In the status quo scheme, *member* dependencies could have blank names
361-
/// for the member, to indicate that the provider might add members.
362-
/// This code uses a separate kind, \ref potentialMember. The holder field is
363-
/// unused.
364-
potentialMember,
365-
/// Corresponding to the status quo *member* dependency with a non-blank
366-
/// member.
367-
member,
368-
dynamicLookup,
369-
externalDepend,
370-
sourceFileProvide,
371-
/// For iterating through the NodeKinds.
372-
kindCount
373-
};
374-
375-
/// Used for printing out NodeKinds to dot files, and dumping nodes for
376-
/// debugging.
377-
const std::string NodeKindNames[]{
378-
"topLevel", "nominal", "potentialMember", "member",
379-
"dynamicLookup", "externalDepend", "sourceFileProvide"};
380354

381355
/// Instead of the status quo scheme of two kinds of "Depends", cascading and
382356
/// non-cascading this code represents each entity ("Provides" in the status

include/swift/AST/RawComment.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct LineColumn {
8686

8787
struct BasicDeclLocs {
8888
StringRef SourceFilePath;
89+
SmallVector<std::pair<LineColumn, uint32_t>, 4> DocRanges;
8990
LineColumn Loc;
9091
LineColumn StartLoc;
9192
LineColumn EndLoc;

include/swift/AST/ReferencedNameTracker.h

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,33 @@
1414
#define SWIFT_REFERENCEDNAMETRACKER_H
1515

1616
#include "swift/AST/Identifier.h"
17+
#include "swift/Basic/ReferenceDependencyKeys.h"
1718
#include "llvm/ADT/DenseMap.h"
1819

20+
#include <unordered_set>
21+
1922
namespace swift {
2023

2124
class NominalTypeDecl;
25+
class DependencyTracker;
2226

2327
class ReferencedNameTracker {
24-
#define TRACKED_SET(KIND, NAME) \
25-
private: \
26-
llvm::DenseMap<KIND, bool> NAME##s; \
27-
public: \
28-
void add##NAME(KIND new##NAME, bool isCascadingUse) { \
29-
NAME##s[new##NAME] |= isCascadingUse; \
30-
} \
31-
const decltype(NAME##s) &get##NAME##s() const { \
32-
return NAME##s; \
33-
}
28+
public:
29+
using EnumerateUsedDecl = function_ref<void(
30+
fine_grained_dependencies::NodeKind kind, StringRef context,
31+
StringRef name, bool isCascadingUse)>;
32+
33+
private:
34+
#define TRACKED_SET(KIND, NAME) \
35+
private: \
36+
llvm::DenseMap<KIND, bool> NAME##s; \
37+
\
38+
public: \
39+
void add##NAME(KIND new##NAME, bool isCascadingUse) { \
40+
NAME##s[new##NAME] |= isCascadingUse; \
41+
} \
42+
/* make private once ReferenceDependencies.cpp is gone */ \
43+
const decltype(NAME##s) &get##NAME##s() const { return NAME##s; }
3444

3545
TRACKED_SET(DeclBaseName, TopLevelName)
3646
TRACKED_SET(DeclBaseName, DynamicLookupName)
@@ -39,6 +49,33 @@ public: \
3949
TRACKED_SET(MemberPair, UsedMember)
4050

4151
#undef TRACKED_SET
52+
public:
53+
// Pushing the DependencyTracker through unifies external dependency
54+
// enumeration.
55+
void enumerateAllUses(bool includeIntrafileDeps,
56+
const DependencyTracker &depTracker,
57+
EnumerateUsedDecl enumerateUsedDecl) const;
58+
59+
private:
60+
template <fine_grained_dependencies::NodeKind kind>
61+
void enumerateSimpleUses(llvm::DenseMap<DeclBaseName, bool> cascadesByName,
62+
EnumerateUsedDecl enumerateUsedDecl) const;
63+
64+
void enumerateExternalUses(const DependencyTracker &,
65+
EnumerateUsedDecl enumerateUsedDecl) const;
66+
67+
void enumerateCompoundUses(bool includeIntrafileDeps,
68+
EnumerateUsedDecl enumerateUsedDecl) const;
69+
70+
std::unordered_set<std::string>
71+
computeHoldersOfCascadingMembers(bool includeIntrafileDeps) const;
72+
73+
void enumerateNominalUses(
74+
bool includeIntrafileDeps,
75+
const std::unordered_set<std::string> &&holdersOfCascadingMembers,
76+
EnumerateUsedDecl enumerateUsedDecl) const;
77+
78+
void enumerateMemberUses(EnumerateUsedDecl enumerateUsedDecl) const;
4279
};
4380

4481
} // end namespace swift

0 commit comments

Comments
 (0)