Skip to content

Commit 1a4e71c

Browse files
authored
Merge branch 'main' into mainwinarm64
2 parents 83ee8eb + f7d1c59 commit 1a4e71c

File tree

75 files changed

+1370
-856
lines changed

Some content is hidden

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

75 files changed

+1370
-856
lines changed

cmake/caches/Windows-aarch64.cmake

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -26,65 +26,21 @@ set(LLVM_DEFAULT_TARGET_TRIPLE aarch64-unknown-windows-msvc CACHE STRING "")
2626
set(LLVM_APPEND_VC_REV NO CACHE BOOL "")
2727
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR YES CACHE BOOL "")
2828
set(LLVM_ENABLE_PYTHON YES CACHE BOOL "")
29-
30-
set(default_targets
31-
x86_64-unknown-windows-msvc
29+
set(LLVM_RUNTIME_TARGETS
3230
aarch64-unknown-windows-msvc
33-
i686-unknown-windows-msvc)
34-
set(LLVM_RUNTIME_TARGETS ${default_targets} CACHE STRING "")
35-
36-
# Build the android builtins if NDK path is provided.
37-
if(NOT "$ENV{NDKPATH}" STREQUAL "")
38-
list(APPEND default_targets
39-
aarch64-unknown-linux-android
40-
x86_64-unknown-linux-android
41-
i686-unknown-linux-android
42-
armv7-unknown-linux-androideabi)
43-
endif()
44-
45-
set(LLVM_BUILTIN_TARGETS ${default_targets} CACHE STRING "")
46-
31+
CACHE STRING "")
4732
foreach(target ${LLVM_RUNTIME_TARGETS})
4833
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES
4934
compiler-rt
5035
CACHE STRING "")
5136
set(RUNTIMES_${target}_CMAKE_MT mt CACHE STRING "")
5237
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
5338
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
54-
set(RUNTIMES_${target}_COMPILER_RT_BUILD_BUILTINS YES CACHE BOOL "")
5539
set(RUNTIMES_${target}_COMPILER_RT_BUILD_CRT NO CACHE BOOL "")
5640
set(RUNTIMES_${target}_COMPILER_RT_BUILD_LIBFUZZER NO CACHE BOOL "")
57-
set(RUNTIMES_${target}_COMPILER_RT_BUILD_ORC NO CACHE BOOL "")
5841
set(RUNTIMES_${target}_COMPILER_RT_BUILD_PROFILE YES CACHE BOOL "")
59-
set(RUNTIMES_${target}_COMPILER_RT_BUILD_XRAY NO CACHE BOOL "")
60-
# Sanitizers will be configured, but not built. We have separate build
61-
# steps for that, because we need a different shell for each target.
6242
set(RUNTIMES_${target}_COMPILER_RT_BUILD_SANITIZERS NO CACHE BOOL "")
63-
endforeach()
64-
65-
foreach(target ${LLVM_BUILTIN_TARGETS})
66-
set(BUILTINS_${target}_CMAKE_MT mt CACHE STRING "")
67-
if(${target} MATCHES windows-msvc)
68-
set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
69-
elseif(${target} MATCHES linux-android)
70-
# Use a single 'linux' directory and arch-based lib names on Android.
71-
set(BUILTINS_${target}_LLVM_ENABLE_PER_TARGET_RUNTIME_DIR NO CACHE BOOL "")
72-
set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Android CACHE STRING "")
73-
if(${target} MATCHES aarch64)
74-
set(BUILTINS_${target}_CMAKE_ANDROID_ARCH_ABI arm64-v8a CACHE STRING "")
75-
elseif(${target} MATCHES armv7)
76-
set(BUILTINS_${target}_CMAKE_ANDROID_ARCH_ABI armeabi-v7a CACHE STRING "")
77-
elseif(${target} MATCHES i686)
78-
set(BUILTINS_${target}_CMAKE_ANDROID_ARCH_ABI x86 CACHE STRING "")
79-
else()
80-
set(BUILTINS_${target}_CMAKE_ANDROID_ARCH_ABI x86_64 CACHE STRING "")
81-
endif()
82-
set(BUILTINS_${target}_CMAKE_ANDROID_NDK $ENV{NDKPATH} CACHE PATH "")
83-
set(BUILTINS_${target}_CMAKE_ANDROID_API 21 CACHE STRING "")
84-
set(BUILTINS_${target}_CMAKE_C_COMPILER_TARGET "${target}21" CACHE STRING "")
85-
set(BUILTINS_${target}_CMAKE_CXX_COMPILER_TARGET "${target}21" CACHE STRING "")
86-
endif()
87-
set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
43+
set(RUNTIMES_${target}_COMPILER_RT_BUILD_XRAY NO CACHE BOOL "")
8844
endforeach()
8945

