Skip to content

Commit 681fa32

Browse files
committed
---
yaml --- r: 339899 b: refs/heads/rxwei-patch-1 c: a35c9f0 h: refs/heads/master i: 339897: 4548cd5 339895: 668639b
1 parent 6d06cff commit 681fa32

23 files changed

+41
-181
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 4cb6c71adfaf1b53321319376bb9bbb44ef74d24
1018+
refs/heads/rxwei-patch-1: a35c9f0c607619285c521a6f6e7284190d3594c6
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/include/swift/ABI/Metadata.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3121,6 +3121,10 @@ struct MetadataCompletionContext {
31213121
/// it may be called many times as successive dependencies are resolved.
31223122
/// If the function ever completes successfully (by returning null), it
31233123
/// will not be called again for the same type.
3124+
///
3125+
/// \return null to indicate that the type has been completed, or a non-null
3126+
/// pointer to indicate that completion is blocked on the completion of
3127+
/// some other type
31243128
using MetadataCompleter =
31253129
SWIFT_CC(swift)
31263130
MetadataDependency(const Metadata *type,

branches/rxwei-patch-1/lib/SILOptimizer/Utils/CastOptimizer.cpp

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -321,45 +321,17 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
321321
auto *CCABI = cast<CheckedCastAddrBranchInst>(Inst);
322322
switch (CCABI->getConsumptionKind()) {
323323
case CastConsumptionKind::TakeAlways:
324-
Builder.emitDestroyValueOperation(Loc, srcOp);
324+
Builder.createReleaseValue(Loc, srcOp, Builder.getDefaultAtomicity());
325325
break;
326326
case CastConsumptionKind::TakeOnSuccess: {
327-
{
328-
// Insert a release in the success BB.
329-
SILBuilderWithScope successBuilder(SuccessBB->begin());
330-
successBuilder.emitDestroyValueOperation(Loc, srcOp);
331-
}
332-
{
333-
// And a store in the failure BB.
334-
if (Builder.hasOwnership()) {
335-
SILBuilderWithScope failureBuilder(FailureBB->begin());
336-
SILValue writeback = srcOp;
337-
SILType srcType = src->getType().getObjectType();
338-
if (writeback->getType() != srcType) {
339-
writeback =
340-
failureBuilder.createUncheckedRefCast(Loc, writeback, srcType);
341-
}
342-
failureBuilder.emitStoreValueOperation(Loc, writeback, src,
343-
StoreOwnershipQualifier::Init);
344-
}
345-
}
327+
// Insert a release in the success BB.
328+
SILBuilderWithScope SuccessBuilder(SuccessBB->begin());
329+
SuccessBuilder.emitDestroyValueOperation(Loc, srcOp);
346330
break;
347331
}
348332
case CastConsumptionKind::BorrowAlways:
349333
llvm_unreachable("checked_cast_addr_br never has BorrowAlways");
350334
case CastConsumptionKind::CopyOnSuccess:
351-
// If we are performing copy_on_success, store the value back into memory
352-
// here since we loaded it. We may need to cast back to the actual
353-
// underlying type.
354-
if (Builder.hasOwnership()) {
355-
SILValue writeback = srcOp;
356-
SILType srcType = src->getType().getObjectType();
357-
if (writeback->getType() != srcType) {
358-
writeback = Builder.createUncheckedRefCast(Loc, writeback, srcType);
359-
}
360-
Builder.emitStoreValueOperation(Loc, writeback, src,
361-
StoreOwnershipQualifier::Init);
362-
}
363335
break;
364336
}
365337

branches/rxwei-patch-1/lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,10 +2735,6 @@ void TypeChecker::addImplicitDynamicAttribute(Decl *D) {
27352735
// Don't add dynamic to functions with a cdecl.
27362736
if (FD->getAttrs().hasAttribute<CDeclAttr>())
27372737
return;
2738-
// Don't add dynamic to local function definitions.
2739-
if (!FD->getDeclContext()->isTypeContext() &&
2740-
FD->getDeclContext()->isLocalContext())
2741-
return;
27422738
}
27432739

27442740
// Don't add dynamic if accessor is inlinable or tranparent.

branches/rxwei-patch-1/stdlib/public/Darwin/Foundation/Collections+DataProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extension Repeated: DataProtocol where Element == UInt8 {
4949
public typealias Regions = Repeated<Data>
5050

5151
public var regions: Repeated<Data> {
52-
guard self.count > 0 else { return repeatElement(Data(), count: 0) }
52+
guard !self.isEmpty else { return repeatElement(Data(), count: 0) }
5353
return repeatElement(Data(CollectionOfOne(self.first!)), count: self.count)
5454
}
5555
}

branches/rxwei-patch-1/stdlib/public/Darwin/Foundation/Data.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
639639
@inlinable // This is @inlinable as a convenience initializer.
640640
init(_ srcBuffer: UnsafeRawBufferPointer) {
641641
self.init(count: srcBuffer.count)
642-
if srcBuffer.count > 0 {
642+
if !srcBuffer.isEmpty {
643643
Swift.withUnsafeMutableBytes(of: &bytes) { dstBuffer in
644644
dstBuffer.baseAddress?.copyMemory(from: srcBuffer.baseAddress!, byteCount: srcBuffer.count)
645645
}
@@ -729,7 +729,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
729729

730730
@inlinable // This is @inlinable as trivially computable.
731731
mutating func append(contentsOf buffer: UnsafeRawBufferPointer) {
732-
guard buffer.count > 0 else { return }
732+
guard !buffer.isEmpty else { return }
733733
assert(count + buffer.count <= MemoryLayout<Buffer>.size)
734734
let cnt = count
735735
_ = Swift.withUnsafeMutableBytes(of: &bytes) { rawBuffer in
@@ -1270,7 +1270,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
12701270

12711271
@inlinable // This is @inlinable as a trivial initializer.
12721272
init(_ buffer: UnsafeRawBufferPointer) {
1273-
if buffer.count == 0 {
1273+
if buffer.isEmpty {
12741274
self = .empty
12751275
} else if InlineData.canStore(count: buffer.count) {
12761276
self = .inline(InlineData(buffer))
@@ -1283,7 +1283,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
12831283

12841284
@inlinable // This is @inlinable as a trivial initializer.
12851285
init(_ buffer: UnsafeRawBufferPointer, owner: AnyObject) {
1286-
if buffer.count == 0 {
1286+
if buffer.isEmpty {
12871287
self = .empty
12881288
} else if InlineData.canStore(count: buffer.count) {
12891289
self = .inline(InlineData(buffer))
@@ -2313,7 +2313,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
23132313
}
23142314

23152315
public mutating func append(_ other: Data) {
2316-
guard other.count > 0 else { return }
2316+
guard !other.isEmpty else { return }
23172317
other.withUnsafeBytes { (buffer: UnsafeRawBufferPointer) in
23182318
_representation.append(contentsOf: buffer)
23192319
}

branches/rxwei-patch-1/stdlib/public/Darwin/Foundation/URL.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ public struct URL : ReferenceConvertible, Equatable {
586586
/// If the data representation is not a legal URL string as ASCII bytes, the URL object may not behave as expected. If the URL cannot be formed then this will return nil.
587587
@available(macOS 10.11, iOS 9.0, *)
588588
public init?(dataRepresentation: __shared Data, relativeTo url: __shared URL?, isAbsolute: Bool = false) {
589-
guard dataRepresentation.count > 0 else { return nil }
589+
guard !dataRepresentation.isEmpty else { return nil }
590590

591591
if isAbsolute {
592592
_url = URL._converted(from: NSURL(absoluteURLWithDataRepresentation: dataRepresentation, relativeTo: url))

branches/rxwei-patch-1/stdlib/public/Darwin/Network/NWListener.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public final class NWListener: CustomDebugStringConvertible {
4747
} else {
4848
description = String("\(description).*")
4949
}
50-
if txtRecord != nil && txtRecord!.count > 0 {
51-
description = String("\(description) <\(txtRecord!.count) bytes of txt>")
50+
if let txtRecord = txtRecord, !txtRecord.isEmpty {
51+
description = String("\(description) <\(txtRecord.count) bytes of txt>")
5252
}
5353
return description
5454
}

branches/rxwei-patch-1/stdlib/public/core/Array.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ extension Array: RangeReplaceableCollection {
884884
return _Buffer(_buffer: newBuffer, shiftedToStartIndex: 0)
885885
}
886886

887-
/// Construct an Array of `count` uninitialized elements.
887+
/// Construct a Array of `count` uninitialized elements.
888888
@inlinable
889889
internal init(_uninitializedCount count: Int) {
890890
_precondition(count >= 0, "Can't construct Array with count < 0")
@@ -903,7 +903,7 @@ extension Array: RangeReplaceableCollection {
903903
}
904904

905905
/// Entry point for `Array` literal construction; builds and returns
906-
/// an Array of `count` uninitialized elements.
906+
/// a Array of `count` uninitialized elements.
907907
@inlinable
908908
@_semantics("array.uninitialized")
909909
internal static func _allocateUninitialized(
@@ -936,7 +936,7 @@ extension Array: RangeReplaceableCollection {
936936
}
937937

938938
/// Entry point for aborting literal construction: deallocates
939-
/// an Array containing only uninitialized elements.
939+
/// a Array containing only uninitialized elements.
940940
@inlinable
941941
internal mutating func _deallocateUninitialized() {
942942
// Set the count to zero and just release as normal.

branches/rxwei-patch-1/stdlib/public/core/CollectionDifference.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public struct CollectionDifference<ChangeElement> {
8989
private static func _validateChanges<Changes: Collection>(
9090
_ changes : Changes
9191
) -> Bool where Changes.Element == Change {
92-
if changes.count == 0 { return true }
92+
if changes.isEmpty { return true }
9393

9494
var insertAssocToOffset = Dictionary<Int,Int>()
9595
var removeOffsetToAssoc = Dictionary<Int,Int>()
@@ -181,7 +181,7 @@ public struct CollectionDifference<ChangeElement> {
181181

182182
// Find first insertion via binary search
183183
let firstInsertIndex: Int
184-
if sortedChanges.count == 0 {
184+
if sortedChanges.isEmpty {
185185
firstInsertIndex = 0
186186
} else {
187187
var range = 0...sortedChanges.count

branches/rxwei-patch-1/stdlib/public/core/DebuggerSupport.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public enum _DebuggerSupport {
119119
isRoot: Bool
120120
) -> Bool {
121121
if isRoot || collectionStatus.isCollection { return true }
122-
if mirror.children.count > 0 { return true }
122+
if !mirror.children.isEmpty { return true }
123123
if mirror.displayStyle == .`class` { return true }
124124
if let sc = mirror.superclassMirror { return ivarCount(mirror: sc) > 0 }
125125
return true

branches/rxwei-patch-1/stdlib/public/core/Dictionary.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ extension Collection {
16781678
internal func _makeKeyValuePairDescription<K, V>(
16791679
withTypeName type: String? = nil
16801680
) -> String where Element == (key: K, value: V) {
1681-
if self.count == 0 {
1681+
if self.isEmpty {
16821682
return "[:]"
16831683
}
16841684

branches/rxwei-patch-1/stdlib/public/core/KeyPath.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ internal struct KeyPathBuffer {
17201720

17211721
// fetch type, which is in the buffer unless it's the final component
17221722
let nextType: Any.Type?
1723-
if data.count == 0 {
1723+
if data.isEmpty {
17241724
nextType = nil
17251725
} else {
17261726
nextType = _pop(from: &data, as: Any.Type.self)
@@ -2244,7 +2244,7 @@ internal func _appendingKeyPaths<
22442244
}
22452245
}
22462246

2247-
_internalInvariant(destBuffer.count == 0,
2247+
_internalInvariant(destBuffer.isEmpty,
22482248
"did not fill entire result buffer")
22492249
}
22502250

branches/rxwei-patch-1/stdlib/public/core/StringUTF8Validation.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ internal func validateUTF8(_ buf: UnsafeBufferPointer<UInt8>) -> UTF8ValidationR
154154
}
155155

156156
internal func repairUTF8(_ input: UnsafeBufferPointer<UInt8>, firstKnownBrokenRange: Range<Int>) -> String {
157-
_internalInvariant(input.count > 0, "empty input doesn't need to be repaired")
157+
_internalInvariant(!input.isEmpty, "empty input doesn't need to be repaired")
158158
_internalInvariant(firstKnownBrokenRange.clamped(to: input.indices) == firstKnownBrokenRange)
159159
// During this process, `remainingInput` contains the remaining bytes to process. It's split into three
160160
// non-overlapping sub-regions:
@@ -176,8 +176,8 @@ internal func repairUTF8(_ input: UnsafeBufferPointer<UInt8>, firstKnownBrokenRa
176176
var brokenRange: Range<Int> = firstKnownBrokenRange
177177
var remainingInput = input
178178
repeat {
179-
_internalInvariant(brokenRange.count > 0, "broken range empty")
180-
_internalInvariant(remainingInput.count > 0, "empty remaining input doesn't need to be repaired")
179+
_internalInvariant(!brokenRange.isEmpty, "broken range empty")
180+
_internalInvariant(!remainingInput.isEmpty, "empty remaining input doesn't need to be repaired")
181181
let goodChunk = remainingInput[..<brokenRange.startIndex]
182182

183183
// very likely this capacity reservation does not actually do anything because we reserved space for the entire
@@ -199,6 +199,6 @@ internal func repairUTF8(_ input: UnsafeBufferPointer<UInt8>, firstKnownBrokenRa
199199
case .error(let newBrokenRange):
200200
brokenRange = newBrokenRange
201201
}
202-
} while remainingInput.count > 0
202+
} while !remainingInput.isEmpty
203203
return String(result)
204204
}

branches/rxwei-patch-1/stdlib/public/core/VarArgs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public func _encodeBitsAsWords<T>(_ x: T) -> [Int] {
201201
let result = [Int](
202202
repeating: 0,
203203
count: (MemoryLayout<T>.size + MemoryLayout<Int>.size - 1) / MemoryLayout<Int>.size)
204-
_internalInvariant(result.count > 0)
204+
_internalInvariant(!result.isEmpty)
205205
var tmp = x
206206
// FIXME: use UnsafeMutablePointer.assign(from:) instead of memcpy.
207207
_memcpy(dest: UnsafeMutablePointer(result._baseAddressIfContiguous!),

branches/rxwei-patch-1/test/Prototypes/BigInt.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public struct _BigInt<Word: FixedWidthInteger & UnsignedInteger> :
9595

9696
/// A Boolean value indicating whether this instance is equal to zero.
9797
public var isZero: Bool {
98-
return _data.count == 0
98+
return _data.isEmpty
9999
}
100100

101101
//===--- Numeric initializers -------------------------------------------===//
@@ -212,7 +212,7 @@ public struct _BigInt<Word: FixedWidthInteger & UnsignedInteger> :
212212
/// - `_data` has no trailing zero elements
213213
/// - If `self == 0`, then `isNegative == false`
214214
func _checkInvariants(source: String = #function) {
215-
if _data.count == 0 {
215+
if _data.isEmpty {
216216
assert(isNegative == false,
217217
"\(source): isNegative with zero length _data")
218218
}

branches/rxwei-patch-1/test/SILGen/dynamically_replaceable.swift

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -367,18 +367,3 @@ var x = 10
367367
defer {
368368
let y = x
369369
}
370-
371-
// IMPLICIT-LABEL: sil [dynamically_replacable] [ossa] @$s23dynamically_replaceable16testWithLocalFunyyF
372-
// IMPLICIT-LABEL: sil private [ossa] @$s23dynamically_replaceable16testWithLocalFunyyF05localF0L_yyF
373-
// IMPLICIT-LABEL: sil private [ossa] @$s23dynamically_replaceable16testWithLocalFunyyF05localF0L_yyF0geF0L_yyF
374-
// IMPLICIT-LABEL: sil private [ossa] @$s23dynamically_replaceable16testWithLocalFunyyFyycfU_
375-
public func testWithLocalFun() {
376-
func localFun() {
377-
func localLocalFun() { print("bar") }
378-
print("foo")
379-
localLocalFun()
380-
}
381-
localFun()
382-
let unamedClosure = { print("foo") }
383-
unamedClosure()
384-
}

branches/rxwei-patch-1/test/SILOptimizer/constant_propagation_objc.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ bb4:
185185
// CHECK: apply {{%.*}}<Array<String>>([[CAST_TMP]], [[INPUT_VALUE]],
186186
// CHECK: strong_release [[INPUT_VALUE]]
187187
// NOTE: When we perform take_always, this is the take of the cast.
188-
// CHECK: strong_release [[INPUT_VALUE]]
188+
// CHECK: release_value [[INPUT_VALUE]]
189189
// CHECK: switch_enum_addr [[CAST_TMP]] : $*Optional<Array<String>>, case #Optional.none!enumelt: [[FAIL_BB]], default [[SUCCESS_TRAMPOLINE_BB:bb[0-9]+]]
190190
//
191191
// CHECK: [[SUCCESS_TRAMPOLINE_BB]]:

0 commit comments

Comments
 (0)