Skip to content

Commit 367a861

Browse files
committed
---
yaml --- r: 341747 b: refs/heads/rxwei-patch-1 c: 6025608 h: refs/heads/master i: 341745: 2f79b05 341743: a5b2615
1 parent c8d12b0 commit 367a861

File tree

9 files changed

+42
-54
lines changed

9 files changed

+42
-54
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: 768b91e4561da5122356ec45f19e55664d8e72bf
1018+
refs/heads/rxwei-patch-1: 6025608aebe4e79d954b16592416f00e626aaac7
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/AST/SimpleRequest.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ namespace detail {
113113

114114
/// Extract the first, nearest source location from a tuple.
115115
template<unsigned Index, typename ...Types,
116-
typename = typename std::enable_if<(Index < sizeof...(Types))>::type>
116+
typename = typename std::enable_if<sizeof...(Types) - Index
117+
? true
118+
: false>::type>
117119
SourceLoc extractNearestSourceLocTuple(const std::tuple<Types...> &value) {
118120
SourceLoc loc = maybeExtractNearestSourceLoc(std::get<Index>(value));
119121
if (loc.isValid())

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5473,15 +5473,3 @@ void TypeChecker::inferDefaultWitnesses(ProtocolDecl *proto) {
54735473
req.getFirstType()->getCanonicalType(), requirementProto, *conformance);
54745474
}
54755475
}
5476-
5477-
Type TypeChecker::getWitnessType(Type type, ProtocolDecl *protocol,
5478-
ProtocolConformanceRef conformance,
5479-
Identifier name,
5480-
Diag<> brokenProtocolDiag) {
5481-
Type ty = conformance.getTypeWitnessByName(type, name);
5482-
if (!ty &&
5483-
!(conformance.isConcrete() && conformance.getConcrete()->isInvalid()))
5484-
diagnose(protocol->getLoc(), brokenProtocolDiag);
5485-
5486-
return (!ty || ty->hasError()) ? Type() : ty;
5487-
}

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,8 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
763763
return nullptr;
764764
S->setSequenceConformance(conformance);
765765

766-
iteratorTy = TC.getWitnessType(sequenceType, sequenceProto, *conformance,
767-
TC.Context.Id_Iterator,
768-
diag::sequence_protocol_broken);
766+
iteratorTy = conformance->getTypeWitnessByName(sequenceType,
767+
TC.Context.Id_Iterator);
769768
if (!iteratorTy)
770769
return nullptr;
771770

@@ -796,7 +795,7 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
796795
// be around.
797796
auto nextResultType =
798797
OptionalType::get(conformance->getTypeWitnessByName(
799-
sequenceType, DC->getASTContext().Id_Element))
798+
sequenceType, TC.Context.Id_Element))
800799
->getCanonicalType();
801800
auto *genBinding = PatternBindingDecl::createImplicit(
802801
TC.Context, StaticSpellingKind::None, genPat,
@@ -829,9 +828,8 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
829828
if (!genConformance)
830829
return nullptr;
831830

832-
Type elementTy = TC.getWitnessType(iteratorTy, iteratorProto,
833-
*genConformance, TC.Context.Id_Element,
834-
diag::iterator_protocol_broken);
831+
Type elementTy = genConformance->getTypeWitnessByName(iteratorTy,
832+
TC.Context.Id_Element);
835833
if (!elementTy)
836834
return nullptr;
837835

branches/rxwei-patch-1/lib/Sema/TypeChecker.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,26 +1536,6 @@ class TypeChecker final : public LazyResolver {
15361536
/// array literals exist.
15371537
bool requireArrayLiteralIntrinsics(SourceLoc loc);
15381538

1539-
/// Retrieve the witness type with the given name.
1540-
///
1541-
/// \param type The type that conforms to the given protocol.
1542-
///
1543-
/// \param protocol The protocol through which we're looking.
1544-
///
1545-
/// \param conformance The protocol conformance.
1546-
///
1547-
/// \param name The name of the associated type.
1548-
///
1549-
/// \param brokenProtocolDiag Diagnostic to emit if the type cannot be
1550-
/// accessed.
1551-
///
1552-
/// \return the witness type, or null if an error occurs or the type
1553-
/// returned would contain an ErrorType.
1554-
Type getWitnessType(Type type, ProtocolDecl *protocol,
1555-
ProtocolConformanceRef conformance,
1556-
Identifier name,
1557-
Diag<> brokenProtocolDiag);
1558-
15591539
/// Build a call to the witness with the given name and arguments.
15601540
///
15611541
/// \param base The base expression, whose witness will be invoked.

branches/rxwei-patch-1/stdlib/public/SwiftShims/RefCount.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,6 @@ _Static_assert(_Alignof(InlineRefCounts) == _Alignof(__swift_uintptr_t),
14961496
#endif
14971497

14981498
#if defined(_WIN32) && defined(_M_ARM64)
1499-
#if defined(__cplusplus)
15001499
namespace std {
15011500
template <>
15021501
inline void _Atomic_storage<swift::SideTableRefCountBits, 16>::_Unlock() const noexcept {
@@ -1506,6 +1505,5 @@ inline void _Atomic_storage<swift::SideTableRefCountBits, 16>::_Unlock() const n
15061505
}
15071506
}
15081507
#endif
1509-
#endif
15101508

15111509
#endif

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ internal final class __EmptyArrayStorage
4040
return try body(UnsafeBufferPointer(start: nil, count: 0))
4141
}
4242

43+
@nonobjc
44+
override internal func _getNonVerbatimBridgedCount() -> Int {
45+
return 0
46+
}
47+
4348
override internal func _getNonVerbatimBridgingBuffer() -> _BridgingBuffer {
4449
return _BridgingBuffer(0)
4550
}
@@ -106,6 +111,17 @@ internal final class _ContiguousArrayStorage<
106111
}
107112
}
108113