9046
set(LLVM_TARGETS_TO_BUILD AArch64 ARM WebAssembly X86 CACHE STRING "")
@@ -211,7 +167,6 @@ set(LLVM_DISTRIBUTION_COMPONENTS
211167
libclang
212168
libclang-headers
213169
LTO
214-
builtins
215170
runtimes
216171
${LLVM_TOOLCHAIN_TOOLS}
217172
${CLANG_TOOLS}

cmake/caches/Windows-x86_64.cmake

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,24 @@ set(LLVM_APPEND_VC_REV NO CACHE BOOL "")
2727
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR YES CACHE BOOL "")
2828
set(LLVM_ENABLE_PYTHON YES CACHE BOOL "")
2929

30-
set(default_targets
30+
set(DEFAULT_BUILTIN_TARGETS
3131
x86_64-unknown-windows-msvc
32-
aarch64-unknown-windows-msvc
33-
i686-unknown-windows-msvc)
34-
set(LLVM_RUNTIME_TARGETS ${default_targets} CACHE STRING "")
35-
32+
aarch64-unknown-windows-msvc)
3633
# Build the android builtins if NDK path is provided.
3734
if(NOT "$ENV{NDKPATH}" STREQUAL "")
38-
list(APPEND default_targets
35+
list(APPEND DEFAULT_BUILTIN_TARGETS
3936
aarch64-unknown-linux-android
40-
x86_64-unknown-linux-android
41-
i686-unknown-linux-android
42-
armv7-unknown-linux-androideabi)
37+
x86_64-unknown-linux-android)
4338
endif()
4439

45-
set(LLVM_BUILTIN_TARGETS ${default_targets} CACHE STRING "")
40+
# The builtin targets are used to build the compiler-rt builtins.
41+
set(LLVM_BUILTIN_TARGETS ${DEFAULT_BUILTIN_TARGETS} CACHE STRING "")
42+
43+
# The runtime targets are used to build the compiler-rt profile library.
44+
set(LLVM_RUNTIME_TARGETS
45+
x86_64-unknown-windows-msvc
46+
aarch64-unknown-windows-msvc
47+
CACHE STRING "")
4648

4749
foreach(target ${LLVM_RUNTIME_TARGETS})
4850
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES
@@ -51,15 +53,13 @@ foreach(target ${LLVM_RUNTIME_TARGETS})
5153
set(RUNTIMES_${target}_CMAKE_MT mt CACHE STRING "")
5254
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
5355
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
54-
set(RUNTIMES_${target}_COMPILER_RT_BUILD_BUILTINS YES CACHE BOOL "")
56+
set(RUNTIMES_${target}_COMPILER_RT_BUILD_BUILTINS NO CACHE BOOL "")
5557
set(RUNTIMES_${target}_COMPILER_RT_BUILD_CRT NO CACHE BOOL "")
5658
set(RUNTIMES_${target}_COMPILER_RT_BUILD_LIBFUZZER NO CACHE BOOL "")
5759
set(RUNTIMES_${target}_COMPILER_RT_BUILD_ORC NO CACHE BOOL "")
5860
set(RUNTIMES_${target}_COMPILER_RT_BUILD_PROFILE YES CACHE BOOL "")
59-
set(RUNTIMES_${target}_COMPILER_RT_BUILD_XRAY NO CACHE BOOL "")
60-
# Sanitizers will be configured, but not built. We have separate build
61-
# steps for that, because we need a different shell for each target.
6261
set(RUNTIMES_${target}_COMPILER_RT_BUILD_SANITIZERS NO CACHE BOOL "")
62+
set(RUNTIMES_${target}_COMPILER_RT_BUILD_XRAY NO CACHE BOOL "")
6363
endforeach()
6464

