Skip to content

Commit eeb0f08

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 6118cd9 + 4db0ac6 commit eeb0f08

File tree

61 files changed

+1178
-847
lines changed

Some content is hidden

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

61 files changed

+1178
-847
lines changed

docs/ARCOptimization.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ this is true. The rule for conversions is that a conversion that preserves RC
232232
identity must have the following properties:
233233

234234
1. Both of its arguments must be non-trivial values with the same ownership
235-
semantics (i.e. unowned, strong, weak). This means that conversions such as:
235+
semantics (i.e. unowned, strong, weak). This means that the following
236+
conversions do not propagate RC identity:
236237

237238
- address_to_pointer
238239
- pointer_to_address

include/swift/AST/AnyFunctionRef.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef SWIFT_AST_ANY_FUNCTION_REF_H
1414
#define SWIFT_AST_ANY_FUNCTION_REF_H
1515

16+
#include "swift/Basic/Compiler.h"
1617
#include "swift/Basic/LLVM.h"
1718
#include "swift/AST/Decl.h"
1819
#include "swift/AST/Expr.h"
@@ -151,7 +152,7 @@ class AnyFunctionRef {
151152
}
152153

153154
// Disable "only for use within the debugger" warning.
154-
#if defined(_MSC_VER)
155+
#if SWIFT_COMPILER_IS_MSVC
155156
#pragma warning(push)
156157
#pragma warning(disable: 4996)
157158
#endif
@@ -176,7 +177,7 @@ class AnyFunctionRef {
176177
llvm_unreachable("unexpected AnyFunctionRef representation");
177178
}
178179
};
179-
#if defined(_MSC_VER)
180+
#if SWIFT_COMPILER_IS_MSVC
180181
#pragma warning(pop)
181182
#endif
182183

