Skip to content

Commit 622fbb2

Browse files
Merge remote-tracking branch 'apple/main' into katei/merge-main-2023-04-27
2 parents dacbf5f + aff5b20 commit 622fbb2

File tree

277 files changed

+11473
-3717
lines changed

Some content is hidden

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

277 files changed

+11473
-3717
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
/include/swift/Sema/ @hborla @slavapestov @xedin
7575
/include/swift/Sema/CS* @hborla @xedin
7676
/include/swift/Sema/Constraint* @hborla @xedin
77+
/include/swift/SymbolGraphGen/ @QuietMisdreavus
7778
/include/swift/Threading @al45tair
7879

7980
# lib
@@ -93,6 +94,7 @@
9394
/lib/ClangImporter/DWARFImporter* @adrian-prantl
9495
/lib/DependencyScan @artemcm
9596
/lib/Driver @artemcm
97+
/lib/DriverTool/swift_symbolgraph_extract_main.cpp @QuietMisdreavus
9698
/lib/Frontend/*ModuleInterface* @artemcm @tshortli
9799
# TODO: /lib/IRGen/
98100
/lib/IDE/ @ahoppen @bnbarham @rintaro
@@ -121,6 +123,7 @@
121123
/lib/Sema/TypeCheckProtocol* @AnthonyLatsis @hborla @slavapestov
122124
/lib/Sema/TypeCheckType* @AnthonyLatsis @hborla @slavapestov @xedin
123125
/lib/Serialization/SerializedModuleLoader.cpp @artemcm
126+
/lib/SymbolGraphGen @QuietMisdreavus
124127
/lib/Threading @al45tair
125128

126129
# localization
@@ -153,6 +156,7 @@
153156
# TODO: /test/SILOptimizer/
154157
/test/ScanDependencies/ @artemcm
155158
/test/Sema/ @hborla @slavapestov @xedin
159+
/test/SymbolGraph/ @QuietMisdreavus
156160
/test/decl/ @hborla @slavapestov
157161
/test/decl/protocol/ @AnthonyLatsis @hborla @slavapestov
158162
# FIXME: This file could have a dedicated directory.

include/swift/AST/ASTContext.h

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace swift {
9595
class ModuleDependencyInfo;
9696
class PatternBindingDecl;
9797
class PatternBindingInitializer;
98-
class PluginRegistry;
98+
class PluginLoader;
9999
class SourceFile;
100100
class SourceLoc;
101101
class Type;
@@ -1488,6 +1488,12 @@ class ASTContext final {
14881488

14891489
Type getNamedSwiftType(ModuleDecl *module, StringRef name);
14901490

1491+
/// Set the plugin loader.
1492+
void setPluginLoader(std::unique_ptr<PluginLoader> loader);
1493+
1494+
/// Get the plugin loader.
1495+
PluginLoader &getPluginLoader();
1496+
14911497
/// Lookup a library plugin that can handle \p moduleName and return the path
14921498
/// to it.
14931499
/// The path is valid within the VFS, use `FS.getRealPath()` for the
@@ -1521,15 +1527,6 @@ class ASTContext final {
15211527
/// instance is simply returned.
15221528
LoadedExecutablePlugin *loadExecutablePlugin(StringRef path);
15231529

1524-
/// Get the plugin registry this ASTContext is using.
1525-
PluginRegistry *getPluginRegistry() const;
1526-
1527-
/// Set the plugin registory this ASTContext should use.
1528-
/// This should be called before any plugin is loaded.
1529-
void setPluginRegistry(PluginRegistry *newValue);
1530-
1531-
const llvm::StringSet<> &getLoadedPluginLibraryPaths() const;
1532-
15331530
/// Get the output backend. The output backend needs to be initialized via
15341531
/// constructor or `setOutputBackend`.
15351532
llvm::vfs::OutputBackend &getOutputBackend() const {
@@ -1548,14 +1545,6 @@ class ASTContext final {
15481545
Optional<ExternalSourceLocs *> getExternalSourceLocs(const Decl *D);
15491546
void setExternalSourceLocs(const Decl *D, ExternalSourceLocs *Locs);
15501547

1551-
Optional<std::pair<RawComment, bool>> getRawComment(const Decl *D);
1552-
void setRawComment(const Decl *D, RawComment RC, bool FromSerialized);
1553-
1554-
Optional<StringRef> getBriefComment(const Decl *D);
1555-
void setBriefComment(const Decl *D, StringRef Comment);
1556-
1557-
void createModuleToExecutablePluginMap();
1558-
15591548
friend TypeBase;
15601549
friend ArchetypeType;
15611550
friend OpaqueTypeDecl;

include/swift/AST/ASTScope.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ class ASTSourceFileScope final : public ASTScopeImpl {
413413
NullablePtr<const void> addressForPrinting() const override { return SF; }
414414

415415
ASTContext &getASTContext() const override;
416+
bool ignoreInDebugInfo() const override { return true; }
416417

417418
protected:
418419
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;

include/swift/AST/ASTWalker.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,10 @@ class ASTWalker {
591591
/// TODO: Consider changing this to false by default.
592592
virtual bool shouldWalkSerializedTopLevelInternalDecls() { return true; }
593593

594+
/// Whether to walk into the definition of a \c MacroDecl if it hasn't been
595+
/// type-checked yet.
596+
virtual bool shouldWalkIntoUncheckedMacroDefinitions() { return false; }
597+
594598
/// walkToParameterListPre - This method is called when first visiting a
595599
/// ParameterList, before walking into its parameters.
596600
///

include/swift/AST/Comment.h

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,16 @@ class DocComment {
9393
};
9494

9595
/// Get a parsed documentation comment for the declaration, if there is one.
96-
///
97-
/// \param AllowSerialized Allow loading serialized doc comment data, including
98-
/// comment ranges.
9996
DocComment *getSingleDocComment(swift::markup::MarkupContext &Context,
100-
const Decl *D, bool AllowSerialized = false);
97+
const Decl *D);
10198

10299
/// Get the declaration that actually provides a doc comment for another.
103-
///
104-
/// \param AllowSerialized Allow loading serialized doc comment data, including
105-
/// comment ranges.
106-
const Decl *getDocCommentProvidingDecl(const Decl *D,
107-
bool AllowSerialized = false);
100+
const Decl *getDocCommentProvidingDecl(const Decl *D);
108101

109102
/// Attempt to get a doc comment from the declaration, or other inherited
110103
/// sources, like from base classes or protocols.
111-
///
112-
/// \param AllowSerialized Allow loading serialized doc comment data, including
113-
/// comment ranges.
114104
DocComment *getCascadingDocComment(swift::markup::MarkupContext &MC,
115-
const Decl *D,
116-
bool AllowSerialized = false);
105+
const Decl *D);
117106

118107
/// Extract comments parts from the given Markup node.
119108
swift::markup::CommentParts
@@ -122,6 +111,25 @@ extractCommentParts(swift::markup::MarkupContext &MC,
122111

123112
/// Extract brief comment from \p RC, and print it to \p OS .
124113
void printBriefComment(RawComment RC, llvm::raw_ostream &OS);
114+
115+
/// Describes the intended serialization target for a doc comment.
116+
enum class DocCommentSerializationTarget : uint8_t {
117+
/// The doc comment should not be serialized.
118+
None = 0,
119+
120+
/// The doc comment should only be serialized in the 'swiftsourceinfo'.
121+
SourceInfoOnly,
122+
123+
/// The doc comment should be serialized in both the 'swiftdoc' and
124+
/// 'swiftsourceinfo'.
125+
SwiftDocAndSourceInfo,
126+
};
127+
128+
/// Retrieve the expected serialization target for a documentation comment
129+
/// attached to the given decl.
130+
DocCommentSerializationTarget
131+
getDocCommentSerializationTargetFor(const Decl *D);
132+
125133
} // namespace swift
126134

127135
#endif // LLVM_SWIFT_AST_COMMENT_H

include/swift/AST/Decl.h

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
747747
friend class IterableDeclContext;
748748
friend class MemberLookupTable;
749749
friend class DeclDeserializer;
750+
friend class RawCommentRequest;
750751

751752
private:
752753
llvm::PointerUnion<DeclContext *, ASTContext *> Context;
@@ -1015,16 +1016,17 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
10151016
}
10161017

10171018
/// \returns the unparsed comment attached to this declaration.
1018-
RawComment getRawComment(bool SerializedOK = false) const;
1019+
RawComment getRawComment() const;
10191020

10201021
Optional<StringRef> getGroupName() const;
10211022

10221023
Optional<StringRef> getSourceFileName() const;
10231024

10241025
Optional<unsigned> getSourceOrder() const;
10251026

1026-
/// \returns the brief comment attached to this declaration.
1027-
StringRef getBriefComment() const;
1027+
/// \returns The brief comment attached to this declaration, or the brief
1028+
/// comment attached to the comment providing decl.
1029+
StringRef getSemanticBriefComment() const;
10281030

10291031
/// Returns true if there is a Clang AST node associated
10301032
/// with self.
@@ -1099,14 +1101,19 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
10991101
/// Check if this is a declaration defined at the top level of the Swift module
11001102
bool isStdlibDecl() const;
11011103

1102-
LifetimeAnnotation getLifetimeAnnotation() const {
1103-
auto &attrs = getAttrs();
1104-
if (attrs.hasAttribute<EagerMoveAttr>())
1105-
return LifetimeAnnotation::EagerMove;
1106-
if (attrs.hasAttribute<NoEagerMoveAttr>())
1107-
return LifetimeAnnotation::Lexical;
1108-
return LifetimeAnnotation::None;
1109-
}
1104+
/// The effective lifetime resulting from the decorations on the declaration.
1105+
///
1106+
/// Usually, this, not getLifetimeAnnotationFromAttributes should be used.
1107+
LifetimeAnnotation getLifetimeAnnotation() const;
1108+
1109+
/// The source-level lifetime attribute, either @_eagerMove or @_noEagerMove
1110+
/// that the declaration bears.
1111+
///
1112+
/// Usually getLifetimeAnnotation should be used.
1113+
///
1114+
/// Needed to access the attributes before the AST has been fully formed, such
1115+
/// as when printing.
1116+
LifetimeAnnotation getLifetimeAnnotationFromAttributes() const;
11101117

11111118
bool isNoImplicitCopy() const {
11121119
return getAttrs().hasAttribute<NoImplicitCopyAttr>();
@@ -6327,6 +6334,8 @@ class ParamDecl : public VarDecl {
63276334
Specifier getSpecifier() const;
63286335
void setSpecifier(Specifier Spec);
63296336

6337+
LifetimeAnnotation getLifetimeAnnotation() const;
6338+
63306339
/// Is the type of this parameter 'inout'?
63316340
bool isInOut() const { return getSpecifier() == Specifier::InOut; }
63326341

@@ -7338,6 +7347,8 @@ class FuncDecl : public AbstractFunctionDecl {
73387347

73397348
SelfAccessKind getSelfAccessKind() const;
73407349

7350+
LifetimeAnnotation getLifetimeAnnotation() const;
7351+
73417352
void setSelfAccessKind(SelfAccessKind mod) {
73427353
Bits.FuncDecl.SelfAccess = static_cast<unsigned>(mod);
73437354
Bits.FuncDecl.SelfAccessComputed = true;

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,10 @@ ERROR(error_output_missing,none,
485485
REMARK(matching_output_produced,none,
486486
"produced matching output file '%0' for deterministic check: hash '%1'", (StringRef, StringRef))
487487

488+
// Caching related diagnostics
489+
ERROR(error_caching_no_cas_fs, none,
490+
"caching is enabled without -cas-fs option, input is not immutable", ())
491+
488492
// CAS related diagnostics
489493
ERROR(error_create_cas, none, "failed to create CAS '%0' (%1)", (StringRef, StringRef))
490494
ERROR(error_invalid_cas_id, none, "invalid CASID '%0' (%1)", (StringRef, StringRef))

include/swift/AST/DiagnosticsSIL.def

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ ERROR(exclusivity_access_required_unknown_decl,none,
8888
"%select{initialization|read|modification|deinitialization}0 requires "
8989
"exclusive access; consider copying to a local variable", (unsigned))
9090

91+
ERROR(exclusivity_access_required_moveonly,none,
92+
"overlapping accesses to %0, but "
93+
"%select{initialization|read|modification|deinitialization}1 requires "
94+
"exclusive access",
95+
(StringRef, unsigned))
96+
97+
ERROR(exclusivity_access_required_unknown_decl_moveonly,none,
98+
"overlapping accesses, but "
99+
"%select{initialization|read|modification|deinitialization}0 requires "
100+
"exclusive access", (unsigned))
101+
91102
NOTE(exclusivity_conflicting_access,none,
92103
"conflicting access is here", ())
93104

include/swift/AST/DiagnosticsSema.def

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,6 +2783,10 @@ ERROR(requires_generic_params_made_equal,none,
27832783
ERROR(requires_generic_param_made_equal_to_concrete,none,
27842784
"same-type requirement makes generic parameter %0 non-generic",
27852785
(Type))
2786+
ERROR(shadowed_generic_param,none,
2787+
"generic parameter %0 shadows generic parameter from outer scope with the same name",
2788+
(DeclName))
2789+
27862790
ERROR(recursive_decl_reference,none,
27872791
"%0 %1 references itself", (DescriptiveDeclKind, DeclBaseName))
27882792
ERROR(recursive_generic_signature,none,
@@ -3529,6 +3533,8 @@ ERROR(lifetime_invalid_global_scope,none, "%0 is only valid on methods",
35293533
ERROR(eagermove_and_lexical_combined,none,
35303534
"@_eagerMove and @_noEagerMove attributes are alternate styles of lifetimes "
35313535
"and can't be combined", ())
3536+
ERROR(eagermove_and_noncopyable_combined,none,
3537+
"@_eagerMove cannot be applied to NonCopyable types", ())
35323538

35333539
ERROR(autoclosure_function_type,none,
35343540
"@autoclosure attribute only applies to function types",
@@ -7065,6 +7071,28 @@ ERROR(invalid_macro_role_for_macro_syntax,none,
70657071
ERROR(macro_cannot_introduce_names,none,
70667072
"'%0' macros are not allowed to introduce names", (StringRef))
70677073

7074+
ERROR(macro_resolve_circular_reference, none,
7075+
"circular reference resolving %select{freestanding|attached}0 macro %1",
7076+
(bool, DeclName))
7077+
NOTE(macro_resolve_circular_reference_through, none,
7078+
"while resolving %select{freestanding|attached}0 macro %1",
7079+
(bool, DeclName))
7080+
7081+
ERROR(macro_expand_circular_reference, none,
7082+
"circular reference expanding %0 macro %1", (StringRef, DeclName))
7083+
NOTE(macro_expand_circular_reference_through, none,
7084+
"circular reference expanding %0 macro %1", (StringRef, DeclName))
7085+
7086+
ERROR(macro_expand_circular_reference_entity, none,
7087+
"circular reference expanding %0 macros on %1", (StringRef, DeclName))
7088+
NOTE(macro_expand_circular_reference_entity_through, none,
7089+
"circular reference expanding %0 macros on %1", (StringRef, DeclName))
7090+
7091+
ERROR(macro_expand_circular_reference_unnamed, none,
7092+
"circular reference expanding %0 macros", (StringRef))
7093+
NOTE(macro_expand_circular_reference_unnamed_through, none,
7094+
"circular reference expanding %0 macros", (StringRef))
7095+
70687096
//------------------------------------------------------------------------------
70697097
// MARK: Move Only Errors
70707098
//------------------------------------------------------------------------------

include/swift/AST/FileUnit.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,16 @@ class FileUnit : public DeclContext, public ASTAllocated<FileUnit> {
161161
///
162162
/// This function is an implementation detail for comment serialization.
163163
/// If you just want to get a comment attached to a decl, use
164-
/// \c Decl::getRawComment() or \c Decl::getBriefComment().
164+
/// \c Decl::getRawComment() or \c Decl::getSemanticBriefComment().
165165
virtual Optional<CommentInfo>
166166
getCommentForDecl(const Decl *D) const {
167167
return None;
168168
}
169169

170+
/// For a serialized AST file, returns \c true if an adjacent swiftdoc has been
171+
/// loaded. Otherwise, returns \c false.
172+
virtual bool hasLoadedSwiftDoc() const { return false; }
173+
170174
virtual Optional<StringRef>
171175
getGroupNameForDecl(const Decl *D) const {
172176
return None;

0 commit comments

Comments
 (0)