6565
foreach(target ${LLVM_BUILTIN_TARGETS})
@@ -72,10 +72,6 @@ foreach(target ${LLVM_BUILTIN_TARGETS})
7272
set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Android CACHE STRING "")
7373
if(${target} MATCHES aarch64)
7474
set(BUILTINS_${target}_CMAKE_ANDROID_ARCH_ABI arm64-v8a CACHE STRING "")
75-
elseif(${target} MATCHES armv7)
76-
set(BUILTINS_${target}_CMAKE_ANDROID_ARCH_ABI armeabi-v7a CACHE STRING "")
77-
elseif(${target} MATCHES i686)
78-
set(BUILTINS_${target}_CMAKE_ANDROID_ARCH_ABI x86 CACHE STRING "")
7975
else()
8076
set(BUILTINS_${target}_CMAKE_ANDROID_ARCH_ABI x86_64 CACHE STRING "")
8177
endif()

include/swift/AST/ASTBridging.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,14 @@ SWIFT_NAME("getter:BridgedPatternBindingInitializer.asDeclContext(self:)")
536536
BridgedDeclContext BridgedPatternBindingInitializer_asDeclContext(
537537
BridgedPatternBindingInitializer cInit);
538538

539+
SWIFT_NAME("BridgedCustomAttributeInitializer.create(declContext:)")
540+
BridgedCustomAttributeInitializer
541+
BridgedCustomAttributeInitializer_create(BridgedDeclContext cDeclContext);
542+
543+
SWIFT_NAME("getter:BridgedCustomAttributeInitializer.asDeclContext(self:)")
544+
BridgedDeclContext BridgedCustomAttributeInitializer_asDeclContext(
545+
BridgedCustomAttributeInitializer cInit);
546+
539547
SWIFT_NAME("getter:BridgedClosureExpr.asDeclContext(self:)")
540548
BridgedDeclContext
541549
BridgedClosureExpr_asDeclContext(BridgedClosureExpr cClosure);
@@ -613,7 +621,7 @@ SWIFT_NAME(
613621
"BridgedCustomAttr.createParsed(_:atLoc:type:initContext:argumentList:)")
614622
BridgedCustomAttr BridgedCustomAttr_createParsed(
615623
BridgedASTContext cContext, BridgedSourceLoc cAtLoc, BridgedTypeRepr cType,
616-
BridgedNullablePatternBindingInitializer cInitContext,
624+
BridgedNullableCustomAttributeInitializer cInitContext,
617625
BridgedNullableArgumentList cArgumentList);
618626