114+
/// Returns the number of elements in the array.
115+
///
116+
/// - Precondition: `Element` is bridged non-verbatim.
117+
@nonobjc
118+
override internal func _getNonVerbatimBridgedCount() -> Int {
119+
_internalInvariant(
120+
!_isBridgedVerbatimToObjectiveC(Element.self),
121+
"Verbatim bridging should be handled separately")
122+
return countAndCapacity.count
123+
}
124+
109125
/// Bridge array elements and return a new buffer that owns them.
110126
///
111127
/// - Precondition: `Element` is bridged non-verbatim.

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,13 @@ extension __SwiftNativeNSArrayWithContiguousStorage : _NSArrayCore {
232232
/// bridging of array elements.
233233
@objc
234234
internal override var count: Int {
235-
return _nativeStorage.countAndCapacity.count
235+
if let bridgedStorage = _heapBufferBridged {
236+
return _BridgingBuffer(bridgedStorage).count
237+
}
238+
239+
// Check if elements are bridged verbatim.
240+
return _nativeStorage._withVerbatimBridgedUnsafeBuffer { $0.count }
241+
?? _nativeStorage._getNonVerbatimBridgedCount()
236242
}
237243
}
238244
#else
@@ -288,6 +294,12 @@ internal class __ContiguousArrayStorageBase
288294
"Concrete subclasses must implement _withVerbatimBridgedUnsafeBuffer")
289295
}
290296

297+
@nonobjc
298+
internal func _getNonVerbatimBridgedCount() -> Int {
299+
_internalInvariantFailure(
300+
"Concrete subclasses must implement _getNonVerbatimBridgedCount")
301+
}
302+
291303
internal func _getNonVerbatimBridgingBuffer() -> _BridgingBuffer {
292304
_internalInvariantFailure(
293305
"Concrete subclasses must implement _getNonVerbatimBridgingBuffer")

branches/rxwei-patch-1/stdlib/public/runtime/Metadata.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "llvm/Support/PointerLikeTypeTraits.h"
3232
#include <algorithm>
3333
#include <cctype>
34-
#include <cinttypes>
3534
#include <condition_variable>
3635
#include <new>
3736
#include <unordered_set>
@@ -3898,15 +3897,10 @@ void _swift_debug_verifyTypeLayoutAttribute(Metadata *type,
38983897
size_t size,
38993898
const char *description) {
39003899
auto presentValue = [&](const void *value) {
3901-
if (size <= sizeof(uint64_t)) {
3902-
uint64_t intValue = 0;
3903-
auto ptr = reinterpret_cast<uint8_t *>(&intValue);
3904-
#if defined(__BIG_ENDIAN__)
3905-
ptr += sizeof(uint64_t) - size;
3906-
#endif
3907-
memcpy(ptr, value, size);
3908-
fprintf(stderr, "%" PRIu64 " (%#" PRIx64 ")\n", intValue, intValue);
3909-
fprintf(stderr, " ");
3900+
if (size < sizeof(long long)) {
3901+
long long intValue = 0;
3902+
memcpy(&intValue, value, size);
3903+
fprintf(stderr, "%lld (%#llx)\n ", intValue, intValue);
39103904
}
39113905
auto bytes = reinterpret_cast<const uint8_t *>(value);
39123906
for (unsigned i = 0; i < size; ++i) {

0 commit comments

Comments
 (0)