Skip to content

Commit 2715d0e

Browse files
committed
Merge branch 'main' into 20240710-main-to-rebranch
Conflicts: - `test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift` previously fixed on rebranch, now fixed on main (slightly differently).
2 parents d57c885 + 32af2f6 commit 2715d0e

File tree

248 files changed

+3409
-2579
lines changed

Some content is hidden

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

248 files changed

+3409
-2579
lines changed

Diff for: .github/ISSUE_TEMPLATE/bug-report.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ body:
3434
label: Reproduction
3535
description: >
3636
Provide a test case, preferably in a Markdown codeblock, and explain
37-
how to build or run it to reproduce the problem. If the problem is a
38-
poor or unexpected error, warning, fix-it, or output, please show
39-
them. Consider reducing the test case to the smallest amount of code
37+
how to build or run it to reproduce the problem.
38+
If the problem is a poor or unexpected diagnostic, fix-it, or other
39+
output, please show this output as is.
40+
For example, paste it from the terminal.
41+
Consider reducing the test case to the smallest amount of code
4042
possible — a smaller test case is easier to reason about and more
4143
appealing to contributors.
4244
value: |

Diff for: .github/PULL_REQUEST_TEMPLATE/release.md

-46
This file was deleted.

Diff for: .github/pull_request_template.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
<!-- What's in this pull request? -->
2-
Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.
3-
41
<!--
5-
If this pull request resolves any GitHub issues, link them.
6-
For information about linking a pull request to an issue, see:
2+
If this pull request is targeting a release branch, please fill out the
3+
following form:
4+
https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1
5+
6+
Otherwise, replace this comment with a description of your changes and
7+
rationale. Provide links to external references/discussions if appropriate.
8+
If this pull request resolves any GitHub issues, link them like so:
9+
10+
Resolves <link to issue>, resolves <link to another issue>.
11+
12+
For more information about linking a pull request to an issue, see:
713
https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
814
-->
9-
Resolves #NNNNN, fix apple/llvm-project#MMMMM.
1015

1116
<!--
1217
Before merging this pull request, you must run the Swift continuous integration tests.

Diff for: include/swift-c/DependencyScan/DependencyScan.h

+9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ typedef struct swiftscan_dependency_info_s *swiftscan_dependency_info_t;
4949
/// Opaque container to a link library info.
5050
typedef struct swiftscan_link_library_info_s *swiftscan_link_library_info_t;
5151

52+
/// Opaque container to a macro dependency.
53+
typedef struct swiftscan_macro_dependency_s *swiftscan_macro_dependency_t;
54+
5255
/// Opaque container to an overall result of a dependency scan.
5356
typedef struct swiftscan_dependency_graph_s *swiftscan_dependency_graph_t;
5457

@@ -73,6 +76,12 @@ typedef struct {
7376
size_t count;
7477
} swiftscan_link_library_set_t;
7578