619627
SWIFT_NAME("BridgedDocumentationAttr.createParsed(_:atLoc:range:metadata:"

include/swift/AST/ASTBridgingWrappers.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ AST_BRIDGING_WRAPPER_NULLABLE(GenericParamList)
8383
AST_BRIDGING_WRAPPER_NULLABLE(TrailingWhereClause)
8484
AST_BRIDGING_WRAPPER_NULLABLE(ParameterList)
8585
AST_BRIDGING_WRAPPER_NULLABLE(PatternBindingInitializer)
86+
AST_BRIDGING_WRAPPER_NULLABLE(CustomAttributeInitializer)
8687
AST_BRIDGING_WRAPPER_NONNULL(TypeAttributes)
8788
AST_BRIDGING_WRAPPER_NONNULL(CustomAttribute)
8889
AST_BRIDGING_WRAPPER_NULLABLE(ArgumentList)

include/swift/AST/Attr.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class AbstractFunctionDecl;
6060
class FuncDecl;
6161
class ClassDecl;
6262
class AccessorDecl;
63+
class CustomAttributeInitializer;
6364
class GenericFunctionType;
6465
class LazyConformanceLoader;
6566
class LazyMemberLoader;
@@ -1861,13 +1862,13 @@ class ClangImporterSynthesizedTypeAttr : public DeclAttribute {
18611862
class CustomAttr final : public DeclAttribute {
18621863
TypeExpr *typeExpr;
18631864
ArgumentList *argList;
1864-
PatternBindingInitializer *initContext;
1865+
CustomAttributeInitializer *initContext;
18651866
Expr *semanticInit = nullptr;
18661867

18671868
mutable unsigned isArgUnsafeBit : 1;
18681869

18691870
CustomAttr(SourceLoc atLoc, SourceRange range, TypeExpr *type,
1870-
PatternBindingInitializer *initContext, ArgumentList *argList,
1871+
CustomAttributeInitializer *initContext, ArgumentList *argList,
18711872
bool implicit);
18721873

18731874
public:
@@ -1878,7 +1879,7 @@ class CustomAttr final : public DeclAttribute {
18781879
}
18791880

18801881
static CustomAttr *create(ASTContext &ctx, SourceLoc atLoc, TypeExpr *type,
1881-
PatternBindingInitializer *initContext,
1882+
CustomAttributeInitializer *initContext,
18821883
ArgumentList *argList, bool implicit = false);
18831884

18841885
TypeExpr *getTypeExpr() const { return typeExpr; }
@@ -1911,7 +1912,7 @@ class CustomAttr final : public DeclAttribute {
19111912
Expr *getSemanticInit() const { return semanticInit; }
19121913
void setSemanticInit(Expr *expr) { semanticInit = expr; }
19131914

1914-
PatternBindingInitializer *getInitContext() const { return initContext; }
1915+
CustomAttributeInitializer *getInitContext() const { return initContext; }
19151916

19161917
static bool classof(const DeclAttribute *DA) {
19171918
return DA->getKind() == DeclAttrKind::Custom;
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//===--- AvailabilityDomain.h - Swift Availability Domains ------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2024 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 defines the AvailabilityDomain class, which represents a domain
14+
// for which availability can be checked.
15+
//
16+
//===----------------------------------------------------------------------===//
17+
18+
#ifndef SWIFT_AST_AVAILABILITY_DOMAIN_H
19+
#define SWIFT_AST_AVAILABILITY_DOMAIN_H
20+
21+
#include "swift/AST/PlatformKind.h"
22+
#include "swift/Basic/LLVM.h"
23+
24+
namespace swift {
25+
26+
/// Represents a dimension of availability (e.g. macOS platform or Swift
27+
/// language mode).
28+
class AvailabilityDomain final {
29+
public:
30+
enum class Kind : uint8_t {
31+
/// The root availability domain. This is used for declarations that are
32+
/// universally unavailable or deprecated, for example.
33+
Universal,
34+
35+
/// Represents availability for a specific operating system platform.
36+
Platform,
37+
38+
/// Represents availability with respect to Swift language mode.
39+
SwiftLanguage,
40+
41+
/// Represents PackageDescription availability.
42+
PackageDescription,
43+
};
44+
45+
private:
46+
Kind kind;
47+
PlatformKind platform;
48+
49+
AvailabilityDomain(Kind kind) : kind(kind), platform(PlatformKind::none) {
50+
assert(kind != Kind::Platform);
51+
};
52+
53+
AvailabilityDomain(PlatformKind platform)
54+
: kind(Kind::Platform), platform(platform) {
55+
assert(platform != PlatformKind::none);
56+
};
57+
58+
public:
59+
static AvailabilityDomain forUniversal() {
60+
return AvailabilityDomain(Kind::Universal);
61+
}
62+
63+
static AvailabilityDomain forPlatform(PlatformKind platformKind) {
64+
return AvailabilityDomain(platformKind);
65+
}
66+
67+
static AvailabilityDomain forSwiftLanguage() {
68+
return AvailabilityDomain(Kind::SwiftLanguage);
69+
}
70+
71+
static AvailabilityDomain forPackageDescription() {
72+
return AvailabilityDomain(Kind::PackageDescription);
73+
}
74+
75+
Kind getKind() const { return kind; }
76+
77+
bool isUniversal() const { return kind == Kind::Universal; }
78+
79+
bool isPlatform() const { return kind == Kind::Platform; }
80+
81+
bool isSwiftLanguage() const { return kind == Kind::SwiftLanguage; }
82+
83+
bool isPackageDescription() const { return kind == Kind::PackageDescription; }
84+
85+
/// Returns the platform kind for this domain if applicable.
86+
PlatformKind getPlatformKind() const {
87+
assert(kind == Kind::Platform);
88+
return platform;
89+
}
90+
91+
/// Returns the string to use in diagnostics to identify the domain. May
92+
/// return an empty string.
93+
llvm::StringRef getNameForDiagnostics() const;
94+
95+
/// Returns the string to use when printing an `@available` attribute.
96+
llvm::StringRef getNameForAttributePrinting() const;
97+
};
98+
99+
} // end namespace swift
100+
101+
#endif

include/swift/AST/Decl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ namespace swift {
6666
class AccessorDecl;
6767
class ApplyExpr;
6868
class AvailabilityRange;
69+
class AvailabilityDomain;
6970
class GenericEnvironment;
7071
class ArchetypeType;
7172
class ASTContext;
@@ -1390,6 +1391,10 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl>, public Swi
13901391
/// and its DeclContext does not.
13911392
bool isOutermostPrivateOrFilePrivateScope() const;
13921393

1394+
/// Returns the availability domain associated with the given `AvailableAttr`
1395+
/// that is attached to this decl.
1396+
AvailabilityDomain getDomainForAvailableAttr(const AvailableAttr *attr) const;
1397+
13931398
/// Returns the active platform-specific `@available` attribute for this decl.
13941399
/// There may be multiple `@available` attributes that are relevant to the
13951400
/// current platform, but the returned one has the highest priority.

include/swift/AST/DeclAttr.def

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,11 @@ DECL_ATTR(lifetime, Lifetime,
513513
OnAccessor | OnConstructor | OnFunc | OnSubscript | LongAttribute | ABIBreakingToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove | AllowMultipleAttributes,
514514
161)
515515

516-
LAST_DECL_ATTR(Lifetime)
516+
SIMPLE_DECL_ATTR(_addressableSelf, AddressableSelf,
517+
OnAccessor | OnConstructor | OnFunc | OnSubscript | ABIBreakingToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove | UserInaccessible,
518+
162)
519+
520+
LAST_DECL_ATTR(AddressableSelf)
517521

518522
#undef DECL_ATTR_ALIAS
519523
#undef CONTEXTUAL_DECL_ATTR_ALIAS

include/swift/AST/DiagnosticsSema.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ ERROR(incorrect_explicit_closure_result_vs_return_type,none,
309309
"declared closure result %0 is incompatible with return type %1",
310310
(Type, Type))
311311

312+
ERROR(addressable_not_enabled,none,
313+
"@_addressable is an experimental feature", ())
314+
ERROR(addressableSelf_not_on_method,none,
315+
"@_addressableSelf cannot be applied to non-member declarations", ())
316+
312317
ERROR(unsupported_closure_attr,none,
313318
"%select{attribute |}0 '%1' is not supported on a closure",
314319
(bool, StringRef))

0 commit comments

Comments
 (0)