include/swift/AST/Decl.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "swift/AST/LazyResolver.h"
2929
#include "swift/AST/TypeAlignments.h"
3030
#include "swift/AST/Witness.h"
31+
#include "swift/Basic/Compiler.h"
3132
#include "swift/Basic/OptionalEnum.h"
3233
#include "swift/Basic/Range.h"
3334
#include "llvm/ADT/DenseMap.h"
@@ -864,11 +865,7 @@ class alignas(1 << DeclAlignInBits) Decl {
864865

865866
// Make vanilla new/delete illegal for Decls.
866867
void *operator new(size_t Bytes) = delete;
867-
868-
// Work around MSVC error: attempting to reference a deleted function.
869-
#if !defined(_MSC_VER) || defined(__clang__)
870-
void operator delete(void *Data) = delete;
871-
#endif
868+
void operator delete(void *Data) SWIFT_DELETE_OPERATOR_DELETED;
872869

873870
// Only allow allocation of Decls using the allocator in ASTContext
874871
// or by doing a placement new.

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3318,7 +3318,7 @@ WARNING(discardable_result_on_void_never_function, none,
33183318

33193319
ERROR(versioned_attr_with_explicit_accessibility,
33203320
none, "'@_versioned' attribute can only be applied to internal "
3321-
"declarations, but %0 is %select{private|fileprivate|%error|public}1",
3321+
"declarations, but %0 is %select{private|fileprivate|%error|public|open}1",
33223322
(Identifier, Accessibility))
33233323

33243324
#define FRAGILE_FUNC_KIND \
@@ -3332,7 +3332,7 @@ ERROR(local_type_in_inlineable_function,
33323332
(DeclName, unsigned))
33333333

33343334
ERROR(resilience_decl_unavailable,
3335-
none, "%0 %1 is %select{private|fileprivate|internal|%error}2 and "
3335+
none, "%0 %1 is %select{private|fileprivate|internal|%error|%error}2 and "
33363336
"cannot be referenced from " FRAGILE_FUNC_KIND "3",
33373337
(DescriptiveDeclKind, DeclName, Accessibility, unsigned))
33383338

include/swift/AST/GenericEnvironment.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#include "swift/AST/SubstitutionMap.h"
2121
#include "swift/AST/GenericParamKey.h"
2222
#include "swift/AST/GenericSignature.h"
23+
#include "swift/Basic/Compiler.h"
2324
#include "llvm/ADT/ArrayRef.h"
25+
#include "llvm/Support/ErrorHandling.h"
2426
#include "llvm/Support/TrailingObjects.h"
2527
#include <utility>
2628

@@ -183,9 +185,7 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
183185

184186
/// Make vanilla new/delete illegal.
185187
void *operator new(size_t Bytes) = delete;
186-
#if !defined(_MSC_VER) || defined(__clang__)
187-
void operator delete(void *Data) = delete;
188-
#endif
188+
void operator delete(void *Data) SWIFT_DELETE_OPERATOR_DELETED;
189189

190190
/// Only allow placement new.
191191
void *operator new(size_t Bytes, void *Mem) {

include/swift/AST/Module.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "swift/AST/LookupKinds.h"
2424
#include "swift/AST/RawComment.h"
2525
#include "swift/AST/Type.h"
26+
#include "swift/Basic/Compiler.h"
2627
#include "swift/Basic/OptionSet.h"
2728
#include "swift/Basic/SourceLoc.h"
2829
#include "swift/Basic/STLExtras.h"
@@ -506,11 +507,7 @@ class ModuleDecl : public TypeDecl, public DeclContext {
506507
private:
507508
// Make placement new and vanilla new/delete illegal for Modules.
508509
void *operator new(size_t Bytes) throw() = delete;
509-
510-
// Work around MSVC error: attempting to reference a deleted function.
511-
#if !defined(_MSC_VER) && !defined(__clang__)
512-
void operator delete(void *Data) throw() = delete;
513-
#endif
510+
void operator delete(void *Data) throw() SWIFT_DELETE_OPERATOR_DELETED;
514511
void *operator new(size_t Bytes, void *Mem) throw() = delete;
515512
public:
516513
// Only allow allocation of Modules using the allocator in ASTContext

include/swift/AST/ProtocolConformance.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "swift/AST/Types.h"
2525
#include "swift/AST/TypeAlignments.h"
2626
#include "swift/AST/Witness.h"
27+
#include "swift/Basic/Compiler.h"
2728
#include "llvm/ADT/ArrayRef.h"
2829
#include "llvm/ADT/DenseMap.h"
2930
#include "llvm/ADT/FoldingSet.h"
@@ -265,11 +266,7 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance {
265266

266267
// Make vanilla new/delete illegal for protocol conformances.
267268
void *operator new(size_t bytes) = delete;
268-
269-
// Work around MSVC error: attempting to reference a deleted function.
270-
#if !defined(_MSC_VER) || defined(__clang__)
271-
void operator delete(void *data) = delete;
272-
#endif
269+
void operator delete(void *data) SWIFT_DELETE_OPERATOR_DELETED;
273270

274271
// Only allow allocation of protocol conformances using the allocator in
275272
// ASTContext or by doing a placement new.

include/swift/AST/TypeRepr.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ enum class TypeReprKind : uint8_t {
4242

4343
/// \brief Representation of a type as written in source.
4444
class alignas(8) TypeRepr {
45-
// Fix MSVC error: attempting to reference a deleted function.
46-
#if !defined(_MSC_VER) || defined(__clang__)
4745
TypeRepr(const TypeRepr&) = delete;
48-
#endif
4946
void operator=(const TypeRepr&) = delete;
5047

5148
class TypeReprBitfields {

include/swift/Basic/Compiler.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===--- Compiler.h - Compiler specific definitions -------------*- 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+
#ifndef SWIFT_BASIC_COMPILER_H
14+
#define SWIFT_BASIC_COMPILER_H
15+
16+
#if defined(_MSC_VER) && !defined(__clang__)
17+
#define SWIFT_COMPILER_IS_MSVC 1
18+
#else
19+
#define SWIFT_COMPILER_IS_MSVC 0
20+
#endif
21+
22+
#if SWIFT_COMPILER_IS_MSVC
23+
// Work around MSVC bug: attempting to reference a deleted function
24+
// https://connect.microsoft.com/VisualStudio/feedback/details/3116505
25+
#define SWIFT_DELETE_OPERATOR_DELETED \
26+
{ llvm_unreachable("Delete operator should not be called."); }
27+
#else
28+
#define SWIFT_DELETE_OPERATOR_DELETED = delete;
29+
#endif
30+
31+
#endif // SWIFT_BASIC_COMPILER_H

include/swift/Basic/EncodedSequence.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#ifndef SWIFT_BASIC_ENCODEDSEQUENCE_H
2222
#define SWIFT_BASIC_ENCODEDSEQUENCE_H
2323

24+
#include "swift/Basic/Compiler.h"
2425
#include "swift/Basic/LLVM.h"
2526
#include "swift/Basic/PrefixMap.h"
2627
#include "llvm/ADT/ArrayRef.h"
@@ -339,7 +340,7 @@ class EncodedSequence : public EncodedSequenceBase {
339340
template <class ValueType> class Map {
340341
// Hack: MSVC isn't able to resolve the InlineKeyCapacity part of the
341342
// template of PrefixMap, so we have to split it up and pass it manually.
342-
#if defined(_MSC_VER) && !defined(__clang__)
343+
#if SWIFT_COMPILER_IS_MSVC
343344
static const size_t Size = (sizeof(void*) - 1) / sizeof(Chunk);
344345
static const size_t ActualSize = max<size_t>(Size, 1);
345346

include/swift/Basic/type_traits.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define SWIFT_BASIC_TYPETRAITS_H
1515

1616
#include <type_traits>
17+
#include "swift/Basic/Compiler.h"
1718

1819
#ifndef __has_feature
1920
#define SWIFT_DEFINED_HAS_FEATURE
@@ -29,8 +30,8 @@ namespace swift {
2930
/// is not intended to be specialized.
3031
template<typename T>
3132
struct IsTriviallyCopyable {
32-
#if _LIBCPP_VERSION || (defined(_MSC_VER) && !defined(__clang__))
33-
// libc++ implements it.
33+
#if _LIBCPP_VERSION || SWIFT_COMPILER_IS_MSVC
34+
// libc++ and MSVC implement is_trivially_copyable.
3435
static const bool value = std::is_trivially_copyable<T>::value;
3536
#elif __has_feature(is_trivially_copyable)
3637
static const bool value = __is_trivially_copyable(T);
@@ -41,8 +42,8 @@ struct IsTriviallyCopyable {
4142

4243
template<typename T>
4344
struct IsTriviallyConstructible {
44-
#if _LIBCPP_VERSION || (defined(_MSC_VER) && !defined(__clang__))
45-
// libc++ implements it.
45+
#if _LIBCPP_VERSION || SWIFT_COMPILER_IS_MSVC
46+
// libc++ and MSVC implement is_trivially_constructible.
4647
static const bool value = std::is_trivially_constructible<T>::value;
4748
#elif __has_feature(has_trivial_constructor)
4849
static const bool value = __has_trivial_constructor(T);
@@ -53,8 +54,8 @@ struct IsTriviallyConstructible {
5354

5455
template<typename T>
5556
struct IsTriviallyDestructible {
56-
#if _LIBCPP_VERSION || (defined(_MSC_VER) && !defined(__clang__))
57-
// libc++ implements it.
57+
#if _LIBCPP_VERSION || SWIFT_COMPILER_IS_MSVC
58+
// libc++ and MSVC implement is_trivially_destructible.
5859
static const bool value = std::is_trivially_destructible<T>::value;
5960
#elif __has_feature(has_trivial_destructor)
6061
static const bool value = __has_trivial_destructor(T);

include/swift/SIL/SILAllocated.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#define SWIFT_SIL_SILALLOCATED_H
1515

1616
#include "swift/Basic/LLVM.h"
17+
#include "swift/Basic/Compiler.h"
18+
#include "llvm/Support/ErrorHandling.h"
1719
#include <stddef.h>
1820

1921
namespace swift {
@@ -28,11 +30,8 @@ class SILAllocated {
2830
void *operator new(size_t) = delete;
2931
void *operator new[](size_t) = delete;
3032

31-
// Work around MSVC error: attempting to reference a deleted function.
32-
#if !defined(_MSC_VER) || defined(__clang__)
3333
/// Disable non-placement delete.
34-
void operator delete(void *) = delete;
35-
#endif
34+
void operator delete(void *) SWIFT_DELETE_OPERATOR_DELETED;
3635
void operator delete[](void *) = delete;
3736

3837
/// Custom version of 'new' that uses the SILModule's BumpPtrAllocator with

include/swift/SIL/SILArgument.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef SWIFT_SIL_SILARGUMENT_H
1414
#define SWIFT_SIL_SILARGUMENT_H
1515

16+
#include "swift/Basic/Compiler.h"
1617
#include "swift/SIL/SILArgumentConvention.h"
1718
#include "swift/SIL/SILFunction.h"
1819
#include "swift/SIL/SILValue.h"
@@ -36,11 +37,7 @@ SILFunctionType::getSILArgumentConvention(unsigned index) const {
3637

3738
class SILArgument : public ValueBase {
3839
void operator=(const SILArgument &) = delete;
39-
40-
// Work around MSVC error: attempting to reference a deleted function.
41-
#if !defined(_MSC_VER) || defined(__clang__)
42-
void operator delete(void *Ptr, size_t) = delete;
43-
#endif
40+
void operator delete(void *Ptr, size_t) SWIFT_DELETE_OPERATOR_DELETED
4441

4542
SILBasicBlock *ParentBB;
4643
const ValueDecl *Decl;

include/swift/SIL/SILBasicBlock.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef SWIFT_SIL_BASICBLOCK_H
1818
#define SWIFT_SIL_BASICBLOCK_H
1919

20+
#include "swift/Basic/Compiler.h"
2021
#include "swift/Basic/Range.h"
2122
#include "swift/Basic/TransformArrayRef.h"
2223
#include "swift/SIL/SILInstruction.h"
@@ -53,10 +54,7 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
5354
SILBasicBlock() : Parent(nullptr) {}
5455
void operator=(const SILBasicBlock &) = delete;
5556

56-
// Work around MSVC error: attempting to reference a deleted function.
57-
#if !defined(_MSC_VER) || defined(__clang__)
58-
void operator delete(void *Ptr, size_t) = delete;
59-
#endif
57+
void operator delete(void *Ptr, size_t) SWIFT_DELETE_OPERATOR_DELETED
6058

6159
SILBasicBlock(SILFunction *F, SILBasicBlock *afterBB = nullptr);
6260

include/swift/SIL/SILInstruction.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "swift/AST/Builtins.h"
2121
#include "swift/AST/ProtocolConformanceRef.h"
22+
#include "swift/Basic/Compiler.h"
2223
#include "swift/SIL/Consumption.h"
2324
#include "swift/SIL/SILAllocated.h"
2425
#include "swift/SIL/SILArgumentConvention.h"
@@ -80,11 +81,7 @@ class SILInstruction : public ValueBase,public llvm::ilist_node<SILInstruction>{
8081

8182
SILInstruction() = delete;
8283
void operator=(const SILInstruction &) = delete;
83-
84-
// Work around MSVC error: attempting to reference a deleted function.
85-
#if !defined(_MSC_VER) || defined(__clang__)
86-
void operator delete(void *Ptr, size_t) = delete;
87-
#endif
84+
void operator delete(void *Ptr, size_t) SWIFT_DELETE_OPERATOR_DELETED
8885

8986
/// Check any special state of instructions that are not represented in the
9087
/// instructions operands/type.

include/swift/SIL/SILOpenedArchetypesTracker.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef SWIFT_SIL_SILOPENEDARCHETYPESTRACKER_H
1414
#define SWIFT_SIL_SILOPENEDARCHETYPESTRACKER_H
1515

16+
#include "swift/Basic/Compiler.h"
1617
#include "swift/SIL/Notifications.h"
1718
#include "swift/SIL/SILModule.h"
1819
#include "swift/SIL/SILFunction.h"
@@ -21,7 +22,8 @@
2122
namespace swift {
2223

2324
// Disable MSVC warning: multiple copy constructors specified.
24-
#if defined(_MSC_VER)
25+
// TODO: silence this warning.
26+
#if SWIFT_COMPILER_IS_MSVC
2527
#pragma warning(push)
2628
#pragma warning(disable: 4521)
2729
#endif
@@ -134,7 +136,7 @@ class SILOpenedArchetypesTracker : public DeleteNotificationHandler {
134136
OpenedArchetypeDefsMap LocalOpenedArchetypeDefs;
135137
};
136138

137-
#if defined(_MSC_VER)
139+
#if SWIFT_COMPILER_IS_MSVC
138140
#pragma warning(pop)
139141
#endif
140142

include/swift/SIL/SILUndef.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@
1313
#ifndef SWIFT_SIL_UNDEF_H
1414
#define SWIFT_SIL_UNDEF_H
1515

16+
#include "swift/Basic/Compiler.h"
1617
#include "swift/SIL/SILValue.h"
1718

1819
namespace swift {
1920
class SILModule;
2021

2122
class SILUndef : public ValueBase {
2223
void operator=(const SILArgument &) = delete;
23-
24-
// Work around MSVC error: attempting to reference a deleted function.
25-
#if !defined(_MSC_VER) || defined(__clang__)
26-
void operator delete(void *Ptr, size_t) = delete;
27-
#endif
24+
void operator delete(void *Ptr, size_t) SWIFT_DELETE_OPERATOR_DELETED
2825

2926
SILUndef(SILType Ty) : ValueBase(ValueKind::SILUndef, Ty) {}
3027
public:

lib/AST/ASTContext.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "swift/AST/RawComment.h"
3232
#include "swift/AST/SILLayout.h"
3333
#include "swift/AST/TypeCheckerDebugConsumer.h"
34+
#include "swift/Basic/Compiler.h"
3435
#include "swift/Basic/Fallthrough.h"
3536
#include "swift/Basic/SourceManager.h"
3637
#include "swift/Basic/StringExtras.h"
@@ -277,12 +278,12 @@ struct ASTContext::Implementation {
277278
conformance.~SpecializedProtocolConformance();
278279
// Work around MSVC warning: local variable is initialized but
279280
// not referenced.
280-
#if defined(_MSC_VER)
281+
#if SWIFT_COMPILER_IS_MSVC
281282
#pragma warning (disable: 4189)
282283
#endif
283284
for (auto &conformance : InheritedConformances)
284285
conformance.~InheritedProtocolConformance();
285-
#if defined(_MSC_VER)
286+
#if SWIFT_COMPILER_IS_MSVC
286287
#pragma warning (default: 4189)
287288
#endif
288289

0 commit comments

Comments
 (0)