Skip to content

Commit d22a3bd

Browse files
authored
Merge branch 'main' into sdkrelative
2 parents a007833 + 5db0f83 commit d22a3bd

File tree

195 files changed

+3677
-1102
lines changed

Some content is hidden

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

195 files changed

+3677
-1102
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
/docs/Windows* @compnerd
5656

5757
# include
58-
/include/swift-c/DependencyScan/ @artemcm
58+
/include/swift-c/DependencyScan/ @artemcm @cachemeifyoucan
5959
/include/swift/*Demangl*/ @rjmccall
6060
/include/swift/AST/ @hborla @slavapestov @xedin
6161
/include/swift/AST/*Availability* @tshortli
@@ -71,7 +71,7 @@
7171
/include/swift/Basic/ @DougGregor
7272
/include/swift/Basic/Features.def @DougGregor @hborla
7373
/include/swift/ClangImporter @zoecarver @hyp @egorzhdan @beccadax @ian-twilightcoder @Xazax-hun
74-
/include/swift/DependencyScan @artemcm
74+
/include/swift/DependencyScan @artemcm @cachemeifyoucan
7575
/include/swift/Driver*/ @artemcm
7676
/include/swift/Frontend*/ @artemcm @tshortli
7777
/include/swift/IDE/ @ahoppen @bnbarham @hamishknight @rintaro
@@ -118,7 +118,7 @@
118118
/lib/Basic/Windows @compnerd
119119
/lib/ClangImporter @zoecarver @hyp @egorzhdan @beccadax @ian-twilightcoder @Xazax-hun
120120
/lib/ClangImporter/DWARFImporter* @adrian-prantl
121-
/lib/DependencyScan @artemcm
121+
/lib/DependencyScan @artemcm @cachemeifyoucan
122122
/lib/Driver*/ @artemcm
123123
/lib/DriverTool/autolink_extract_main.cpp @MaxDesiatov @etcwilde
124124
/lib/DriverTool/sil* @jckarter
@@ -247,7 +247,7 @@
247247
/unittests/*Demangl*/ @rjmccall
248248
/unittests/AST/ @hborla @slavapestov @xedin
249249
/unittests/AST/*Evaluator* @CodaFi @slavapestov
250-
/unittests/DependencyScan/ @artemcm
250+
/unittests/DependencyScan/ @artemcm @cachemeifyoucan
251251
/unittests/FrontendTool/ @artemcm @tshortli
252252
/unittests/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @hamishknight @rintaro
253253
/unittests/Reflection/ @slavapestov

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ docs/_build
5252

5353
# SwiftPM
5454
.build
55+
.index-build
5556
.swiftpm
5657

5758
#==============================================================================#

Runtimes/Core/core/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ target_compile_options(swiftCore PRIVATE
284284
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature FreestandingMacros>"
285285
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature BitwiseCopyable>"
286286
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature Extern>"
287-
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature DebugDescriptionMacro>"
288287
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -group-info-path -Xfrontend ${CMAKE_CURRENT_SOURCE_DIR}/GroupInfo.json>"
289288
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -enable-experimental-concise-pound-file>"
290289
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolinking-runtime-compatibility-concurrency>"

cmake/caches/Windows-aarch64.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ set(LLVM_TARGETS_TO_BUILD AArch64 ARM WebAssembly X86 CACHE STRING "")
5050
set(LLVM_BUILD_LLVM_DYLIB NO CACHE BOOL "")
5151
set(LLVM_BUILD_LLVM_C_DYLIB NO CACHE BOOL "")
5252
set(LLVM_ENABLE_LIBEDIT NO CACHE BOOL "")
53-
set(LLVM_ENABLE_LIBXML2 NO CACHE BOOL "")
53+
set(LLVM_ENABLE_LIBXML2 YES CACHE BOOL "")
5454
set(LLVM_ENABLE_OCAMLDOC NO CACHE BOOL "")
5555
set(LLVM_ENABLE_TERMINFO NO CACHE BOOL "")
5656
set(LLVM_ENABLE_Z3_SOLVER NO CACHE BOOL "")
@@ -62,12 +62,14 @@ set(LLVM_INCLUDE_GO_TESTS NO CACHE BOOL "")
6262
set(LLVM_TOOL_GOLD_BUILD NO CACHE BOOL "")
6363
set(LLVM_TOOL_LLVM_SHLIB_BUILD NO CACHE BOOL "")
6464

65+
set(CLANG_ENABLE_LIBXML2 NO CACHE BOOL "")
66+
6567
# Avoid swig dependency for lldb
6668
set(LLDB_ALLOW_STATIC_BINDINGS YES CACHE BOOL "")
6769
set(LLDB_USE_STATIC_BINDINGS YES CACHE BOOL "")
6870
set(LLDB_ENABLE_PYTHON YES CACHE BOOL "")
6971
set(LLDB_EMBED_PYTHON_HOME NO CACHE BOOL "")
70-
set(LLDB_ENABLE_LIBXML2 NO CACHE BOOL "")
72+
set(LLDB_ENABLE_LIBXML2 YES CACHE BOOL "")
7173

7274
# This requires perl which may not be available on Windows
7375
set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "")

cmake/caches/Windows-x86_64.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ set(LLVM_TARGETS_TO_BUILD AArch64 ARM WebAssembly X86 CACHE STRING "")
9090
set(LLVM_BUILD_LLVM_DYLIB NO CACHE BOOL "")
9191
set(LLVM_BUILD_LLVM_C_DYLIB NO CACHE BOOL "")
9292
set(LLVM_ENABLE_LIBEDIT NO CACHE BOOL "")
93-
set(LLVM_ENABLE_LIBXML2 NO CACHE BOOL "")
93+
set(LLVM_ENABLE_LIBXML2 YES CACHE BOOL "")
9494
set(LLVM_ENABLE_OCAMLDOC NO CACHE BOOL "")
9595
set(LLVM_ENABLE_TERMINFO NO CACHE BOOL "")
9696
set(LLVM_ENABLE_Z3_SOLVER NO CACHE BOOL "")
@@ -102,12 +102,14 @@ set(LLVM_INCLUDE_GO_TESTS NO CACHE BOOL "")
102102
set(LLVM_TOOL_GOLD_BUILD NO CACHE BOOL "")
103103
set(LLVM_TOOL_LLVM_SHLIB_BUILD NO CACHE BOOL "")
104104

105+
set(CLANG_ENABLE_LIBXML2 NO CACHE BOOL "")
106+
105107
# Avoid swig dependency for lldb
106108
set(LLDB_ALLOW_STATIC_BINDINGS YES CACHE BOOL "")
107109
set(LLDB_USE_STATIC_BINDINGS YES CACHE BOOL "")
108110
set(LLDB_ENABLE_PYTHON YES CACHE BOOL "")
109111
set(LLDB_EMBED_PYTHON_HOME NO CACHE BOOL "")
110-
set(LLDB_ENABLE_LIBXML2 NO CACHE BOOL "")
112+
set(LLDB_ENABLE_LIBXML2 YES CACHE BOOL "")
111113

112114
# This requires perl which may not be available on Windows
113115
set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "")

cmake/modules/DarwinSDKs.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set(SUPPORTED_IOS_SIMULATOR_ARCHS "x86_64;arm64")
33
set(SUPPORTED_TVOS_ARCHS "arm64")
44
set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64;arm64")
55
set(SUPPORTED_WATCHOS_ARCHS "armv7k;arm64_32")
6-
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "x86_64;arm64")
6+
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;x86_64;arm64")
77
set(SUPPORTED_OSX_ARCHS "x86_64;arm64")
88
set(SUPPORTED_XROS_ARCHS "arm64;arm64e")
99
set(SUPPORTED_XROS_SIMULATOR_ARCHS "arm64")

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ function(remove_sdk_unsupported_archs name os sdk_path deployment_version archit
9191
# 32-bit watchOS is not listed explicitly in SDK settings.
9292
message(STATUS "Assuming ${name} SDK at ${sdk_path} supports architecture ${arch}")
9393
list(APPEND architectures ${arch})
94+
elseif(arch STREQUAL "i386" AND os STREQUAL "watchsimulator")
95+
# 32-bit watchOS simulator is not listed explicitly in SDK settings.
96+
message(STATUS "Assuming ${name} SDK at ${sdk_path} supports architecture ${arch}")
97+
list(APPEND architectures ${arch})
9498
else()
9599
message(STATUS "${name} SDK at ${sdk_path} does not support architecture ${arch}")
96100
endif()

docs/Testing.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,6 @@ code for the target that is not the build machine:
298298

299299
Add ``REQUIRES: executable_test`` to the test.
300300

301-
* ``%target-run-simple-swift``: build a one-file Swift program and run it on
302-
the target machine.
303-
304-
Use this substitution for executable tests that don't require special
305-
compiler arguments.
306-
307-
Add ``REQUIRES: executable_test`` to the test.
308-
309301
* ``%target-run-stdlib-swift``: like ``%target-run-simple-swift`` with
310302
``-parse-stdlib -Xfrontend -disable-access-control``.
311303

include/swift/AST/ASTMangler.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ enum class DestructorKind {
4545
/// The mangler for AST declarations.
4646
class ASTMangler : public Mangler {
4747
protected:
48-
#if 0 // STAGING
4948
const ASTContext &Context;
50-
#endif
5149
ModuleDecl *Mod = nullptr;
5250

5351
/// Optimize out protocol names if a type only conforms to one protocol.
@@ -189,19 +187,6 @@ class ASTMangler : public Mangler {
189187
HasSymbolQuery,
190188
};
191189

192-
// STAGING: legacy constructor for LLDB
193-
/// lldb overrides the defaulted argument to 'true'.
194-
ASTMangler(bool DWARFMangling = false) {
195-
if (DWARFMangling) {
196-
DWARFMangling = true;
197-
RespectOriginallyDefinedIn = false;
198-
}
199-
}
200-
201-
/// lldb overrides the defaulted argument to 'true'.
202-
ASTMangler(const ASTContext &Ctx, bool DWARFMangling = false) : ASTMangler(DWARFMangling) {}
203-
204-
#if 0
205190
/// lldb overrides the defaulted argument to 'true'.
206191
ASTMangler(const ASTContext &Ctx, bool DWARFMangling = false) : Context(Ctx) {
207192
if (DWARFMangling) {
@@ -214,7 +199,6 @@ class ASTMangler : public Mangler {
214199
}
215200

216201
const ASTContext &getASTContext() { return Context; }
217-
#endif
218202

219203
void addTypeSubstitution(Type type, GenericSignature sig) {
220204
type = dropProtocolsFromAssociatedTypes(type, sig);

include/swift/AST/Attr.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,13 +508,17 @@ class DeclAttribute : public AttributeBase {
508508

509509
/// Create a copy of this attribute.
510510
DeclAttribute *clone(ASTContext &ctx) const;
511+
512+
/// Determine whether we can clone this attribute.
513+
bool canClone() const;
511514
};
512515

513516
#define UNIMPLEMENTED_CLONE(AttrType) \
514517
AttrType *clone(ASTContext &ctx) const { \
515518
llvm_unreachable("unimplemented"); \
516519
return nullptr; \
517-
}
520+
} \
521+
bool canClone() const { return false; }
518522

519523
/// Describes a "simple" declaration attribute that carries no data.
520524
template<DeclAttrKind Kind>
@@ -1916,9 +1920,13 @@ class CustomAttr final : public DeclAttribute {
19161920

19171921
/// Create a copy of this attribute.
19181922
CustomAttr *clone(ASTContext &ctx) const {
1923+
assert(argList == nullptr &&
1924+
"Cannot clone custom attribute with an argument list");
19191925
return create(ctx, AtLoc, getTypeExpr(), initContext, argList, isImplicit());
19201926
}
19211927

1928+
bool canClone() const { return argList == nullptr; }
1929+
19221930
private:
19231931
friend class CustomAttrNominalRequest;
19241932
void resetTypeInformation(TypeExpr *repr);

include/swift/AST/Decl.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3492,7 +3492,7 @@ class OpaqueTypeDecl final :
34923492
///
34933493
/// This is more complex than just checking `getNamingDecl` because the
34943494
/// function could also be the getter of a storage declaration.
3495-
bool isOpaqueReturnTypeOfFunction(const AbstractFunctionDecl *func) const;
3495+
bool isOpaqueReturnTypeOf(const Decl *owner) const;
34963496

34973497
/// Get the ordinal of the anonymous opaque parameter of this decl with type
34983498
/// repr `repr`, as introduce implicitly by an occurrence of "some" in return
@@ -6817,6 +6817,9 @@ class ParamDecl : public VarDecl {
68176817

68186818
/// Whether or not this parameter is 'isolated'.
68196819
IsIsolated = 1 << 2,
6820+
6821+
/// Whether this parameter is `@_addressable`.
6822+
IsAddressable = 1 << 3,
68206823

68216824
/// Whether or not this parameter is 'sending'.
68226825
IsSending = 1 << 4,
@@ -7107,6 +7110,18 @@ class ParamDecl : public VarDecl {
71077110
removeFlag(Flag::IsSending);
71087111
}
71097112

7113+
/// Whether or not this parameter is marked with '@_addressable'.
7114+
bool isAddressable() const {
7115+
return getOptions().contains(Flag::IsAddressable);
7116+
}
7117+
7118+
void setAddressable(bool value = true) {
7119+
if (value)
7120+
addFlag(Flag::IsAddressable);
7121+
else
7122+
removeFlag(Flag::IsAddressable);
7123+
}
7124+
71107125
/// Whether or not this parameter is marked with '_const'.
71117126
bool isCompileTimeConst() const {
71127127
return ArgumentNameAndFlags.getInt().contains(

include/swift/AST/DiagnosticEngine.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "swift/AST/ActorIsolation.h"
2222
#include "swift/AST/DeclNameLoc.h"
2323
#include "swift/AST/DiagnosticConsumer.h"
24+
#include "swift/AST/DiagnosticGroups.h"
2425
#include "swift/AST/TypeLoc.h"
2526
#include "swift/Basic/PrintDiagnosticNamesMode.h"
2627
#include "swift/Basic/Statistic.h"
@@ -498,6 +499,7 @@ namespace swift {
498499

499500
private:
500501
DiagID ID;
502+
DiagGroupID GroupID;
501503
SmallVector<DiagnosticArgument, 3> Args;
502504
SmallVector<CharSourceRange, 2> Ranges;
503505
SmallVector<FixIt, 2> FixIts;
@@ -510,7 +512,10 @@ namespace swift {
510512
friend DiagnosticEngine;
511513
friend class InFlightDiagnostic;
512514

513-
Diagnostic(DiagID ID) : ID(ID) {}
515+
Diagnostic(DiagID ID, DiagGroupID GroupID) : ID(ID), GroupID(GroupID) {}
516+
517+
/// Constructs a Diagnostic with DiagGroupID infered from DiagID.
518+
Diagnostic(DiagID ID);
514519

515520
public:
516521
// All constructors are intentionally implicit.
@@ -535,6 +540,7 @@ namespace swift {
535540

536541
// Accessors.
537542
DiagID getID() const { return ID; }
543+
DiagGroupID getGroupID() const { return GroupID; }
538544
ArrayRef<DiagnosticArgument> getArgs() const { return Args; }
539545
ArrayRef<CharSourceRange> getRanges() const { return Ranges; }
540546
ArrayRef<FixIt> getFixIts() const { return FixIts; }
@@ -1434,7 +1440,8 @@ namespace swift {
14341440

14351441
/// Generate DiagnosticInfo for a Diagnostic to be passed to consumers.
14361442
std::optional<DiagnosticInfo>
1437-
diagnosticInfoForDiagnostic(const Diagnostic &diagnostic);
1443+
diagnosticInfoForDiagnostic(const Diagnostic &diagnostic,
1444+
bool includeDiagnosticName);
14381445

14391446
/// Send \c diag to all diagnostic consumers.
14401447
void emitDiagnostic(const Diagnostic &diag);
@@ -1460,9 +1467,16 @@ namespace swift {
14601467
public:
14611468
DiagnosticKind declaredDiagnosticKindFor(const DiagID id);
14621469

1463-
llvm::StringRef
1464-
diagnosticStringFor(const DiagID id,
1465-
PrintDiagnosticNamesMode printDiagnosticNamesMode);
1470+
/// Get a localized format string for a given `DiagID`. If no localization
1471+
/// available returns the default string for that `DiagID`.
1472+
llvm::StringRef diagnosticStringFor(DiagID id);
1473+
1474+
/// Get a localized format string with an optional diagnostic name appended
1475+
/// to it. The diagnostic name type is defined by
1476+
/// `PrintDiagnosticNamesMode`.
1477+
llvm::StringRef diagnosticStringWithNameFor(
1478+
DiagID id, DiagGroupID groupID,
1479+
PrintDiagnosticNamesMode printDiagnosticNamesMode);
14661480

14671481
static llvm::StringRef diagnosticIDStringFor(const DiagID id);
14681482

include/swift/AST/DiagnosticGroups.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ GROUP(no_group, "")
2525
GROUP(DeprecatedDeclaration, "DeprecatedDeclaration.md")
2626
GROUP(Unsafe, "Unsafe.md")
2727
GROUP(UnknownWarningGroup, "UnknownWarningGroup.md")
28+
GROUP(DeclarationUnavailableFromAsynchronousContext, "DeclarationUnavailableFromAsynchronousContext.md")
2829

2930
#define UNDEFINE_DIAGNOSTIC_GROUPS_MACROS
3031
#include "swift/AST/DefineDiagnosticGroupsMacros.h"

include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,14 @@ ERROR(foreign_reference_types_invalid_retain_release, none,
231231
"type '%2'",
232232
(bool, StringRef, StringRef))
233233

234-
ERROR(foreign_reference_types_retain_release_non_void_return_type, none,
235-
"specified %select{retain|release}0 function '%1' is invalid; "
236-
"%select{retain|release}0 function must have 'void' return type",
237-
(bool, StringRef))
234+
ERROR(foreign_reference_types_retain_non_void_or_self_return_type, none,
235+
"specified retain function '%0' is invalid; "
236+
"retain function must have 'void' or parameter return type",
237+
(StringRef))
238+
ERROR(foreign_reference_types_release_non_void_return_type, none,
239+
"specified release function '%0' is invalid; "
240+
"release function must have 'void' return type",
241+
(StringRef))
238242
ERROR(foreign_reference_types_retain_release_not_a_function_decl, none,
239243
"specified %select{retain|release}0 function '%1' is not a function",
240244
(bool, StringRef))
@@ -259,23 +263,28 @@ ERROR(failed_base_method_call_synthesis,none,
259263
(ValueDecl *, ValueDecl *))
260264

261265
ERROR(both_returns_retained_returns_unretained, none,
262-
"%0 cannot be annotated with both swift_attr('returns_retained') and "
263-
"swift_attr('returns_unretained') attributes",
266+
"%0 cannot be annotated with both SWIFT_RETURNS_RETAINED and "
267+
"SWIFT_RETURNS_UNRETAINED",
264268
(const clang::NamedDecl *))
265269

266270
ERROR(returns_retained_or_returns_unretained_for_non_cxx_frt_values, none,
267-
"%0 cannot be annotated with either swift_attr('returns_retained') or "
268-
"swift_attr('returns_unretained') attribute because it is not returning "
269-
"a 'SWIFT_SHARED_REFERENCE' type",
271+
"%0 cannot be annotated with either SWIFT_RETURNS_RETAINED or "
272+
"SWIFT_RETURNS_UNRETAINED because it is not returning "
273+
"a SWIFT_SHARED_REFERENCE type",
270274
(const clang::NamedDecl *))
271275

272276
// TODO: make this case an error in next cxx-interop versions rdar://138806722
273-
WARNING(
274-
no_returns_retained_returns_unretained, none,
275-
"%0 is returning a 'SWIFT_SHARED_REFERENCE' type but is not annotated "
276-
"with either swift_attr('returns_retained') or "
277-
"swift_attr('returns_unretained') attributes",
278-
(const clang::NamedDecl *))
277+
WARNING(no_returns_retained_returns_unretained, none,
278+
"%0 should be annotated with either SWIFT_RETURNS_RETAINED or "
279+
"SWIFT_RETURNS_UNRETAINED as it is returning a SWIFT_SHARED_REFERENCE",
280+
(const clang::NamedDecl *))
281+
282+
WARNING(returns_retained_returns_unretained_on_overloaded_operator, none,
283+
"SWIFT_RETURNS_RETAINED and SWIFT_RETURNS_UNRETAINED is not supported "
284+
"yet for overloaded C++ %0. Overloaded C++ operators always "
285+
"return "
286+
"SWIFT_SHARED_REFERENCE types as owned ",
287+
(const clang::NamedDecl *))
279288

280289
NOTE(unsupported_builtin_type, none, "built-in type '%0' not supported", (StringRef))
281290
NOTE(record_field_not_imported, none, "field %0 unavailable (cannot import)", (const clang::NamedDecl*))

include/swift/AST/DiagnosticsCommon.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ ERROR(error_no_group_info,none,
4747
NOTE(brace_stmt_suggest_do,none,
4848
"did you mean to use a 'do' statement?", ())
4949

50+
// `error_in_future_swift_version` does not have a group because warnings of this kind
51+
// inherit the group from the wrapped error.
5052
WARNING(error_in_future_swift_version,none,
5153
"%0; this is an error in the Swift %1 language mode",
5254
(DiagnosticInfo *, unsigned))
5355

56+
// `error_in_a_future_swift_version` does not have a group because warnings of this kind
57+
// inherit the group from the wrapped error.
5458
WARNING(error_in_a_future_swift_version,none,
5559
"%0; this will be an error in a future Swift language mode",
5660
(DiagnosticInfo *))

0 commit comments

Comments
 (0)