Skip to content

Commit 1fb165a

Browse files
committed
Merge branch 'master' into rename-conflicting-classes-and-methods
1 parent 49c3547 commit 1fb165a

File tree

112 files changed

+7624
-6009
lines changed

Some content is hidden

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

112 files changed

+7624
-6009
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,10 @@ endif()
775775
# Should we cross-compile the standard library for Windows?
776776
is_sdk_requested(WINDOWS swift_build_windows)
777777
if(swift_build_windows AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
778-
configure_sdk_windows(WINDOWS "Windows" "msvc" "aarch64;armv7;i686;x86_64")
778+
if("${SWIFT_SDK_WINDOWS_ARCHITECTURES}" STREQUAL "")
779+
set(SWIFT_SDK_WINDOWS_ARCHITECTURES aarch64;armv7;i686;x86_64)
780+
endif()
781+
configure_sdk_windows(WINDOWS "Windows" "msvc" "${SWIFT_SDK_WINDOWS_ARCHITECTURES}")
779782
endif()
780783

781784
if("${SWIFT_SDKS}" STREQUAL "")

cmake/modules/AddSwift.cmake

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,11 @@ function(_add_variant_c_compile_link_flags)
132132
endif()
133133

134134
if("${CFLAGS_SDK}" STREQUAL "ANDROID")
135-
list(APPEND result
136-
"--sysroot=${SWIFT_SDK_ANDROID_ARCH_${CFLAGS_ARCH}_PATH}"
137-
# Use the linker included in the Android NDK.
138-
"-B" "${SWIFT_SDK_ANDROID_ARCH_${CFLAGS_ARCH}_NDK_PREBUILT_PATH}/${SWIFT_SDK_ANDROID_ARCH_${CFLAGS_ARCH}_NDK_TRIPLE}/bin/")
135+
# lld can handle targeting the android build. However, if lld is not
136+
# enabled, then fallback to the linker included in the android NDK.
137+
if(NOT SWIFT_ENABLE_LLD_LINKER)
138+
list(APPEND result "-B" "${SWIFT_SDK_ANDROID_ARCH_${CFLAGS_ARCH}_NDK_PREBUILT_PATH}/${SWIFT_SDK_ANDROID_ARCH_${CFLAGS_ARCH}_NDK_TRIPLE}/bin")
139+
endif()
139140
endif()
140141

141142
if(IS_DARWIN)
@@ -227,8 +228,8 @@ function(_add_variant_c_compile_flags)
227228
# -D_MD or D_MDd either, as CMake does this automatically.
228229
if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
229230
list(APPEND result -Xclang;--dependent-lib=oldnames)
230-
# TODO(compnerd) handle /MT, /MTd, /MD, /MDd
231-
if("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
231+
# TODO(compnerd) handle /MT, /MTd
232+
if("${CFLAGS_BUILD_TYPE}" STREQUAL "Debug")
232233
list(APPEND result "-D_MDd")
233234
list(APPEND result -Xclang;--dependent-lib=msvcrtd)
234235
else()

docs/ABI/Mangling.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Globals
6464
global ::= context 'MXE' // extension descriptor
6565
global ::= context 'MXX' // anonymous context descriptor
6666
global ::= context identifier 'MXY' // anonymous context descriptor
67-
global ::= type assoc_type_path 'MXA' // generic parameter ref
67+
global ::= type assoc-type-list 'MXA' // generic parameter ref
6868
global ::= protocol 'Mp' // protocol descriptor
6969

7070
global ::= nominal-type 'Mo' // class metadata immediate member base offset
@@ -91,15 +91,13 @@ Globals
9191
global ::= type protocol-conformance 'WL' // lazy protocol witness table cache variable
9292

9393
global ::= protocol-conformance identifier 'Wt' // associated type metadata accessor
94-
global ::= protocol-conformance assoc_type_path nominal-type 'WT' // associated type witness table accessor
94+
global ::= protocol-conformance assoc-type-list nominal-type 'WT' // associated type witness table accessor
9595
global ::= type protocol-conformance 'Wl' // lazy protocol witness table accessor
9696

9797
global ::= type 'WV' // value witness table
9898
global ::= entity 'Wvd' // field offset
9999
global ::= entity 'WC' // resilient enum tag index
100100

101-
assoc_type_path ::= identifier '_' identifier*
102-
103101
A direct symbol resolves directly to the address of an object. An
104102
indirect symbol resolves to the address of a pointer to the object.
105103
They are distinct manglings to make a certain class of bugs

docs/WindowsBuild.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,12 @@ pushd "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64"
233233
cmake -G "Ninja" "%swift_source_dir%/swift"^
234234
-DCMAKE_BUILD_TYPE=Debug^
235235
-DSWIFT_PATH_TO_CMARK_SOURCE="%swift_source_dir%/cmark"^
236-
-DSWIFT_PATH_TO_CMARK_BUILD="%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/cmark-windows-amd64"^
237-
-DSWIFT_CMARK_LIBRARY_DIR="%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/cmark-windows-amd64/src"^
236+
-DSWIFT_PATH_TO_CMARK_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64"^
237+
-DSWIFT_CMARK_LIBRARY_DIR="%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64/src"^
238238
-DSWIFT_PATH_TO_LLVM_SOURCE="%swift_source_dir%/llvm"^
239-
-DSWIFT_PATH_TO_LLVM_BUILD="%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/llvm-windows-amd64"^
239+
-DSWIFT_PATH_TO_LLVM_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"^
240240
-DSWIFT_PATH_TO_CLANG_SOURCE="%swift_source_dir%/llvm/tools/clang"^
241-
-DSWIFT_PATH_TO_CLANG_BUILD="%swift_source_dir%/build/Ninja-RelWithDebInfoAssert/llvm-windows-amd64"^
241+
-DSWIFT_PATH_TO_CLANG_BUILD="%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"^
242242
-DICU_UC_INCLUDE_DIRS="%swift_source_dir%/icu/include"^
243243
-DICU_UC_LIBRARY_DIRS="%swift_source_dir%/icu/lib64"^
244244
-DICU_I18N_INCLUDE_DIRS="%swift_source_dir%/icu/include"^

include/swift/AST/Decl.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3116,18 +3116,26 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
31163116
/// called to make it immediately visible.
31173117
void makeMemberVisible(ValueDecl *member);
31183118

3119+
/// Special-behaviour flags passed to lookupDirect()
3120+
enum class LookupDirectFlags {
3121+
/// Whether to avoid loading any new extension.
3122+
/// Used by the module loader to break recursion.
3123+
IgnoreNewExtensions = 1 << 0,
3124+
/// Whether to include @_implements members.
3125+
/// Used by conformance-checking to find special @_implements members.
3126+
IncludeAttrImplements = 1 << 1,
3127+
};
3128+
31193129
/// Find all of the declarations with the given name within this nominal type
31203130
/// and its extensions.
31213131
///
31223132
/// This routine does not look into superclasses, nor does it consider
31233133
/// protocols to which the nominal type conforms. Furthermore, the resulting
31243134
/// set of declarations has not been filtered for visibility, nor have
31253135
/// overridden declarations been removed.
3126-
///
3127-
/// \param ignoreNewExtensions Whether to avoid loading any new extension.
3128-
/// Used by the module loader to break recursion.
31293136
TinyPtrVector<ValueDecl *> lookupDirect(DeclName name,
3130-
bool ignoreNewExtensions = false);
3137+
OptionSet<LookupDirectFlags> flags =
3138+
OptionSet<LookupDirectFlags>());
31313139

31323140
/// Collect the set of protocols to which this type should implicitly
31333141
/// conform, such as AnyObject (for classes).

include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ ERROR(raw_type_change,none,"%0(%1) is now %2 representable", (StringRef, StringR
4242

4343
ERROR(removed_decl,none,"%0 has been removed%select{| (deprecated)}1", (StringRef, bool))
4444

45+
ERROR(removed_setter,none,"%0 has removed its setter", (StringRef))
46+
4547
ERROR(moved_decl,none,"%0 has been moved to %1", (StringRef, StringRef))
4648

4749
ERROR(renamed_decl,none,"%0 has been renamed to %1", (StringRef, StringRef))
@@ -62,6 +64,10 @@ ERROR(conformance_removed,none,"%0 has removed %select{conformance to|inherited
6264

6365
ERROR(conformance_added,none,"%0 has added inherited protocol %1", (StringRef, StringRef))
6466

67+
ERROR(default_associated_type_removed,none,"%0 has removed default type %1", (StringRef, StringRef))
68+
69+
ERROR(protocol_req_added,none,"%0 has been added as a protocol requirement", (StringRef))
70+
6571
#ifndef DIAG_NO_UNDEF
6672
# if defined(DIAG)
6773
# undef DIAG

include/swift/AST/LookupKinds.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ enum NLOptions : unsigned {
5757
/// This lookup should only return type declarations.
5858
NL_OnlyTypes = 0x80,
5959

60+
/// Include synonyms declared with @_implements()
61+
NL_IncludeAttributeImplements = 0x100,
62+
6063
/// This lookup is known to not add any additional dependencies to the
6164
/// primary source file.
6265
///

include/swift/AST/Types.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4088,7 +4088,8 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
40884088
void Profile(llvm::FoldingSetNodeID &ID) {
40894089
Profile(ID, getGenericSignature(), getExtInfo(), getCoroutineKind(),
40904090
getCalleeConvention(), getParameters(), getYields(),
4091-
getResults(), getOptionalErrorResult());
4091+
getResults(), getOptionalErrorResult(),
4092+
getWitnessMethodConformanceOrNone());
40924093
}
40934094
static void Profile(llvm::FoldingSetNodeID &ID,
40944095
GenericSignature *genericSig,
@@ -4098,7 +4099,8 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
40984099
ArrayRef<SILParameterInfo> params,
40994100
ArrayRef<SILYieldInfo> yields,
41004101
ArrayRef<SILResultInfo> results,
4101-
Optional<SILResultInfo> errorResult);
4102+
Optional<SILResultInfo> errorResult,
4103+
Optional<ProtocolConformanceRef> conformance);
41024104

41034105
// Implement isa/cast/dyncast/etc.
41044106
static bool classof(const TypeBase *T) {

include/swift/IDE/DigesterEnums.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ NODE_KIND(DeclGetter, Getter)
4545
NODE_KIND(DeclSetter, Setter)
4646
NODE_KIND(DeclVar, Var)
4747
NODE_KIND(DeclTypeAlias, TypeAlias)
48+
NODE_KIND(DeclAssociatedType, AssociatedType)
49+
NODE_KIND(DeclSubscript, Subscript)
4850

4951
NODE_ANNOTATION(Added)
5052
NODE_ANNOTATION(Removed)
@@ -100,6 +102,7 @@ KEY(throwing)
100102
KEY(mutating)
101103
KEY(static)
102104
KEY(deprecated)
105+
KEY(protocolReq)
103106
KEY(implicit)
104107
KEY(typeAttributes)
105108
KEY(declAttributes)
@@ -111,6 +114,7 @@ KEY(conformingProtocols)
111114
KEY(enumRawTypeName)
112115
KEY(genericSig)
113116
KEY(fixedbinaryorder)
117+
KEY(hasSetter)
114118

115119
KNOWN_TYPE(Optional)
116120
KNOWN_TYPE(ImplicitlyUnwrappedOptional)

include/swift/Runtime/Atomic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// is formally UB by C++11 language rules, we should be OK because neither
2323
// the processor model nor the optimizer can realistically reorder our uses
2424
// of 'consume'.
25-
#if __arm64__ || __arm__
25+
#if defined(__arm__) || defined(_M_ARM) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
2626
# define SWIFT_MEMORY_ORDER_CONSUME (std::memory_order_relaxed)
2727
#else
2828
# define SWIFT_MEMORY_ORDER_CONSUME (std::memory_order_consume)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//===--- SILArgumentArrayRef.h --------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2018 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+
/// \file
14+
///
15+
/// A header file to ensure that we do not create a dependency cycle in between
16+
/// SILBasicBlock.h and SILInstruction.h.
17+
///
18+
//===----------------------------------------------------------------------===//
19+
20+
#ifndef SWIFT_SIL_SILARGUMENTARRAYREF_H
21+
#define SWIFT_SIL_SILARGUMENTARRAYREF_H
22+
23+
#include "swift/Basic/LLVM.h"
24+
#include "swift/Basic/STLExtras.h"
25+
#include "swift/Basic/TransformArrayRef.h"
26+
27+
namespace swift {
28+
29+
class SILArgument;
30+
class SILPHIArgument;
31+
class SILFunctionArgument;
32+
33+
using PHIArgumentArrayRef =
34+
TransformArrayRef<function_ref<SILPHIArgument *(SILArgument *)>>;
35+
36+
using FunctionArgumentArrayRef =
37+
TransformArrayRef<function_ref<SILFunctionArgument *(SILArgument *)>>;
38+
39+
} // namespace swift
40+
41+
#endif

include/swift/SIL/SILBasicBlock.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/Basic/Compiler.h"
2121
#include "swift/Basic/Range.h"
2222
#include "swift/Basic/TransformArrayRef.h"
23+
#include "swift/SIL/SILArgumentArrayRef.h"
2324
#include "swift/SIL/SILInstruction.h"
2425

2526
namespace swift {
@@ -192,12 +193,15 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
192193
}
193194

194195
ArrayRef<SILArgument *> getArguments() const { return ArgumentList; }
195-
using PHIArgumentArrayRefTy =
196-
TransformArrayRef<SILPHIArgument *(*)(SILArgument *)>;
197-
PHIArgumentArrayRefTy getPHIArguments() const;
198-
using FunctionArgumentArrayRefTy =
199-
TransformArrayRef<SILFunctionArgument *(*)(SILArgument *)>;
200-
FunctionArgumentArrayRefTy getFunctionArguments() const;
196+
197+
/// Returns a transform array ref that performs llvm::cast<SILPHIArgument> on
198+
/// each argument and then returns the downcasted value.
199+
PHIArgumentArrayRef getPHIArguments() const;
200+
201+
/// Returns a transform array ref that performs
202+
/// llvm::cast<SILFunctionArgument> on each argument and then returns the
203+
/// downcasted value.
204+
FunctionArgumentArrayRef getFunctionArguments() const;
201205

202206
unsigned getNumArguments() const { return ArgumentList.size(); }
203207
const SILArgument *getArgument(unsigned i) const { return ArgumentList[i]; }

include/swift/SIL/SILInstruction.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "swift/Basic/Range.h"
3030
#include "swift/SIL/Consumption.h"
3131
#include "swift/SIL/SILAllocated.h"
32+
#include "swift/SIL/SILArgumentArrayRef.h"
3233
#include "swift/SIL/SILDeclRef.h"
3334
#include "swift/SIL/SILFunctionConventions.h"
3435
#include "swift/SIL/SILLocation.h"
@@ -6605,6 +6606,14 @@ class TermInst : public NonValueInstruction {
66056606
});
66066607
}
66076608

6609+
using SuccessorBlockArgumentsListTy =
6610+
TransformRange<ConstSuccessorListTy,
6611+
function_ref<PHIArgumentArrayRef(const SILSuccessor &)>>;
6612+
6613+
/// Return the range of Argument arrays for each successor of this
6614+
/// block.
6615+
SuccessorBlockArgumentsListTy getSuccessorBlockArguments() const;
6616+
66086617
using SuccessorBlockListTy =
66096618
TransformRange<SuccessorListTy,
66106619
SILBasicBlock *(*)(const SILSuccessor &)>;

include/swift/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const uint16_t VERSION_MAJOR = 0;
5555
/// describe what change you made. The content of this comment isn't important;
5656
/// it just ensures a conflict if two people change the module format.
5757
/// Don't worry about adhering to the 80-column limit for this line.
58-
const uint16_t VERSION_MINOR = 448; // Last change: assoc type default is interface type
58+
const uint16_t VERSION_MINOR = 449; // Last change: serialize @_implements names
5959

6060
using DeclIDField = BCFixed<31>;
6161

lib/AST/ASTContext.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3891,7 +3891,8 @@ void SILFunctionType::Profile(llvm::FoldingSetNodeID &id,
38913891
ArrayRef<SILParameterInfo> params,
38923892
ArrayRef<SILYieldInfo> yields,
38933893
ArrayRef<SILResultInfo> results,
3894-
Optional<SILResultInfo> errorResult) {
3894+
Optional<SILResultInfo> errorResult,
3895+
Optional<ProtocolConformanceRef> conformance) {
38953896
id.AddPointer(genericParams);
38963897
id.AddInteger(info.getFuncAttrKey());
38973898
id.AddInteger(unsigned(coroutineKind));
@@ -3909,6 +3910,8 @@ void SILFunctionType::Profile(llvm::FoldingSetNodeID &id,
39093910
// Just allow the profile length to implicitly distinguish the
39103911
// presence of an error result.
39113912
if (errorResult) errorResult->profile(id);
3913+
if (conformance)
3914+
id.AddPointer(conformance->getRequirement());
39123915
}
39133916

39143917
SILFunctionType::SILFunctionType(GenericSignature *genericSig, ExtInfo ext,
@@ -4045,8 +4048,9 @@ CanSILFunctionType SILFunctionType::get(GenericSignature *genericSig,
40454048
assert(!ext.isPseudogeneric() || genericSig);
40464049

40474050
llvm::FoldingSetNodeID id;
4048-
SILFunctionType::Profile(id, genericSig, ext, coroutineKind, callee,
4049-
params, yields, normalResults, errorResult);
4051+
SILFunctionType::Profile(id, genericSig, ext, coroutineKind, callee, params,
4052+
yields, normalResults, errorResult,
4053+
witnessMethodConformance);
40504054

40514055
// Do we already have this generic function type?
40524056
void *insertPos;

lib/AST/Decl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3252,8 +3252,10 @@ void ClassDecl::addImplicitDestructor() {
32523252

32533253
bool ClassDecl::hasMissingDesignatedInitializers() const {
32543254
auto *mutableThis = const_cast<ClassDecl *>(this);
3255+
auto flags = OptionSet<LookupDirectFlags>();
3256+
flags |= LookupDirectFlags::IgnoreNewExtensions;
32553257
(void)mutableThis->lookupDirect(DeclBaseName::createConstructor(),
3256-
/*ignoreNewExtensions*/true);
3258+
flags);
32573259
return Bits.ClassDecl.HasMissingDesignatedInitializers;
32583260
}
32593261

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,8 +2124,9 @@ TypeDecl *EquivalenceClass::lookupNestedType(
21242124
ProtocolDecl *proto = conforms.first;
21252125

21262126
// Look for an associated type and/or concrete type with this name.
2127-
for (auto member : proto->lookupDirect(name,
2128-
/*ignoreNewExtensions=*/true)) {
2127+
auto flags = OptionSet<NominalTypeDecl::LookupDirectFlags>();
2128+
flags |= NominalTypeDecl::LookupDirectFlags::IgnoreNewExtensions;
2129+
for (auto member : proto->lookupDirect(name, flags)) {
21292130
// If this is an associated type, record whether it is the best
21302131
// associated type we've seen thus far.
21312132
if (auto assocType = dyn_cast<AssociatedTypeDecl>(member)) {

0 commit comments

Comments
 (0)