Skip to content

Commit a2d973d

Browse files
committed
Merge branch 'master' into remotemirror-hide-reflection-sections
2 parents acb4142 + d6da4f7 commit a2d973d

File tree

140 files changed

+3381
-1317
lines changed

Some content is hidden

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

140 files changed

+3381
-1317
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CHANGELOG
66

77
| Contents |
88
| :--------------------- |
9-
| [Swift 5.0](#swift-50) |
9+
| [Swift 4.2](#swift-42) |
1010
| [Swift 4.1](#swift-41) |
1111
| [Swift 4.0](#swift-40) |
1212
| [Swift 3.1](#swift-31) |
@@ -20,7 +20,7 @@ CHANGELOG
2020

2121
</details>
2222

23-
Swift 5.0
23+
Swift 4.2
2424
---------
2525

2626
* Public classes may now have internal `required` initializers. The rule for

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
128128
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
129129
# can be reused when a new version of Swift comes out (assuming the user hasn't
130130
# manually set it as part of their own CMake configuration).
131-
set(SWIFT_VERSION "4.1")
131+
set(SWIFT_VERSION "4.2")
132132

133133
set(SWIFT_VENDOR "" CACHE STRING
134134
"The vendor name of the Swift compiler")

benchmark/utils/DriverUtils.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,10 @@ struct TestConfig {
208208
}
209209

210210
if let x = benchArgs.optionalArgsMap["--sleep"] {
211-
if x.isEmpty {
211+
guard let v = Int(x) else {
212212
return .fail("--sleep requires a non-empty integer value")
213213
}
214-
let v: Int? = Int(x)
215-
if v == nil {
216-
return .fail("--sleep requires a non-empty integer value")
217-
}
218-
afterRunSleep = v!
214+
afterRunSleep = v
219215
}
220216

221217
if let _ = benchArgs.optionalArgsMap["--list"] {

cmake/modules/AddSwift.cmake

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,16 @@ function(_add_variant_c_compile_flags)
183183
if(optimized OR CFLAGS_FORCE_BUILD_OPTIMIZED)
184184
list(APPEND result "-O2")
185185

186-
# Omit leaf frame pointers on x86.
187-
if("${CFLAGS_ARCH}" STREQUAL "i386" OR "${CFLAGS_ARCH}" STREQUAL "i686")
188-
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
189-
list(APPEND result "-momit-leaf-frame-pointer")
190-
else()
191-
list(APPEND result "/Oy")
186+
# Omit leaf frame pointers on x86 production builds (optimized, no debug
187+
# info, and no asserts).
188+
is_build_type_with_debuginfo("${CFLAGS_BUILD_TYPE}" debug)
189+
if(NOT debug AND NOT CFLAGS_ENABLE_ASSERTIONS)
190+
if("${CFLAGS_ARCH}" STREQUAL "i386" OR "${CFLAGS_ARCH}" STREQUAL "i686")
191+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
192+
list(APPEND result "-momit-leaf-frame-pointer")
193+
else()
194+
list(APPEND result "/Oy")
195+
endif()
192196
endif()
193197
endif()
194198
else()

docs/Serialization.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ organizational purposes.
135135
of ``@_transparent``. The SIL block precedes the AST block because it affects
136136
which AST nodes get serialized.
137137

138-
- The **SIL index black** contains tables for accessing various SIL entities by
138+
- The **SIL index block** contains tables for accessing various SIL entities by
139139
their names, along with a mapping of unique IDs for these to the appropriate
140140
bit offsets into the SIL block.
141141

include/swift/ABI/MetadataValues.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,10 @@ class TypeContextDescriptorFlags : public FlagSet<uint16_t> {
10211021
/// Only meaningful for class descriptors.
10221022
Class_SuperclassReferenceKind = 12,
10231023
Class_SuperclassReferenceKind_width = 2,
1024+
1025+
/// Whether the immediate class members in this metadata are allocated
1026+
/// at negative offsets. For now, we don't use this.
1027+
Class_AreImmediateMembersNegative = 11,
10241028
};
10251029

10261030
public:
@@ -1037,6 +1041,9 @@ class TypeContextDescriptorFlags : public FlagSet<uint16_t> {
10371041
FLAGSET_DEFINE_FLAG_ACCESSORS(Class_HasResilientSuperclass,
10381042
class_hasResilientSuperclass,
10391043
class_setHasResilientSuperclass)
1044+
FLAGSET_DEFINE_FLAG_ACCESSORS(Class_AreImmediateMembersNegative,
1045+
class_areImmediateMembersNegative,
1046+
class_setAreImmediateMembersNegative)
10401047

10411048
FLAGSET_DEFINE_FIELD_ACCESSORS(Class_SuperclassReferenceKind,
10421049
Class_SuperclassReferenceKind_width,

include/swift/AST/Attr.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ DECL_ATTR(__raw_doc_comment, RawDocComment, OnAnyDecl |
214214
NotSerialized | RejectByParser, /* Not serialized */48)
215215

216216
// Also handles unowned and unowned(weak).
217-
DECL_ATTR(weak, Ownership, OnVar | OnParam | DeclModifier | NotSerialized,
217+
DECL_ATTR(weak, ReferenceOwnership, OnVar | OnParam | DeclModifier | NotSerialized,
218218
/* Not serialized */49)
219-
DECL_ATTR_ALIAS(unowned, Ownership)
219+
DECL_ATTR_ALIAS(unowned, ReferenceOwnership)
220220

221221
DECL_ATTR(effects, Effects, OnFunc | OnConstructor | OnDestructor |
222222
UserInaccessible, 50)

include/swift/AST/Attr.h

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,18 @@ class TypeAttributes {
105105

106106
bool hasConvention() const { return convention.hasValue(); }
107107
StringRef getConvention() const { return *convention; }
108-
109-
bool hasOwnership() const { return getOwnership() != Ownership::Strong; }
110-
Ownership getOwnership() const {
111-
if (has(TAK_sil_weak)) return Ownership::Weak;
112-
if (has(TAK_sil_unowned)) return Ownership::Unowned;
113-
if (has(TAK_sil_unmanaged)) return Ownership::Unmanaged;
114-
return Ownership::Strong;
108+
109+
bool hasOwnership() const {
110+
return getOwnership() != ReferenceOwnership::Strong;
111+
}
112+
ReferenceOwnership getOwnership() const {
113+
if (has(TAK_sil_weak))
114+
return ReferenceOwnership::Weak;
115+
if (has(TAK_sil_unowned))
116+
return ReferenceOwnership::Unowned;
117+
if (has(TAK_sil_unmanaged))
118+
return ReferenceOwnership::Unmanaged;
119+
return ReferenceOwnership::Strong;
115120
}
116121

117122
void clearOwnership() {
@@ -965,24 +970,27 @@ class EffectsAttr : public DeclAttribute {
965970

966971

967972
/// Represents weak/unowned/unowned(unsafe) decl modifiers.
968-
class OwnershipAttr : public DeclAttribute {
969-
const Ownership ownership;
973+
class ReferenceOwnershipAttr : public DeclAttribute {
974+
const ReferenceOwnership ownership;
975+
970976
public:
971-
OwnershipAttr(SourceRange range, Ownership kind)
972-
: DeclAttribute(DAK_Ownership, range.Start, range, /*Implicit=*/false),
973-
ownership(kind) {}
977+
ReferenceOwnershipAttr(SourceRange range, ReferenceOwnership kind)
978+
: DeclAttribute(DAK_ReferenceOwnership, range.Start, range,
979+
/*Implicit=*/false),
980+
ownership(kind) {}
974981

975-
OwnershipAttr(Ownership kind) : OwnershipAttr(SourceRange(), kind) {}
982+
ReferenceOwnershipAttr(ReferenceOwnership kind)
983+
: ReferenceOwnershipAttr(SourceRange(), kind) {}
976984

977-
Ownership get() const { return ownership; }
985+
ReferenceOwnership get() const { return ownership; }
978986

979987
/// Returns a copy of this attribute without any source information.
980-
OwnershipAttr *clone(ASTContext &context) const {
981-
return new (context) OwnershipAttr(get());
988+
ReferenceOwnershipAttr *clone(ASTContext &context) const {
989+
return new (context) ReferenceOwnershipAttr(get());
982990
}
983991

984992
static bool classof(const DeclAttribute *DA) {
985-
return DA->getKind() == DAK_Ownership;
993+
return DA->getKind() == DAK_ReferenceOwnership;
986994
}
987995
};
988996

include/swift/AST/Decl.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4606,7 +4606,20 @@ class VarDecl : public AbstractStorageDecl {
46064606
bool isLet() const { return getSpecifier() == Specifier::Let; }
46074607
/// Is this an immutable 'shared' property?
46084608
bool isShared() const { return getSpecifier() == Specifier::Shared; }
4609-
4609+
4610+
ValueOwnership getValueOwnership() const {
4611+
switch (getSpecifier()) {
4612+
case Specifier::Let:
4613+
return ValueOwnership::Default;
4614+
case Specifier::Var:
4615+
return ValueOwnership::Default;
4616+
case Specifier::InOut:
4617+
return ValueOwnership::InOut;
4618+
case Specifier::Shared:
4619+
return ValueOwnership::Shared;
4620+
}
4621+
}
4622+
46104623
/// Is this an element in a capture list?
46114624
bool isCaptureList() const { return Bits.VarDecl.IsCaptureList; }
46124625

include/swift/AST/DiagnosticConsumer.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef SWIFT_BASIC_DIAGNOSTICCONSUMER_H
2020
#define SWIFT_BASIC_DIAGNOSTICCONSUMER_H
2121

22+
#include "swift/Basic/LLVM.h"
2223
#include "swift/Basic/SourceLoc.h"
2324
#include "llvm/Support/SourceMgr.h"
2425

@@ -111,6 +112,75 @@ class NullDiagnosticConsumer : public DiagnosticConsumer {
111112
ArrayRef<DiagnosticArgument> FormatArgs,
112113
const DiagnosticInfo &Info) override;
113114
};
115+
116+
/// \brief DiagnosticConsumer that funnels diagnostics in certain files to
117+
/// particular sub-consumers.
118+
///
119+
/// The intended use case for such a consumer is "batch mode" compilations,
120+
/// where we want to record diagnostics for each file as if they were compiled
121+
/// separately. This is important for incremental builds, so that if a file has
122+
/// warnings but doesn't get recompiled in the next build, the warnings persist.
123+
///
124+
/// Diagnostics that are not in one of the special files are emitted into every
125+
/// sub-consumer. This is necessary to deal with, for example, diagnostics in a
126+
/// bridging header imported from Objective-C, which isn't really about the
127+
/// current file.
128+
class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
129+
public:
130+
/// A diagnostic consumer, along with the name of the buffer that it should
131+
/// be associated with. An empty string means that a consumer is not
132+
/// associated with any particular buffer, and should only receive diagnostics
133+
/// that are not in any of the other consumers' files.
134+
using ConsumerPair =
135+
std::pair<std::string, std::unique_ptr<DiagnosticConsumer>>;
136+
137+
private:
138+
/// All consumers owned by this FileSpecificDiagnosticConsumer.
139+
const SmallVector<ConsumerPair, 4> SubConsumers;
140+
141+
using ConsumersOrderedByRangeEntry =
142+
std::pair<CharSourceRange, DiagnosticConsumer *>;
143+
144+
/// The consumers owned by this FileSpecificDiagnosticConsumer, sorted by
145+
/// the end locations of each file so that a lookup by position can be done
146+
/// using binary search.
147+
///
148+
/// Generated and cached when the first diagnostic with a location is emitted.
149+
/// This allows diagnostics to be emitted before files are actually opened,
150+
/// as long as they don't have source locations.
151+
///
152+
/// \see #consumerForLocation
153+
SmallVector<ConsumersOrderedByRangeEntry, 4> ConsumersOrderedByRange;
154+
155+
/// Indicates which consumer to send Note diagnostics too.
156+
///
157+
/// Notes are always considered attached to the error, warning, or remark
158+
/// that was most recently emitted.
159+
///
160+
/// If null, Note diagnostics are sent to every consumer.
161+
DiagnosticConsumer *ConsumerForSubsequentNotes = nullptr;
162+
163+
public:
164+
/// Takes ownership of the DiagnosticConsumers specified in \p consumers.
165+
///
166+
/// There must not be two consumers for the same file (i.e., having the same
167+
/// buffer name).
168+
explicit FileSpecificDiagnosticConsumer(
169+
SmallVectorImpl<ConsumerPair> &consumers);
170+
171+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
172+
DiagnosticKind Kind,
173+
StringRef FormatString,
174+
ArrayRef<DiagnosticArgument> FormatArgs,
175+
const DiagnosticInfo &Info) override;
176+
177+
bool finishProcessing() override;
178+
179+
private:
180+
void computeConsumersOrderedByRange(SourceManager &SM);
181+
DiagnosticConsumer *consumerForLocation(SourceManager &SM,
182+
SourceLoc loc) const;
183+
};
114184

115185
} // end namespace swift
116186

0 commit comments

Comments
 (0)