79+
/// Set of macro dependency
80+
typedef struct {
81+
swiftscan_macro_dependency_t *macro_dependencies;
82+
size_t count;
83+
} swiftscan_macro_dependency_set_t;
84+
7685
typedef enum {
7786
SWIFTSCAN_DIAGNOSTIC_SEVERITY_ERROR = 0,
7887
SWIFTSCAN_DIAGNOSTIC_SEVERITY_WARNING = 1,

Diff for: include/swift/AST/ActorIsolation.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class ActorIsolation {
180180
return parameterIndex;
181181
}
182182

183-
/// Returns true if this actor-instance isolation appllies to the self
183+
/// Returns true if this actor-instance isolation applies to the self
184184
/// parameter of a method.
185185
bool isActorInstanceForSelfParameter() const {
186186
return getActorInstanceParameter() == 0;

Diff for: include/swift/AST/Decl.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -2828,10 +2828,6 @@ class ValueDecl : public Decl {
28282828
/// optional result.
28292829
unsigned isIUO : 1;
28302830

2831-
/// Whether we're in the common case where the ActorIsolationRequest
2832-
/// request returned ActorIsolation::forUnspecified().
2833-
unsigned noActorIsolation : 1;
2834-
28352831
/// Whether we've evaluated the ApplyAccessNoteRequest.
28362832
unsigned accessNoteApplied : 1;
28372833
} LazySemanticInfo = { };
@@ -2847,6 +2843,7 @@ class ValueDecl : public Decl {
28472843
friend class ActorIsolationRequest;
28482844
friend class DynamicallyReplacedDeclRequest;
28492845
friend class ApplyAccessNoteRequest;
2846+
28502847
friend class Decl;
28512848
SourceLoc getLocFromSource() const { return NameLoc; }
28522849
protected:

Diff for: include/swift/AST/DiagnosticBridge.h

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
//===--- DiagnosticBridge.h - Diagnostic Bridge to SwiftSyntax --*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 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+
// This file declares the DiagnosticBridge class, which bridges to swift-syntax
14+
// for diagnostics printing.
15+
//
16+
//===----------------------------------------------------------------------===//
17+
18+
#ifndef SWIFT_BASIC_DIAGNOSTICBRIDGE_H
19+
#define SWIFT_BASIC_DIAGNOSTICBRIDGE_H
20+
21+
#include "swift/AST/DiagnosticConsumer.h"
22+
#include "swift/Basic/SourceManager.h"
23+
#include "llvm/ADT/DenseMap.h"
24+
#include "llvm/Support/raw_ostream.h"
25+
26+
namespace swift {
27+
/// Declare the bridge between swift-syntax and swift-frontend for diagnostics
28+
/// handling. The methods in this class should only be called when
29+
/// `SWIFT_BUILD_SWIFT_SYNTAX` is defined as they are otherwise undefined.
30+
class DiagnosticBridge {
31+
/// A queued up source file known to the queued diagnostics.
32+
using QueuedBuffer = void *;
33+
34+
/// The queued diagnostics structure.
35+
void *queuedDiagnostics = nullptr;
36+
llvm::DenseMap<unsigned, QueuedBuffer> queuedBuffers;
37+
38+
/// Source file syntax nodes cached by { source manager, buffer ID }.
39+
llvm::DenseMap<std::pair<SourceManager *, unsigned>, void *> sourceFileSyntax;
40+
41+
public:
42+
/// Enqueue diagnostics.
43+
void enqueueDiagnostic(SourceManager &SM, const DiagnosticInfo &Info,
44+
unsigned innermostBufferID);
45+
46+
/// Flush all enqueued diagnostics.
47+
void flush(llvm::raw_ostream &OS, bool includeTrailingBreak,
48+
bool forceColors);
49+
50+
/// Retrieve the stack of source buffers from the provided location out to
51+
/// a physical source file, with source buffer IDs for each step along the way
52+
/// due to (e.g.) macro expansions or generated code.
53+
///
54+
/// The resulting vector will always contain valid source locations. If the
55+
/// initial location is invalid, the result will be empty.
56+
static SmallVector<unsigned, 1> getSourceBufferStack(SourceManager &sourceMgr,
57+
SourceLoc loc);
58+
59+
DiagnosticBridge() = default;
60+
~DiagnosticBridge();
61+
62+
private:
63+
/// Retrieve the SourceFileSyntax for the given buffer.
64+
void *getSourceFileSyntax(SourceManager &SM, unsigned bufferID,
65+
StringRef displayName);
66+
67+
void queueBuffer(SourceManager &sourceMgr, unsigned bufferID);
68+
};
69+
} // namespace swift
70+
71+
#endif

Diff for: include/swift/AST/DiagnosticEngine.h

-4
Original file line numberDiff line numberDiff line change
@@ -1687,10 +1687,6 @@ namespace swift {
16871687
const StringRef Message;
16881688
};
16891689

1690-
/// Retrieve the macro name for a generated source info that represents
1691-
/// a macro expansion.
1692-
DeclName getGeneratedSourceInfoMacroName(const GeneratedSourceInfo &info);
1693-
16941690
} // end namespace swift
16951691

16961692
#endif

Diff for: include/swift/AST/DiagnosticsCommon.def

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ ERROR(error_opening_output,none,
3232
ERROR(error_closing_output,none,
3333
"error closing '%0' for output: %1", (StringRef, StringRef))
3434

35+
ERROR(error_mccas,none,
36+
"error trying to materialize MCCAS object file: %0", (StringRef))
37+
3538
ERROR(cannot_find_group_info_file,none,
3639
"cannot find group info file at path: '%0'", (StringRef))
3740

Diff for: include/swift/AST/DiagnosticsSIL.def

+4
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,10 @@ NOTE(regionbasedisolation_named_isolated_closure_yields_race, none,
10281028
"%0%1 is captured by a %2 closure. %2 uses in closure may race against later %3 uses",
10291029
(StringRef, Identifier, ActorIsolation, ActorIsolation))
10301030

1031+
NOTE(regionbasedisolation_named_transfer_nt_asynclet_capture, none,
1032+
"sending %1 %0 into async let risks causing data races between nonisolated and %1 uses",
1033+
(Identifier, StringRef))
1034+
10311035
// Misc Error.
10321036
ERROR(regionbasedisolation_task_or_actor_isolated_transferred, none,
10331037
"task or actor isolated value cannot be sent", ())

Diff for: include/swift/AST/DiagnosticsSema.def

+12
Original file line numberDiff line numberDiff line change
@@ -3997,6 +3997,12 @@ ERROR(reasync_without_async_parameter,none,
39973997

39983998
ERROR(inherits_executor_without_async,none,
39993999
"non-async functions cannot inherit an executor", ())
4000+
ERROR(isolation_in_inherits_executor,none,
4001+
"#isolation%select{| (introduced by a default argument)}0 cannot be used "
4002+
"within an '@_unsafeInheritExecutor' function", (bool))
4003+
ERROR(unsafe_inherits_executor_deprecated,none,
4004+
"@_unsafeInheritExecutor attribute is deprecated; consider an "
4005+
"'isolated' parameter defaulted to '#isolation' instead", ())
40004006

40014007
ERROR(lifetime_invalid_global_scope,none, "%0 is only valid on methods",
40024008
(DeclAttribute))
@@ -7820,6 +7826,9 @@ WARNING(suppress_already_suppressed_protocol,none,
78207826
ERROR(extension_conforms_to_invertible_and_others, none,
78217827
"conformance to '%0' must be declared in a separate extension",
78227828
(StringRef))
7829+
ERROR(invertible_conformance_other_source_file,none,
7830+
"conformance to '%0' must occur in the same source file as %kind1",
7831+
(StringRef, const ValueDecl *))
78237832

78247833
// -- older ones below --
78257834
ERROR(noncopyable_parameter_requires_ownership, none,
@@ -7994,6 +8003,9 @@ ERROR(lifetime_dependence_cannot_infer_ambiguous_candidate, none,
79948003
())
79958004
ERROR(lifetime_dependence_immortal_conflict_name, none,
79968005
"conflict between the parameter name and immortal keyword", ())
8006+
ERROR(lifetime_dependence_function_type, none,
8007+
"lifetime dependencies on function types are not supported",
8008+
())
79978009

79988010
//===----------------------------------------------------------------------===//
79998011
// MARK: Sending

Diff for: include/swift/AST/ModuleDependencies.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ struct CommonSwiftTextualModuleDependencyDetails {
253253
std::vector<std::string> bridgingModuleDependencies;
254254

255255
/// The macro dependencies.
256-
llvm::StringMap<MacroPluginDependency> macroDependencies;
256+
std::map<std::string, MacroPluginDependency> macroDependencies;
257257

258258
/// The Swift frontend invocation arguments to build the Swift module from the
259259
/// interface.
@@ -324,7 +324,7 @@ class SwiftInterfaceModuleDependenciesStorage
324324
void addMacroDependency(StringRef macroModuleName, StringRef libraryPath,
325325
StringRef executablePath) {
326326
textualModuleDetails.macroDependencies.insert(
327-
{macroModuleName, {libraryPath.str(), executablePath.str()}});
327+
{macroModuleName.str(), {libraryPath.str(), executablePath.str()}});
328328
}
329329
};
330330

@@ -380,7 +380,7 @@ class SwiftSourceModuleDependenciesStorage
380380
void addMacroDependency(StringRef macroModuleName, StringRef libraryPath,
381381
StringRef executablePath) {
382382
textualModuleDetails.macroDependencies.insert(
383-
{macroModuleName, {libraryPath.str(), executablePath.str()}});
383+
{macroModuleName.str(), {libraryPath.str(), executablePath.str()}});
384384
}
385385
};
386386

@@ -796,7 +796,7 @@ class ModuleDependencyInfo {
796796
/// For a Source dependency, register a `Testable` import
797797
void addTestableImport(ImportPath::Module module);
798798

799-
/// For a Source dependency, register a macro dependency.
799+
/// For a Source/Textual dependency, register a macro dependency.
800800
void addMacroDependency(StringRef macroModuleName, StringRef libraryPath,
801801
StringRef executablePath);
802802

Diff for: include/swift/AST/PrintOptions.h

-21
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,6 @@ struct PrintOptions {
372372
/// Whether to suppress printing of custom attributes that are expanded macros.
373373
bool SuppressExpandedMacros = true;
374374

375-
/// Whether we're supposed to slap a @rethrows on `AsyncSequence` /
376-
/// `AsyncIteratorProtocol` for backward-compatibility reasons.
377-
bool AsyncSequenceRethrows = false;
378-
379375
/// Suppress the @isolated(any) attribute.
380376
bool SuppressIsolatedAny = false;
381377

@@ -385,12 +381,6 @@ struct PrintOptions {
385381
/// Suppress 'sending' on arguments and results.
386382
bool SuppressSendingArgsAndResults = false;
387383

388-
/// Suppress Noncopyable generics.
389-
bool SuppressNoncopyableGenerics = false;
390-
391-
/// Suppress printing of `borrowing` and `consuming`.
392-
bool SuppressNoncopyableOwnershipModifiers = false;
393-
394384
/// Suppress printing of '~Proto' for suppressible, non-invertible protocols.
395385
bool SuppressConformanceSuppression = false;
396386

@@ -618,17 +608,6 @@ struct PrintOptions {
618608
QualifyNestedDeclarations ShouldQualifyNestedDeclarations =
619609
QualifyNestedDeclarations::Never;
620610

621-
/// If true, we print a protocol's primary associated types using the
622-
/// primary associated type syntax: `protocol Foo<Type1, ...>`.
623-
///
624-
/// If false, we print them as ordinary associated types.
625-
bool PrintPrimaryAssociatedTypes = true;
626-
627-
/// Whether or not to print `@attached(extension)` attributes on
628-
/// macro declarations. This is used for feature suppression in
629-
/// Swift interface printing.
630-
bool PrintExtensionMacroAttributes = true;
631-
632611
/// If this is not \c nullptr then function bodies (including accessors
633612
/// and constructors) will be printed by this function.
634613
std::function<void(const ValueDecl *, ASTPrinter &)> FunctionBody;

Diff for: include/swift/AST/SubstitutionMap.h

-16
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,6 @@ class SubstitutionMap {
7373
/// signature nor any replacement types/conformances.
7474
Storage *storage = nullptr;
7575

76-
public:
77-
/// Retrieve the array of replacement types, which line up with the
78-
/// generic parameters.
79-
///
80-
/// Note that the types may be null, for cases where the generic parameter
81-
/// is concrete but hasn't been queried yet.
82-
///
83-
/// Prefer \c getReplacementTypes, this is public for printing purposes.
84-
ArrayRef<Type> getReplacementTypesBuffer() const;
85-
86-
private:
87-
MutableArrayRef<Type> getReplacementTypesBuffer();
88-
89-
/// Retrieve a mutable reference to the buffer of conformances.
90-
MutableArrayRef<ProtocolConformanceRef> getConformancesBuffer();
91-
9276
/// Form a substitution map for the given generic signature with the
9377
/// specified replacement types and conformances.
9478
SubstitutionMap(GenericSignature genericSig,

Diff for: include/swift/AST/TypeCheckRequests.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -1537,8 +1537,7 @@ class GlobalActorAttributeRequest
15371537
class ActorIsolationRequest :
15381538
public SimpleRequest<ActorIsolationRequest,
15391539
ActorIsolation(ValueDecl *),
1540-
RequestFlags::SeparatelyCached |
1541-
RequestFlags::SplitCached> {
1540+
RequestFlags::Cached> {
15421541
public:
15431542
using SimpleRequest::SimpleRequest;
15441543

@@ -1548,10 +1547,8 @@ class ActorIsolationRequest :
15481547
ActorIsolation evaluate(Evaluator &evaluator, ValueDecl *value) const;
15491548

15501549
public:
1551-
// Separate.
1550+
// Caching
15521551
bool isCached() const { return true; }
1553-
std::optional<ActorIsolation> getCachedResult() const;
1554-
void cacheResult(ActorIsolation value) const;
15551552
};
15561553

15571554
/// Determine whether the given function should have an isolated 'self'.

0 commit comments

Comments
 (0)