Merge pull request #16757 from AnthonyLatsis/mark-gardening
[Gardening][.def] Add MARK annotations for better nav
diff --git a/benchmark/single-source/StringBuilder.swift b/benchmark/single-source/StringBuilder.swift
index 65eeb00..6c3ec52 100644
--- a/benchmark/single-source/StringBuilder.swift
+++ b/benchmark/single-source/StringBuilder.swift
@@ -22,6 +22,10 @@
runFunction: run_StringBuilder,
tags: [.validation, .api, .String]),
BenchmarkInfo(
+ name: "StringBuilderSmallReservingCapacity",
+ runFunction: run_StringBuilderSmallReservingCapacity,
+ tags: [.validation, .api, .String]),
+ BenchmarkInfo(
name: "StringUTF16Builder",
runFunction: run_StringUTF16Builder,
tags: [.validation, .api, .String]),
@@ -48,8 +52,11 @@
]
@inline(never)
-func buildString(_ i: String) -> String {
+func buildString(_ i: String, reservingCapacity: Bool = false) -> String {
var sb = getString(i)
+ if reservingCapacity {
+ sb.reserveCapacity(10)
+ }
for str in ["b","c","d","pizza"] {
sb += str
}
@@ -64,6 +71,13 @@
}
@inline(never)
+public func run_StringBuilderSmallReservingCapacity(_ N: Int) {
+ for _ in 1...5000*N {
+ blackHole(buildString("a", reservingCapacity: true))
+ }
+}
+
+@inline(never)
func addString(_ i: String) -> String {
let s = getString(i) + "b" + "c" + "d" + "pizza"
return s
@@ -179,3 +193,4 @@
blackHole(buildString(
word: "bumfuzzle", count: 50_000 * N, reservingCapacity: true))
}
+
diff --git a/benchmark/single-source/StringComparison.swift b/benchmark/single-source/StringComparison.swift
index 1397f00..240e11d 100644
--- a/benchmark/single-source/StringComparison.swift
+++ b/benchmark/single-source/StringComparison.swift
@@ -34,167 +34,275 @@
BenchmarkInfo(
name: "StringComparison_ascii",
runFunction: run_StringComparison_ascii,
- tags: [.validation, .api, .String]),
+ tags: [.validation, .api, .String],
+ setUpFunction: setup_StringComparison_ascii),
BenchmarkInfo(
name: "StringComparison_latin1",
runFunction: run_StringComparison_latin1,
- tags: [.validation, .api, .String]),
+ tags: [.validation, .api, .String],
+ setUpFunction: setup_StringComparison_latin1),
BenchmarkInfo(
name: "StringComparison_fastPrenormal",
runFunction: run_StringComparison_fastPrenormal,
- tags: [.validation, .api, .String]),
+ tags: [.validation, .api, .String],
+ setUpFunction: setup_StringComparison_fastPrenormal),
BenchmarkInfo(
name: "StringComparison_slowerPrenormal",
runFunction: run_StringComparison_slowerPrenormal,
- tags: [.validation, .api, .String]),
+ tags: [.validation, .api, .String],
+ setUpFunction: setup_StringComparison_slowerPrenormal),
BenchmarkInfo(
name: "StringComparison_nonBMPSlowestPrenormal",
runFunction: run_StringComparison_nonBMPSlowestPrenormal,
- tags: [.validation, .api, .String]),
+ tags: [.validation, .api, .String],
+ setUpFunction: setup_StringComparison_nonBMPSlowestPrenormal),
BenchmarkInfo(
name: "StringComparison_emoji",
runFunction: run_StringComparison_emoji,
- tags: [.validation, .api, .String]),
+ tags: [.validation, .api, .String],
+ setUpFunction: setup_StringComparison_emoji),
BenchmarkInfo(
name: "StringComparison_abnormal",
runFunction: run_StringComparison_abnormal,
- tags: [.validation, .api, .String]),
+ tags: [.validation, .api, .String],
+ setUpFunction: setup_StringComparison_abnormal),
BenchmarkInfo(
name: "StringComparison_zalgo",
runFunction: run_StringComparison_zalgo,
- tags: [.validation, .api, .String]),
+ tags: [.validation, .api, .String],
+ setUpFunction: setup_StringComparison_zalgo),
BenchmarkInfo(
name: "StringComparison_longSharedPrefix",
runFunction: run_StringComparison_longSharedPrefix,
- tags: [.validation, .api, .String]),
+ tags: [.validation, .api, .String],
+ setUpFunction: setup_StringComparison_longSharedPrefix),
]
-
- @inline(never)
- public func run_StringComparison_ascii(_ N: Int) {
- let workload = Workload.ascii
- let tripCount = workload.tripCount
- let payload = workload.payload
- for _ in 1...tripCount*N {
- for s1 in payload {
- for s2 in payload {
- blackHole(s1 < s2)
- }
+
+
+var Workload_ascii: Workload? = nil
+
+@inline(never)
+public func setup_StringComparison_ascii() {
+ if Workload_ascii != nil {
+ return
+ }
+ Workload_ascii = Workload.ascii
+}
+
+@inline(never)
+public func run_StringComparison_ascii(_ N: Int) {
+ let workload = Workload_ascii._unsafelyUnwrappedUnchecked
+ let tripCount = workload.tripCount
+ let payload = workload.payload
+ for _ in 1...tripCount*N {
+ for s1 in payload {
+ for s2 in payload {
+ blackHole(s1 < s2)
}
}
}
-
- @inline(never)
- public func run_StringComparison_latin1(_ N: Int) {
- let workload = Workload.latin1
- let tripCount = workload.tripCount
- let payload = workload.payload
- for _ in 1...tripCount*N {
- for s1 in payload {
- for s2 in payload {
- blackHole(s1 < s2)
- }
+}
+
+
+var Workload_latin1: Workload? = nil
+
+@inline(never)
+public func setup_StringComparison_latin1() {
+ if Workload_latin1 != nil {
+ return
+ }
+ Workload_latin1 = Workload.latin1
+}
+
+@inline(never)
+public func run_StringComparison_latin1(_ N: Int) {
+ let workload = Workload_latin1._unsafelyUnwrappedUnchecked
+ let tripCount = workload.tripCount
+ let payload = workload.payload
+ for _ in 1...tripCount*N {
+ for s1 in payload {
+ for s2 in payload {
+ blackHole(s1 < s2)
}
}
}
-
- @inline(never)
- public func run_StringComparison_fastPrenormal(_ N: Int) {
- let workload = Workload.fastPrenormal
- let tripCount = workload.tripCount
- let payload = workload.payload
- for _ in 1...tripCount*N {
- for s1 in payload {
- for s2 in payload {
- blackHole(s1 < s2)
- }
+}
+
+
+var Workload_fastPrenormal: Workload? = nil
+
+@inline(never)
+public func setup_StringComparison_fastPrenormal() {
+ if Workload_fastPrenormal != nil {
+ return
+ }
+ Workload_fastPrenormal = Workload.fastPrenormal
+}
+
+@inline(never)
+public func run_StringComparison_fastPrenormal(_ N: Int) {
+ let workload = Workload_fastPrenormal._unsafelyUnwrappedUnchecked
+ let tripCount = workload.tripCount
+ let payload = workload.payload
+ for _ in 1...tripCount*N {
+ for s1 in payload {
+ for s2 in payload {
+ blackHole(s1 < s2)
}
}
}
-
- @inline(never)
- public func run_StringComparison_slowerPrenormal(_ N: Int) {
- let workload = Workload.slowerPrenormal
- let tripCount = workload.tripCount
- let payload = workload.payload
- for _ in 1...tripCount*N {
- for s1 in payload {
- for s2 in payload {
- blackHole(s1 < s2)
- }
+}
+
+
+var Workload_slowerPrenormal: Workload? = nil
+
+@inline(never)
+public func setup_StringComparison_slowerPrenormal() {
+ if Workload_slowerPrenormal != nil {
+ return
+ }
+ Workload_slowerPrenormal = Workload.slowerPrenormal
+}
+
+@inline(never)
+public func run_StringComparison_slowerPrenormal(_ N: Int) {
+ let workload = Workload_slowerPrenormal._unsafelyUnwrappedUnchecked
+ let tripCount = workload.tripCount
+ let payload = workload.payload
+ for _ in 1...tripCount*N {
+ for s1 in payload {
+ for s2 in payload {
+ blackHole(s1 < s2)
}
}
}
-
- @inline(never)
- public func run_StringComparison_nonBMPSlowestPrenormal(_ N: Int) {
- let workload = Workload.nonBMPSlowestPrenormal
- let tripCount = workload.tripCount
- let payload = workload.payload
- for _ in 1...tripCount*N {
- for s1 in payload {
- for s2 in payload {
- blackHole(s1 < s2)
- }
+}
+
+
+var Workload_nonBMPSlowestPrenormal: Workload? = nil
+
+@inline(never)
+public func setup_StringComparison_nonBMPSlowestPrenormal() {
+ if Workload_nonBMPSlowestPrenormal != nil {
+ return
+ }
+ Workload_nonBMPSlowestPrenormal = Workload.nonBMPSlowestPrenormal
+}
+
+@inline(never)
+public func run_StringComparison_nonBMPSlowestPrenormal(_ N: Int) {
+ let workload = Workload_nonBMPSlowestPrenormal._unsafelyUnwrappedUnchecked
+ let tripCount = workload.tripCount
+ let payload = workload.payload
+ for _ in 1...tripCount*N {
+ for s1 in payload {
+ for s2 in payload {
+ blackHole(s1 < s2)
}
}
}
-
- @inline(never)
- public func run_StringComparison_emoji(_ N: Int) {
- let workload = Workload.emoji
- let tripCount = workload.tripCount
- let payload = workload.payload
- for _ in 1...tripCount*N {
- for s1 in payload {
- for s2 in payload {
- blackHole(s1 < s2)
- }
+}
+
+
+var Workload_emoji: Workload? = nil
+
+@inline(never)
+public func setup_StringComparison_emoji() {
+ if Workload_emoji != nil {
+ return
+ }
+ Workload_emoji = Workload.emoji
+}
+
+@inline(never)
+public func run_StringComparison_emoji(_ N: Int) {
+ let workload = Workload_emoji._unsafelyUnwrappedUnchecked
+ let tripCount = workload.tripCount
+ let payload = workload.payload
+ for _ in 1...tripCount*N {
+ for s1 in payload {
+ for s2 in payload {
+ blackHole(s1 < s2)
}
}
}
-
- @inline(never)
- public func run_StringComparison_abnormal(_ N: Int) {
- let workload = Workload.abnormal
- let tripCount = workload.tripCount
- let payload = workload.payload
- for _ in 1...tripCount*N {
- for s1 in payload {
- for s2 in payload {
- blackHole(s1 < s2)
- }
+}
+
+
+var Workload_abnormal: Workload? = nil
+
+@inline(never)
+public func setup_StringComparison_abnormal() {
+ if Workload_abnormal != nil {
+ return
+ }
+ Workload_abnormal = Workload.abnormal
+}
+
+@inline(never)
+public func run_StringComparison_abnormal(_ N: Int) {
+ let workload = Workload_abnormal._unsafelyUnwrappedUnchecked
+ let tripCount = workload.tripCount
+ let payload = workload.payload
+ for _ in 1...tripCount*N {
+ for s1 in payload {
+ for s2 in payload {
+ blackHole(s1 < s2)
}
}
}
-
- @inline(never)
- public func run_StringComparison_zalgo(_ N: Int) {
- let workload = Workload.zalgo
- let tripCount = workload.tripCount
- let payload = workload.payload
- for _ in 1...tripCount*N {
- for s1 in payload {
- for s2 in payload {
- blackHole(s1 < s2)
- }
+}
+
+
+var Workload_zalgo: Workload? = nil
+
+@inline(never)
+public func setup_StringComparison_zalgo() {
+ if Workload_zalgo != nil {
+ return
+ }
+ Workload_zalgo = Workload.zalgo
+}
+
+@inline(never)
+public func run_StringComparison_zalgo(_ N: Int) {
+ let workload = Workload_zalgo._unsafelyUnwrappedUnchecked
+ let tripCount = workload.tripCount
+ let payload = workload.payload
+ for _ in 1...tripCount*N {
+ for s1 in payload {
+ for s2 in payload {
+ blackHole(s1 < s2)
}
}
}
-
- @inline(never)
- public func run_StringComparison_longSharedPrefix(_ N: Int) {
- let workload = Workload.longSharedPrefix
- let tripCount = workload.tripCount
- let payload = workload.payload
- for _ in 1...tripCount*N {
- for s1 in payload {
- for s2 in payload {
- blackHole(s1 < s2)
- }
+}
+
+
+var Workload_longSharedPrefix: Workload? = nil
+
+@inline(never)
+public func setup_StringComparison_longSharedPrefix() {
+ if Workload_longSharedPrefix != nil {
+ return
+ }
+ Workload_longSharedPrefix = Workload.longSharedPrefix
+}
+
+@inline(never)
+public func run_StringComparison_longSharedPrefix(_ N: Int) {
+ let workload = Workload_longSharedPrefix._unsafelyUnwrappedUnchecked
+ let tripCount = workload.tripCount
+ let payload = workload.payload
+ for _ in 1...tripCount*N {
+ for s1 in payload {
+ for s2 in payload {
+ blackHole(s1 < s2)
}
}
}
-
+}
+
struct Workload {
static let N = 100
@@ -406,4 +514,4 @@
""".lines()
)
-}
\ No newline at end of file
+}
diff --git a/benchmark/single-source/StringComparison.swift.gyb b/benchmark/single-source/StringComparison.swift.gyb
index 25c5a40..adadb9d 100644
--- a/benchmark/single-source/StringComparison.swift.gyb
+++ b/benchmark/single-source/StringComparison.swift.gyb
@@ -37,25 +37,37 @@
BenchmarkInfo(
name: "StringComparison_${Name}",
runFunction: run_StringComparison_${Name},
- tags: [.validation, .api, .String]),
+ tags: [.validation, .api, .String],
+ setUpFunction: setup_StringComparison_${Name}),
% end # Names
]
-
+
% for Name in Names:
- @inline(never)
- public func run_StringComparison_${Name}(_ N: Int) {
- let workload = Workload.${Name}
- let tripCount = workload.tripCount
- let payload = workload.payload
- for _ in 1...tripCount*N {
- for s1 in payload {
- for s2 in payload {
- blackHole(s1 < s2)
- }
+
+var Workload_${Name}: Workload? = nil
+
+@inline(never)
+public func setup_StringComparison_${Name}() {
+ if Workload_${Name} != nil {
+ return
+ }
+ Workload_${Name} = Workload.${Name}
+}
+
+@inline(never)
+public func run_StringComparison_${Name}(_ N: Int) {
+ let workload = Workload_${Name}._unsafelyUnwrappedUnchecked
+ let tripCount = workload.tripCount
+ let payload = workload.payload
+ for _ in 1...tripCount*N {
+ for s1 in payload {
+ for s2 in payload {
+ blackHole(s1 < s2)
}
}
}
-
+}
+
% end # Names
struct Workload {
@@ -268,4 +280,4 @@
""".lines()
)
-}
\ No newline at end of file
+}
diff --git a/docs/Random.md b/docs/Random.md
new file mode 100644
index 0000000..98905f87
--- /dev/null
+++ b/docs/Random.md
@@ -0,0 +1,16 @@
+# Random APIs
+
+More documentation to come.
+
+## Platform-Specific Default Random
+
+The implementation of the default random generator varies by platform. The implementation
+on each platform must be thread-safe and automatically seeded, and should be
+cryptographically secure to the extent possible. Currently supported platforms have the
+following implementation details:
+
+- Apple platforms use `arc4random_buf(3)`.
+- Linux, FreeBSD, and other UNIX-like platforms use `getrandom(2)` when available;
+otherwise, they read from `/dev/urandom`.
+- Fuchsia platforms use `getentropy(3)`.
+- Windows paltforms use `BCryptGenRandom`.
diff --git a/include/swift/ABI/MetadataValues.h b/include/swift/ABI/MetadataValues.h
index e92dd07..433e958 100644
--- a/include/swift/ABI/MetadataValues.h
+++ b/include/swift/ABI/MetadataValues.h
@@ -54,9 +54,20 @@
#define ABSTRACTMETADATAKIND(name, start, end) \
name##_Start = start, name##_End = end,
#include "MetadataKind.def"
+
+ /// The largest possible non-isa-pointer metadata kind value.
+ ///
+ /// This is included in the enumeration to prevent against attempts to
+ /// exhaustively match metadata kinds. Future Swift runtimes or compilers
+ /// may introduce new metadata kinds, so for forward compatibility, the
+ /// runtime must tolerate metadata with unknown kinds.
+ /// This specific value is not mapped to a valid metadata kind at this time,
+ /// however.
+ LastEnumerated = 2047,
};
-const unsigned LastEnumeratedMetadataKind = 2047;
+const unsigned LastEnumeratedMetadataKind =
+ (unsigned)MetadataKind::LastEnumerated;
/// Try to translate the 'isa' value of a type/heap metadata into a value
/// of the MetadataKind enum.
diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def
index 2c47384..7ce915b 100644
--- a/include/swift/AST/DiagnosticsSema.def
+++ b/include/swift/AST/DiagnosticsSema.def
@@ -2449,6 +2449,9 @@
"standard library error: _MaxBuiltinIntegerType is not properly defined", ())
ERROR(no_MaxBuiltinFloatType_found,none,
"standard library error: _MaxBuiltinFloatType is not properly defined", ())
+ERROR(integer_literal_overflows_maxwidth, none,
+ "integer literal needs %1 bits, exceeding limit of %0 bits",
+ (unsigned, unsigned))
ERROR(no_member_of_module,none,
"module %0 has no member named %1", (Identifier, DeclName))
diff --git a/include/swift/AST/Expr.h b/include/swift/AST/Expr.h
index a120657..c4fb037 100644
--- a/include/swift/AST/Expr.h
+++ b/include/swift/AST/Expr.h
@@ -156,6 +156,10 @@
SWIFT_INLINE_BITFIELD_EMPTY(LiteralExpr, Expr);
SWIFT_INLINE_BITFIELD_EMPTY(IdentityExpr, Expr);
+ SWIFT_INLINE_BITFIELD(LookupExpr, Expr, 1,
+ IsSuper : 1
+ );
+ SWIFT_INLINE_BITFIELD_EMPTY(DynamicLookupExpr, LookupExpr);
SWIFT_INLINE_BITFIELD(ParenExpr, IdentityExpr, 1,
/// \brief Whether we're wrapping a trailing closure expression.
@@ -182,9 +186,8 @@
FunctionRefKind : 2
);
- SWIFT_INLINE_BITFIELD(MemberRefExpr, Expr, 2+1,
- Semantics : 2, // an AccessSemantics
- IsSuper : 1
+ SWIFT_INLINE_BITFIELD(MemberRefExpr, LookupExpr, 2,
+ Semantics : 2 // an AccessSemantics
);
SWIFT_INLINE_BITFIELD_FULL(TupleElementExpr, Expr, 32,
@@ -210,9 +213,8 @@
FunctionRefKind : 2
);
- SWIFT_INLINE_BITFIELD_FULL(SubscriptExpr, Expr, 2+1+16+1+1,
+ SWIFT_INLINE_BITFIELD_FULL(SubscriptExpr, LookupExpr, 2+1+1+16,
Semantics : 2, // an AccessSemantics
- IsSuper : 1,
/// Whether the SubscriptExpr also has source locations for the argument
/// label.
HasArgLabelLocs : 1,
@@ -223,7 +225,7 @@
NumArgLabels : 16
);
- SWIFT_INLINE_BITFIELD_FULL(DynamicSubscriptExpr, Expr, 1+1+16,
+ SWIFT_INLINE_BITFIELD_FULL(DynamicSubscriptExpr, DynamicLookupExpr, 1+1+16,
/// Whether the DynamicSubscriptExpr also has source locations for the
/// argument label.
HasArgLabelLocs : 1,
@@ -833,6 +835,8 @@
APInt getValue() const;
static APInt getValue(StringRef Text, unsigned BitWidth, bool Negative);
+ APInt getRawMagnitude() const;
+
static bool classof(const Expr *E) {
return E->getKind() == ExprKind::IntegerLiteral;
}
@@ -1489,16 +1493,60 @@
return E->getKind() == ExprKind::UnresolvedDeclRef;
}
};
+
+/// LookupExpr - This abstract class represents 'a.b', 'a[]', etc where we
+/// are referring to a member of a type, such as a property, variable, etc.
+class LookupExpr : public Expr {
+ Expr *Base;
+ ConcreteDeclRef Member;
+
+protected:
+ explicit LookupExpr(ExprKind Kind, Expr *base, ConcreteDeclRef member,
+ bool Implicit)
+ : Expr(Kind, Implicit), Base(base), Member(member) {
+ Bits.LookupExpr.IsSuper = false;
+ assert(Base);
+ }
+
+public:
+ /// Retrieve the base of the expression.
+ Expr *getBase() const { return Base; }
+
+ /// Replace the base of the expression.
+ void setBase(Expr *E) { Base = E; }
+
+ /// Retrieve the member to which this access refers.
+ ConcreteDeclRef getMember() const { return Member; }
+
+ /// Determine whether the operation has a known underlying declaration or not.
+ bool hasDecl() const { return static_cast<bool>(Member); }
+ /// Retrieve the declaration that this /// operation refers to.
+ /// Only valid when \c hasDecl() is true.
+ ConcreteDeclRef getDecl() const {
+ assert(hasDecl() && "No subscript declaration known!");
+ return getMember();
+ }
+
+ /// Determine whether this reference refers to the superclass's property.
+ bool isSuper() const { return Bits.LookupExpr.IsSuper; }
+
+ /// Set whether this reference refers to the superclass's property.
+ void setIsSuper(bool isSuper) { Bits.LookupExpr.IsSuper = isSuper; }
+
+ static bool classof(const Expr *E) {
+ return E->getKind() >= ExprKind::First_LookupExpr &&
+ E->getKind() <= ExprKind::Last_LookupExpr;
+ }
+};
+
/// MemberRefExpr - This represents 'a.b' where we are referring to a member
/// of a type, such as a property or variable.
///
/// Note that methods found via 'dot' syntax are expressed as DotSyntaxCallExpr
/// nodes, because 'a.f' is actually an application of 'a' (the implicit object
/// argument) to the function 'f'.
-class MemberRefExpr : public Expr {
- Expr *Base;
- ConcreteDeclRef Member;
+class MemberRefExpr : public LookupExpr {
SourceLoc DotLoc;
DeclNameLoc NameLoc;
@@ -1506,12 +1554,8 @@
MemberRefExpr(Expr *base, SourceLoc dotLoc, ConcreteDeclRef member,
DeclNameLoc loc, bool Implicit,
AccessSemantics semantics = AccessSemantics::Ordinary);
- Expr *getBase() const { return Base; }
- ConcreteDeclRef getMember() const { return Member; }
- DeclNameLoc getNameLoc() const { return NameLoc; }
SourceLoc getDotLoc() const { return DotLoc; }
-
- void setBase(Expr *E) { Base = E; }
+ DeclNameLoc getNameLoc() const { return NameLoc; }
/// Return true if this member access is direct, meaning that it
/// does not call the getter or setter.
@@ -1519,17 +1563,9 @@
return (AccessSemantics) Bits.MemberRefExpr.Semantics;
}
- /// Determine whether this member reference refers to the
- /// superclass's property.
- bool isSuper() const { return Bits.MemberRefExpr.IsSuper; }
-
- /// Set whether this member reference refers to the superclass's
- /// property.
- void setIsSuper(bool isSuper) { Bits.MemberRefExpr.IsSuper = isSuper; }
-
SourceLoc getLoc() const { return NameLoc.getBaseNameLoc(); }
SourceLoc getStartLoc() const {
- SourceLoc BaseStartLoc = Base->getStartLoc();
+ SourceLoc BaseStartLoc = getBase()->getStartLoc();
if (BaseStartLoc.isInvalid() || NameLoc.isInvalid()) {
return NameLoc.getBaseNameLoc();
} else {
@@ -1548,24 +1584,12 @@
/// Common base for expressions that involve dynamic lookup, which
/// determines at runtime whether a particular method, property, or
/// subscript is available.
-class DynamicLookupExpr : public Expr {
+class DynamicLookupExpr : public LookupExpr {
protected:
- Expr *Base;
- ConcreteDeclRef Member;
-
explicit DynamicLookupExpr(ExprKind kind, ConcreteDeclRef member, Expr *base)
- : Expr(kind, /*Implicit=*/false), Base(base), Member(member) { }
+ : LookupExpr(kind, base, member, /*Implicit=*/false) { }
public:
- /// Retrieve the member to which this access refers.
- ConcreteDeclRef getMember() const { return Member; }
-
- /// Retrieve the base of the expression.
- Expr *getBase() const { return Base; }
-
- /// Replace the base of the expression.
- void setBase(Expr *base) { Base = base; }
-
static bool classof(const Expr *E) {
return E->getKind() >= ExprKind::First_DynamicLookupExpr &&
E->getKind() <= ExprKind::Last_DynamicLookupExpr;
@@ -1608,7 +1632,7 @@
SourceLoc getLoc() const { return NameLoc.getBaseNameLoc(); }
SourceLoc getStartLoc() const {
- SourceLoc BaseStartLoc = Base->getStartLoc();
+ SourceLoc BaseStartLoc = getBase()->getStartLoc();
if (BaseStartLoc.isInvalid() || NameLoc.isInvalid()) {
return NameLoc.getBaseNameLoc();
} else {
@@ -1676,12 +1700,6 @@
ConcreteDeclRef decl,
bool implicit);
- /// Retrieve the base of the expression.
- Expr *getBase() const { return Base; }
-
- /// Replace the base of the expression.
- void setBase(Expr *base) { Base = base; }
-
/// getIndex - Retrieve the index of the subscript expression, i.e., the
/// "offset" into the base value.
Expr *getIndex() const { return Index; }
@@ -1702,7 +1720,7 @@
SourceLoc getLoc() const { return Index->getStartLoc(); }
- SourceLoc getStartLoc() const { return Base->getStartLoc(); }
+ SourceLoc getStartLoc() const { return getBase()->getStartLoc(); }
SourceLoc getEndLoc() const { return Index->getEndLoc(); }
static bool classof(const Expr *E) {
@@ -2230,12 +2248,10 @@
/// type-checked and well-formed subscript expression refers to a subscript
/// declaration, which provides a getter and (optionally) a setter that will
/// be used to perform reads/writes.
-class SubscriptExpr final : public Expr,
+class SubscriptExpr final : public LookupExpr,
public TrailingCallArguments<SubscriptExpr> {
friend TrailingCallArguments;
- ConcreteDeclRef TheDecl;
- Expr *Base;
Expr *Index;
SubscriptExpr(Expr *base, Expr *index, ArrayRef<Identifier> argLabels,
@@ -2267,11 +2283,6 @@
AccessSemantics semantics
= AccessSemantics::Ordinary);
- /// getBase - Retrieve the base of the subscript expression, i.e., the
- /// value being indexed.
- Expr *getBase() const { return Base; }
- void setBase(Expr *E) { Base = E; }
-
/// getIndex - Retrieve the index of the subscript expression, i.e., the
/// "offset" into the base value.
Expr *getIndex() const { return Index; }
@@ -2296,30 +2307,11 @@
return (AccessSemantics) Bits.SubscriptExpr.Semantics;
}
- /// Determine whether this member reference refers to the
- /// superclass's property.
- bool isSuper() const { return Bits.SubscriptExpr.IsSuper; }
-
- /// Set whether this member reference refers to the superclass's
- /// property.
- void setIsSuper(bool isSuper) { Bits.SubscriptExpr.IsSuper = isSuper; }
-
- /// Determine whether subscript operation has a known underlying
- /// subscript declaration or not.
- bool hasDecl() const { return static_cast<bool>(TheDecl); }
-
- /// Retrieve the subscript declaration that this subscripting
- /// operation refers to. Only valid when \c hasDecl() is true.
- ConcreteDeclRef getDecl() const {
- assert(hasDecl() && "No subscript declaration known!");
- return TheDecl;
- }
-
SourceLoc getLoc() const { return Index->getStartLoc(); }
- SourceLoc getStartLoc() const { return Base->getStartLoc(); }
+ SourceLoc getStartLoc() const { return getBase()->getStartLoc(); }
SourceLoc getEndLoc() const {
auto end = Index->getEndLoc();
- return end.isValid() ? end : Base->getEndLoc();
+ return end.isValid() ? end : getBase()->getEndLoc();
}
static bool classof(const Expr *E) {
@@ -4030,7 +4022,7 @@
}
};
-/// PostfixUnaryExpr - Prefix unary expressions like '!y'.
+/// PostfixUnaryExpr - Postfix unary expressions like 'y!'.
class PostfixUnaryExpr : public ApplyExpr {
public:
PostfixUnaryExpr(Expr *Fn, Expr *Arg, Type Ty = Type())
diff --git a/include/swift/AST/ExprNodes.def b/include/swift/AST/ExprNodes.def
index 3aa95b6..30b3c9f 100644
--- a/include/swift/AST/ExprNodes.def
+++ b/include/swift/AST/ExprNodes.def
@@ -88,11 +88,14 @@
UNCHECKED_EXPR(OverloadedDeclRef, OverloadSetRefExpr)
EXPR_RANGE(OverloadSetRef, OverloadedDeclRef, OverloadedDeclRef)
UNCHECKED_EXPR(UnresolvedDeclRef, Expr)
-EXPR(MemberRef, Expr)
-ABSTRACT_EXPR(DynamicLookup, Expr)
- EXPR(DynamicMemberRef, DynamicLookupExpr)
- EXPR(DynamicSubscript, DynamicLookupExpr)
- EXPR_RANGE(DynamicLookup, DynamicMemberRef, DynamicSubscript)
+ABSTRACT_EXPR(Lookup, Expr)
+ EXPR(MemberRef, LookupExpr)
+ EXPR(Subscript, LookupExpr)
+ ABSTRACT_EXPR(DynamicLookup, LookupExpr)
+ EXPR(DynamicMemberRef, DynamicLookupExpr)
+ EXPR(DynamicSubscript, DynamicLookupExpr)
+ EXPR_RANGE(DynamicLookup, DynamicMemberRef, DynamicSubscript)
+ EXPR_RANGE(Lookup, MemberRef, DynamicSubscript)
UNCHECKED_EXPR(UnresolvedSpecialize, Expr)
UNCHECKED_EXPR(UnresolvedMember, Expr)
UNCHECKED_EXPR(UnresolvedDot, Expr)
@@ -111,7 +114,6 @@
EXPR(Array, CollectionExpr)
EXPR(Dictionary, CollectionExpr)
EXPR_RANGE(Collection, Array, Dictionary)
-EXPR(Subscript, Expr)
EXPR(KeyPathApplication, Expr)
EXPR(TupleElement, Expr)
EXPR(CaptureList, Expr)
diff --git a/include/swift/AST/GenericSignatureBuilder.h b/include/swift/AST/GenericSignatureBuilder.h
index 763002a..afea016 100644
--- a/include/swift/AST/GenericSignatureBuilder.h
+++ b/include/swift/AST/GenericSignatureBuilder.h
@@ -508,7 +508,7 @@
Optional<ProtocolConformanceRef>
operator()(CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) const {
+ ProtocolDecl *conformedProtocol) const {
return builder->lookupConformance(dependentType,
conformingReplacementType,
conformedProtocol);
@@ -522,7 +522,7 @@
/// Lookup a protocol conformance in a module-agnostic manner.
Optional<ProtocolConformanceRef>
lookupConformance(CanType dependentType, Type conformingReplacementType,
- ProtocolType *conformedProtocol);
+ ProtocolDecl *conformedProtocol);
/// Retrieve the lazy resolver, if there is one.
diff --git a/include/swift/AST/RequirementEnvironment.h b/include/swift/AST/RequirementEnvironment.h
index ce5165c..34ada04 100644
--- a/include/swift/AST/RequirementEnvironment.h
+++ b/include/swift/AST/RequirementEnvironment.h
@@ -114,7 +114,7 @@
/// Retrieve the substitution map that maps the interface types of the
/// requirement to the interface types of the synthetic environment.
- const SubstitutionMap &getRequirementToSyntheticMap() const {
+ SubstitutionMap getRequirementToSyntheticMap() const {
return reqToSyntheticEnvMap;
}
};
diff --git a/include/swift/AST/SubstitutionMap.h b/include/swift/AST/SubstitutionMap.h
index 21d64b4..5b54941 100644
--- a/include/swift/AST/SubstitutionMap.h
+++ b/include/swift/AST/SubstitutionMap.h
@@ -164,7 +164,7 @@
/// Apply a substitution to all replacement types in the map. Does not
/// change keys.
- SubstitutionMap subst(const SubstitutionMap &subMap) const;
+ SubstitutionMap subst(SubstitutionMap subMap) const;
/// Apply a substitution to all replacement types in the map. Does not
/// change keys.
@@ -208,8 +208,8 @@
///
/// The 'how' parameter determines if we're looking at the depth or index.
static SubstitutionMap
- combineSubstitutionMaps(const SubstitutionMap &firstSubMap,
- const SubstitutionMap &secondSubMap,
+ combineSubstitutionMaps(SubstitutionMap firstSubMap,
+ SubstitutionMap secondSubMap,
CombineSubstitutionMaps how,
unsigned baseDepthOrIndex,
unsigned origDepthOrIndex,
@@ -270,6 +270,28 @@
Type lookupSubstitution(CanSubstitutableType type) const;
};
+/// A function object suitable for use as a \c TypeSubstitutionFn that
+/// queries an underlying \c SubstitutionMap.
+struct QuerySubstitutionMap {
+ SubstitutionMap subMap;
+
+ Type operator()(SubstitutableType *type) const;
+};
+
+/// Functor class suitable for use as a \c LookupConformanceFn to look up a
+/// conformance in a \c SubstitutionMap.
+class LookUpConformanceInSubstitutionMap {
+ SubstitutionMap Subs;
+public:
+ explicit LookUpConformanceInSubstitutionMap(SubstitutionMap Subs)
+ : Subs(Subs) {}
+
+ Optional<ProtocolConformanceRef>
+ operator()(CanType dependentType,
+ Type conformingReplacementType,
+ ProtocolDecl *conformedProtocol) const;
+};
+
} // end namespace swift
namespace llvm {
diff --git a/include/swift/AST/Type.h b/include/swift/AST/Type.h
index c132bd5..60e6fe7 100644
--- a/include/swift/AST/Type.h
+++ b/include/swift/AST/Type.h
@@ -88,19 +88,11 @@
Type operator()(SubstitutableType *type) const;
};
-/// A function object suitable for use as a \c TypeSubstitutionFn that
-/// queries an underlying \c SubstitutionMap.
-struct QuerySubstitutionMap {
- const SubstitutionMap &subMap;
-
- Type operator()(SubstitutableType *type) const;
-};
-
/// Function used to resolve conformances.
using GenericFunction = auto(CanType dependentType,
- Type conformingReplacementType,
- ProtocolType *conformedProtocol)
- ->Optional<ProtocolConformanceRef>;
+ Type conformingReplacementType,
+ ProtocolDecl *conformedProtocol)
+ -> Optional<ProtocolConformanceRef>;
using LookupConformanceFn = llvm::function_ref<GenericFunction>;
/// Functor class suitable for use as a \c LookupConformanceFn to look up a
@@ -114,21 +106,7 @@
Optional<ProtocolConformanceRef>
operator()(CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) const;
-};
-
-/// Functor class suitable for use as a \c LookupConformanceFn to look up a
-/// conformance in a \c SubstitutionMap.
-class LookUpConformanceInSubstitutionMap {
- const SubstitutionMap &Subs;
-public:
- explicit LookUpConformanceInSubstitutionMap(const SubstitutionMap &Subs)
- : Subs(Subs) {}
-
- Optional<ProtocolConformanceRef>
- operator()(CanType dependentType,
- Type conformingReplacementType,
- ProtocolType *conformedProtocol) const;
+ ProtocolDecl *conformedProtocol) const;
};
/// Functor class suitable for use as a \c LookupConformanceFn that provides
@@ -139,7 +117,7 @@
Optional<ProtocolConformanceRef>
operator()(CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) const;
+ ProtocolDecl *conformedProtocol) const;
};
/// Functor class suitable for use as a \c LookupConformanceFn that fetches
@@ -153,7 +131,7 @@
Optional<ProtocolConformanceRef>
operator()(CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) const;
+ ProtocolDecl *conformedProtocol) const;
};
/// Flags that can be passed when substituting into a type.
@@ -314,7 +292,7 @@
/// \param options Options that affect the substitutions.
///
/// \returns the substituted type, or a null type if an error occurred.
- Type subst(const SubstitutionMap &substitutions,
+ Type subst(SubstitutionMap substitutions,
SubstOptions options = None) const;
/// Replace references to substitutable types with new, concrete types and
diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h
index 47a4056..f31121c 100644
--- a/include/swift/AST/Types.h
+++ b/include/swift/AST/Types.h
@@ -1605,7 +1605,7 @@
friend TrailingObjects;
NameAliasType(TypeAliasDecl *typealias, Type parent,
- const SubstitutionMap &substitutions, Type underlying,
+ SubstitutionMap substitutions, Type underlying,
RecursiveTypeProperties properties);
size_t numTrailingObjects(OverloadToken<Type>) const {
@@ -1623,7 +1623,7 @@
public:
static NameAliasType *get(TypeAliasDecl *typealias, Type parent,
- const SubstitutionMap &substitutions,
+ SubstitutionMap substitutions,
Type underlying);
/// \brief Returns the declaration that declares this type.
@@ -1660,7 +1660,7 @@
void Profile(llvm::FoldingSetNodeID &id) const;
static void Profile(llvm::FoldingSetNodeID &id, TypeAliasDecl *typealias,
- Type parent, const SubstitutionMap &substitutions,
+ Type parent, SubstitutionMap substitutions,
Type underlying);
// Implement isa/cast/dyncast/etc.
@@ -3057,7 +3057,7 @@
/// Substitute the given generic arguments into this generic
/// function type and return the resulting non-generic type.
- FunctionType *substGenericArgs(const SubstitutionMap &subs);
+ FunctionType *substGenericArgs(SubstitutionMap subs);
/// Substitute the given generic arguments into this generic
/// function type using the given substitution and conformance lookup
@@ -4033,7 +4033,7 @@
isABICompatibleWith(CanSILFunctionType other) const;
CanSILFunctionType substGenericArgs(SILModule &silModule,
- const SubstitutionMap &subs);
+ SubstitutionMap subs);
CanSILFunctionType substGenericArgs(SILModule &silModule,
TypeSubstitutionFn subs,
LookupConformanceFn conformances);
diff --git a/include/swift/Demangling/TypeDecoder.h b/include/swift/Demangling/TypeDecoder.h
index 9c7b3d9..e20cf2f 100644
--- a/include/swift/Demangling/TypeDecoder.h
+++ b/include/swift/Demangling/TypeDecoder.h
@@ -127,7 +127,7 @@
case NodeKind::BoundGenericEnum:
case NodeKind::BoundGenericStructure:
case NodeKind::BoundGenericOtherNominalType: {
- if (Node->getNumChildren() != 2)
+ if (Node->getNumChildren() < 2)
return BuiltType();
BuiltNominalTypeDecl typeDecl = BuiltNominalTypeDecl();
@@ -161,7 +161,7 @@
// Handle lowered metatypes in a hackish way. If the representation
// was not thin, force the resulting typeref to have a non-empty
// representation.
- if (Node->getNumChildren() == 2) {
+ if (Node->getNumChildren() >= 2) {
auto repr = Node->getChild(i++);
if (repr->getKind() != NodeKind::MetatypeRepresentation ||
!repr->hasText())
diff --git a/include/swift/Remote/MetadataReader.h b/include/swift/Remote/MetadataReader.h
index 9d64ea2..2173e25 100644
--- a/include/swift/Remote/MetadataReader.h
+++ b/include/swift/Remote/MetadataReader.h
@@ -441,7 +441,8 @@
case MetadataKind::ErrorObject:
// Treat these all as Builtin.NativeObject for type lowering purposes.
return Builder.createBuiltinType("Bo");
- case MetadataKind::Opaque: {
+ case MetadataKind::Opaque:
+ default: {
auto BuiltOpaque = Builder.getOpaqueType();
TypeCache[MetadataAddress] = BuiltOpaque;
return BuiltOpaque;
@@ -924,8 +925,6 @@
return _readMetadata<TargetMetatypeMetadata>(address);
case MetadataKind::ObjCClassWrapper:
return _readMetadata<TargetObjCClassWrapperMetadata>(address);
- case MetadataKind::Opaque:
- return _readMetadata<TargetOpaqueMetadata>(address);
case MetadataKind::Optional:
return _readMetadata<TargetEnumMetadata>(address);
case MetadataKind::Struct:
@@ -946,6 +945,9 @@
return _readMetadata(address, totalSize);
}
+ case MetadataKind::Opaque:
+ default:
+ return _readMetadata<TargetOpaqueMetadata>(address);
}
// We can fall out here if the value wasn't actually a valid
diff --git a/include/swift/Runtime/Debug.h b/include/swift/Runtime/Debug.h
index 792eb85..0ecc8f8 100644
--- a/include/swift/Runtime/Debug.h
+++ b/include/swift/Runtime/Debug.h
@@ -82,13 +82,6 @@
swift_runtime_unreachable("Expected compiler to crash.");
}
-/// Report a corrupted type object.
-LLVM_ATTRIBUTE_NORETURN
-LLVM_ATTRIBUTE_ALWAYS_INLINE // Minimize trashed registers
-static inline void _failCorruptType(const Metadata *type) {
- swift::crash("Corrupt Swift type object");
-}
-
// swift::fatalError() halts with a crash log message,
// but makes no attempt to preserve register state.
LLVM_ATTRIBUTE_NORETURN
diff --git a/include/swift/Runtime/Metadata.h b/include/swift/Runtime/Metadata.h
index e055f8f..3d4e384 100644
--- a/include/swift/Runtime/Metadata.h
+++ b/include/swift/Runtime/Metadata.h
@@ -819,22 +819,9 @@
case MetadataKind::ForeignClass:
return true;
- case MetadataKind::Function:
- case MetadataKind::Struct:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
- case MetadataKind::Existential:
- case MetadataKind::Metatype:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
+ default:
return false;
}
-
- swift_runtime_unreachable("Unhandled MetadataKind in switch.");
}
/// Is this metadata for an existential type?
@@ -843,24 +830,10 @@
case MetadataKind::ExistentialMetatype:
case MetadataKind::Existential:
return true;
-
- case MetadataKind::Metatype:
- case MetadataKind::Class:
- case MetadataKind::ObjCClassWrapper:
- case MetadataKind::ForeignClass:
- case MetadataKind::Struct:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
+
+ default:
return false;
}
-
- swift_runtime_unreachable("Unhandled MetadataKind in switch.");
}
/// Is this either type metadata or a class object for any kind of class?
@@ -944,20 +917,9 @@
case MetadataKind::ForeignClass:
return static_cast<const TargetForeignClassMetadata<Runtime> *>(this)
->Description;
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
- case MetadataKind::Function:
- case MetadataKind::Existential:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Metatype:
- case MetadataKind::ObjCClassWrapper:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
+ default:
return nullptr;
}
-
- swift_runtime_unreachable("Unhandled MetadataKind in switch.");
}
/// Get the class object for this type if it has one, or return null if the
diff --git a/include/swift/SIL/SILType.h b/include/swift/SIL/SILType.h
index ce10601..14c9b79 100644
--- a/include/swift/SIL/SILType.h
+++ b/include/swift/SIL/SILType.h
@@ -439,7 +439,7 @@
///
/// Only call this with function types!
SILType substGenericArgs(SILModule &M,
- const SubstitutionMap &SubMap) const;
+ SubstitutionMap SubMap) const;
/// If the original type is generic, pass the signature as genericSig.
///
@@ -450,7 +450,7 @@
LookupConformanceFn conformances,
CanGenericSignature genericSig=CanGenericSignature()) const;
- SILType subst(SILModule &silModule, const SubstitutionMap &subs) const;
+ SILType subst(SILModule &silModule, SubstitutionMap subs) const;
/// Return true if this type references a "ref" type that has a single pointer
/// representation. Class existentials do not always qualify.
diff --git a/include/swift/SILOptimizer/Utils/Generics.h b/include/swift/SILOptimizer/Utils/Generics.h
index e8b7584..02d5f30 100644
--- a/include/swift/SILOptimizer/Utils/Generics.h
+++ b/include/swift/SILOptimizer/Utils/Generics.h
@@ -114,7 +114,7 @@
// Create a new substituted type with the updated signature.
CanSILFunctionType createSubstitutedType(SILFunction *OrigF,
- const SubstitutionMap &SubstMap,
+ SubstitutionMap SubstMap,
bool HasUnboundGenericParams);
void createSubstitutedAndSpecializedTypes();
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 4deddfe..6a1ac4c 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -2874,7 +2874,7 @@
//===----------------------------------------------------------------------===//
NameAliasType::NameAliasType(TypeAliasDecl *typealias, Type parent,
- const SubstitutionMap &substitutions,
+ SubstitutionMap substitutions,
Type underlying,
RecursiveTypeProperties properties)
: SugarType(TypeKind::NameAlias, underlying, properties),
@@ -2897,7 +2897,7 @@
}
NameAliasType *NameAliasType::get(TypeAliasDecl *typealias, Type parent,
- const SubstitutionMap &substitutions,
+ SubstitutionMap substitutions,
Type underlying) {
// Compute the recursive properties.
//
@@ -2950,7 +2950,7 @@
void NameAliasType::Profile(
llvm::FoldingSetNodeID &id,
TypeAliasDecl *typealias,
- Type parent, const SubstitutionMap &substitutions,
+ Type parent, SubstitutionMap substitutions,
Type underlying) {
id.AddPointer(typealias);
id.AddPointer(parent.getPointer());
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 444a9d4..10a2a73 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -996,15 +996,19 @@
return Result;
}
-
-
+/// A wrapper around LLVM::getAsInteger that can be used on Swift interger
+/// literals. It avoids misinterpreting decimal numbers prefixed with 0 as
+/// octal numbers.
+static bool getAsInteger(StringRef Text, llvm::APInt &Value) {
+ // swift encodes octal differently from C
+ bool IsCOctal = Text.size() > 1 && Text[0] == '0' && isdigit(Text[1]);
+ return Text.getAsInteger(IsCOctal ? 10 : 0, Value);
+}
static APInt getIntegerLiteralValue(bool IsNegative, StringRef Text,
unsigned BitWidth) {
llvm::APInt Value(BitWidth, 0);
- // swift encodes octal differently from C
- bool IsCOctal = Text.size() > 1 && Text[0] == '0' && isdigit(Text[1]);
- bool Error = Text.getAsInteger(IsCOctal ? 10 : 0, Value);
+ bool Error = getAsInteger(Text, Value);
assert(!Error && "Invalid IntegerLiteral formed"); (void)Error;
if (IsNegative)
Value = -Value;
@@ -1017,6 +1021,15 @@
return getIntegerLiteralValue(Negative, Text, BitWidth);
}
+/// Returns the raw magnitude of the literal text without any truncation.
+APInt IntegerLiteralExpr::getRawMagnitude() const {
+ llvm::APInt Value(64, 0);
+ bool Error = getAsInteger(getDigitsText(), Value);
+ assert(!Error && "Invalid IntegerLiteral formed");
+ (void)Error;
+ return Value;
+}
+
APInt IntegerLiteralExpr::getValue() const {
assert(!getType().isNull() && "Semantic analysis has not completed");
assert(!getType()->hasError() && "Should have a valid type");
@@ -1342,12 +1355,10 @@
MemberRefExpr::MemberRefExpr(Expr *base, SourceLoc dotLoc,
ConcreteDeclRef member, DeclNameLoc nameLoc,
bool Implicit, AccessSemantics semantics)
- : Expr(ExprKind::MemberRef, Implicit), Base(base),
- Member(member), DotLoc(dotLoc), NameLoc(nameLoc) {
+ : LookupExpr(ExprKind::MemberRef, base, member, Implicit),
+ DotLoc(dotLoc), NameLoc(nameLoc) {
Bits.MemberRefExpr.Semantics = (unsigned) semantics;
- Bits.MemberRefExpr.IsSuper = false;
- assert(Member);
}
Type OverloadSetRefExpr::getBaseType() const {
@@ -1588,10 +1599,9 @@
bool hasTrailingClosure,
ConcreteDeclRef decl,
bool implicit, AccessSemantics semantics)
- : Expr(ExprKind::Subscript, implicit, Type()),
- TheDecl(decl), Base(base), Index(index) {
+ : LookupExpr(ExprKind::Subscript, base, decl, implicit),
+ Index(index) {
Bits.SubscriptExpr.Semantics = (unsigned) semantics;
- Bits.SubscriptExpr.IsSuper = false;
Bits.SubscriptExpr.NumArgLabels = argLabels.size();
Bits.SubscriptExpr.HasArgLabelLocs = !argLabelLocs.empty();
Bits.SubscriptExpr.HasTrailingClosure = hasTrailingClosure;
diff --git a/lib/AST/GenericSignature.cpp b/lib/AST/GenericSignature.cpp
index a5ee2f4..104e046 100644
--- a/lib/AST/GenericSignature.cpp
+++ b/lib/AST/GenericSignature.cpp
@@ -556,7 +556,7 @@
return conformsToProtocol(canFirstType, protocol);
else
return (bool)GSB->lookupConformance(/*dependentType=*/CanType(),
- canFirstType, protocolType);
+ canFirstType, protocol);
}
case RequirementKind::SameType: {
diff --git a/lib/AST/GenericSignatureBuilder.cpp b/lib/AST/GenericSignatureBuilder.cpp
index 8b69e36..9334571 100644
--- a/lib/AST/GenericSignatureBuilder.cpp
+++ b/lib/AST/GenericSignatureBuilder.cpp
@@ -2639,9 +2639,7 @@
// Lookup the conformance of the concrete type to this protocol.
auto conformance =
lookupConformance(type.getDependentType(*this)->getCanonicalType(),
- concrete,
- proto->getDeclaredInterfaceType()
- ->castTo<ProtocolType>());
+ concrete, proto);
if (!conformance) {
if (!concrete->hasError() && concreteSource->getLoc().isValid()) {
Impl->HadAnyError = true;
@@ -2672,9 +2670,7 @@
// Lookup the conformance of the superclass to this protocol.
auto conformance =
lookupConformance(type.getDependentType(*this)->getCanonicalType(),
- superclass,
- proto->getDeclaredInterfaceType()
- ->castTo<ProtocolType>());
+ superclass, proto);
if (!conformance) return nullptr;
// Conformance to this protocol is redundant; update the requirement source
@@ -3825,16 +3821,16 @@
Optional<ProtocolConformanceRef>
GenericSignatureBuilder::lookupConformance(CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) {
+ ProtocolDecl *conformedProtocol) {
if (conformingReplacementType->isTypeParameter())
- return ProtocolConformanceRef(conformedProtocol->getDecl());
+ return ProtocolConformanceRef(conformedProtocol);
// Figure out which module to look into.
// FIXME: When lookupConformance() starts respecting modules, we'll need
// to do some filtering here.
- ModuleDecl *searchModule = conformedProtocol->getDecl()->getParentModule();
+ ModuleDecl *searchModule = conformedProtocol->getParentModule();
auto result = searchModule->lookupConformance(conformingReplacementType,
- conformedProtocol->getDecl());
+ conformedProtocol);
if (result && getLazyResolver())
getLazyResolver()->markConformanceUsed(*result, searchModule);
@@ -4726,7 +4722,7 @@
// getLookupConformanceFns used in here don't use that parameter anyway.
auto dependentType = CanType();
auto conformance =
- getLookupConformanceFn()(dependentType, subjectType, proto);
+ getLookupConformanceFn()(dependentType, subjectType, proto->getDecl());
// FIXME: diagnose if there's no conformance.
if (conformance) {
diff --git a/lib/AST/ProtocolConformance.cpp b/lib/AST/ProtocolConformance.cpp
index 278f0c3..02996fc 100644
--- a/lib/AST/ProtocolConformance.cpp
+++ b/lib/AST/ProtocolConformance.cpp
@@ -118,8 +118,7 @@
// Check the conformance map.
if (auto result = conformances(origType->getCanonicalType(),
- substType,
- proto->getDeclaredType())) {
+ substType, proto)) {
return *result;
}
diff --git a/lib/AST/RequirementEnvironment.cpp b/lib/AST/RequirementEnvironment.cpp
index 8989f1a..a7cd8cd 100644
--- a/lib/AST/RequirementEnvironment.cpp
+++ b/lib/AST/RequirementEnvironment.cpp
@@ -110,10 +110,8 @@
return substGenericParam;
},
[selfType, substConcreteType, conformance, conformanceDC, &ctx](
- CanType type, Type replacement, ProtocolType *protoType)
+ CanType type, Type replacement, ProtocolDecl *proto)
-> Optional<ProtocolConformanceRef> {
- auto proto = protoType->getDecl();
-
// The protocol 'Self' conforms concretely to the conforming type.
if (type->isEqual(selfType)) {
ProtocolConformance *specialized = conformance;
diff --git a/lib/AST/SubstitutionMap.cpp b/lib/AST/SubstitutionMap.cpp
index 6a6a12a..ddf5a00 100644
--- a/lib/AST/SubstitutionMap.cpp
+++ b/lib/AST/SubstitutionMap.cpp
@@ -223,7 +223,7 @@
SubstFlags::UseErrorType);
auto protoType = req.getSecondType()->castTo<ProtocolType>();
auto proto = protoType->getDecl();
- auto conformance = lookupConformance(depTy, replacement, protoType)
+ auto conformance = lookupConformance(depTy, replacement, proto)
.getValueOr(ProtocolConformanceRef(proto));
conformances.push_back(conformance);
}
@@ -338,7 +338,7 @@
return LookUpConformanceInSignature(*getGenericSignature())(
type->getCanonicalType(),
superclass,
- proto->getDeclaredType());
+ proto);
}
return None;
@@ -415,7 +415,7 @@
return subst(MapTypeOutOfContext(), MakeAbstractConformanceForGenericType());
}
-SubstitutionMap SubstitutionMap::subst(const SubstitutionMap &subMap) const {
+SubstitutionMap SubstitutionMap::subst(SubstitutionMap subMap) const {
return subst(QuerySubstitutionMap{subMap},
LookUpConformanceInSubstitutionMap(subMap));
}
@@ -430,8 +430,7 @@
.subst(subs, conformances, SubstFlags::UseErrorType);
},
[&](CanType dependentType, Type replacementType,
- ProtocolType *conformedProtocol) ->Optional<ProtocolConformanceRef> {
- auto proto = conformedProtocol->getDecl();
+ ProtocolDecl *proto) ->Optional<ProtocolConformanceRef> {
auto conformance =
lookupConformance(dependentType, proto)
.getValueOr(ProtocolConformanceRef(proto));
@@ -455,10 +454,9 @@
// inside generic types.
return Type();
},
- [&](CanType origType, Type replacementType, ProtocolType *protoType)
+ [&](CanType origType, Type replacementType, ProtocolDecl *protoType)
-> Optional<ProtocolConformanceRef> {
- if (origType->isEqual(protocolSelfType) &&
- protoType->getDecl() == protocol)
+ if (origType->isEqual(protocolSelfType) && protoType == protocol)
return conformance;
// This will need to change if we ever support protocols
@@ -530,8 +528,8 @@
}
SubstitutionMap
-SubstitutionMap::combineSubstitutionMaps(const SubstitutionMap &firstSubMap,
- const SubstitutionMap &secondSubMap,
+SubstitutionMap::combineSubstitutionMaps(SubstitutionMap firstSubMap,
+ SubstitutionMap secondSubMap,
CombineSubstitutionMaps how,
unsigned firstDepthOrIndex,
unsigned secondDepthOrIndex,
@@ -568,13 +566,12 @@
return Type(replacement).subst(secondSubMap);
return Type(type).subst(firstSubMap);
},
- [&](CanType type, Type substType, ProtocolType *conformedProtocol) {
+ [&](CanType type, Type substType, ProtocolDecl *conformedProtocol) {
auto replacement = type.transform(replaceGenericParameter);
if (replacement)
return secondSubMap.lookupConformance(replacement->getCanonicalType(),
- conformedProtocol->getDecl());
- return firstSubMap.lookupConformance(type,
- conformedProtocol->getDecl());
+ conformedProtocol);
+ return firstSubMap.lookupConformance(type, conformedProtocol);
});
}
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index c7ff4db..f2391a5 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -2762,7 +2762,7 @@
}
FunctionType *
-GenericFunctionType::substGenericArgs(const SubstitutionMap &subs) {
+GenericFunctionType::substGenericArgs(SubstitutionMap subs) {
Type input = getInput().subst(subs);
Type result = getResult().subst(subs);
return FunctionType::get(input, result, getExtInfo());
@@ -2842,8 +2842,7 @@
auto proto = assocType->getProtocol();
Optional<ProtocolConformanceRef> conformance
= lookupConformances(origBase->getCanonicalType(),
- substBase,
- proto->getDeclaredType());
+ substBase, proto);
if (!conformance) return failed();
if (!conformance->isConcrete()) return failed();
@@ -2876,39 +2875,39 @@
Optional<ProtocolConformanceRef>
LookUpConformanceInModule::operator()(CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) const {
+ ProtocolDecl *conformedProtocol) const {
if (conformingReplacementType->isTypeParameter())
- return ProtocolConformanceRef(conformedProtocol->getDecl());
+ return ProtocolConformanceRef(conformedProtocol);
return M->lookupConformance(conformingReplacementType,
- conformedProtocol->getDecl());
+ conformedProtocol);
}
Optional<ProtocolConformanceRef>
LookUpConformanceInSubstitutionMap::operator()(CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) const {
- return Subs.lookupConformance(dependentType, conformedProtocol->getDecl());
+ ProtocolDecl *conformedProtocol) const {
+ return Subs.lookupConformance(dependentType, conformedProtocol);
}
Optional<ProtocolConformanceRef>
MakeAbstractConformanceForGenericType::operator()(CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) const {
+ ProtocolDecl *conformedProtocol) const {
assert((conformingReplacementType->is<SubstitutableType>()
|| conformingReplacementType->is<DependentMemberType>())
&& "replacement requires looking up a concrete conformance");
- return ProtocolConformanceRef(conformedProtocol->getDecl());
+ return ProtocolConformanceRef(conformedProtocol);
}
Optional<ProtocolConformanceRef>
LookUpConformanceInSignature::operator()(CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) const {
+ ProtocolDecl *conformedProtocol) const {
// FIXME: Should pass dependentType instead, once
// GenericSignature::lookupConformance() does the right thing
return Sig.lookupConformance(conformingReplacementType->getCanonicalType(),
- conformedProtocol->getDecl());
+ conformedProtocol);
}
Type DependentMemberType::substBaseType(ModuleDecl *module,
@@ -3116,7 +3115,7 @@
});
}
-Type Type::subst(const SubstitutionMap &substitutions,
+Type Type::subst(SubstitutionMap substitutions,
SubstOptions options) const {
return substType(*this,
QuerySubstitutionMap{substitutions},
diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp
index 5d1b089..d431891 100644
--- a/lib/ClangImporter/ClangImporter.cpp
+++ b/lib/ClangImporter/ClangImporter.cpp
@@ -2455,6 +2455,15 @@
results.push_back(extension);
}
+ auto findEnclosingExtension = [](Decl *importedDecl) -> ExtensionDecl * {
+ for (auto importedDC = importedDecl->getDeclContext();
+ !importedDC->isModuleContext();
+ importedDC = importedDC->getParent()) {
+ if (auto ext = dyn_cast<ExtensionDecl>(importedDC))
+ return ext;
+ }
+ return nullptr;
+ };
// Retrieve all of the globals that will be mapped to members.
// FIXME: Since we don't represent Clang submodules as Swift
@@ -2462,21 +2471,33 @@
llvm::SmallPtrSet<ExtensionDecl *, 8> knownExtensions;
for (auto entry : lookupTable->allGlobalsAsMembers()) {
auto decl = entry.get<clang::NamedDecl *>();
- auto importedDecl =
- owner.importDecl(decl, owner.CurrentVersion);
+ auto importedDecl = owner.importDecl(decl, owner.CurrentVersion);
if (!importedDecl) continue;
// Find the enclosing extension, if there is one.
- ExtensionDecl *ext = nullptr;
- for (auto importedDC = importedDecl->getDeclContext();
- !importedDC->isModuleContext();
- importedDC = importedDC->getParent()) {
- ext = dyn_cast<ExtensionDecl>(importedDC);
- if (ext) break;
- }
- if (!ext) continue;
+ ExtensionDecl *ext = findEnclosingExtension(importedDecl);
+ if (ext && knownExtensions.insert(ext).second)
+ results.push_back(ext);
- if (knownExtensions.insert(ext).second)
+ // If this is a compatibility typealias, the canonical type declaration
+ // may exist in another extension.
+ auto alias = dyn_cast<TypeAliasDecl>(importedDecl);
+ if (!alias || !alias->isCompatibilityAlias()) continue;
+
+ auto aliasedTy = alias->getUnderlyingTypeLoc().getType();
+ ext = nullptr;
+ importedDecl = nullptr;
+
+ // Note: We can't use getAnyGeneric() here because `aliasedTy`
+ // might be typealias.
+ if (auto Ty = dyn_cast<NameAliasType>(aliasedTy.getPointer()))
+ importedDecl = Ty->getDecl();
+ else if (auto Ty = dyn_cast<AnyGenericType>(aliasedTy.getPointer()))
+ importedDecl = Ty->getDecl();
+ if (!importedDecl) continue;
+
+ ext = findEnclosingExtension(importedDecl);
+ if (ext && knownExtensions.insert(ext).second)
results.push_back(ext);
}
}
diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp
index 2c688e7..3071be1 100644
--- a/lib/ClangImporter/ImportDecl.cpp
+++ b/lib/ClangImporter/ImportDecl.cpp
@@ -386,35 +386,6 @@
return true;
}
-void ClangImporter::Implementation::forEachDistinctName(
- const clang::NamedDecl *decl,
- llvm::function_ref<bool(ImportedName, ImportNameVersion)> action) {
- using ImportNameKey = std::pair<DeclName, EffectiveClangContext>;
- SmallVector<ImportNameKey, 8> seenNames;
-
- ImportedName newName = importFullName(decl, CurrentVersion);
- ImportNameKey key(newName, newName.getEffectiveContext());
- if (action(newName, CurrentVersion))
- seenNames.push_back(key);
-
- CurrentVersion.forEachOtherImportNameVersion(
- [&](ImportNameVersion nameVersion) {
- // Check to see if the name is different.
- ImportedName newName = importFullName(decl, nameVersion);
- ImportNameKey key(newName, newName.getEffectiveContext());
- bool seen = llvm::any_of(seenNames,
- [&key](const ImportNameKey &existing) -> bool {
- if (key.first != existing.first)
- return false;
- return key.second.equalsWithoutResolving(existing.second);
- });
- if (seen)
- return;
- if (action(newName, nameVersion))
- seenNames.push_back(key);
- });
-}
-
// Build the init(rawValue:) initializer for an imported NS_ENUM.
// enum NSSomeEnum: RawType {
// init?(rawValue: RawType) {
@@ -2175,7 +2146,9 @@
if (canonicalVersion != getActiveSwiftVersion()) {
auto activeName = Impl.importFullName(D, getActiveSwiftVersion());
if (activeName &&
- activeName.getDeclName() == canonicalName.getDeclName()) {
+ activeName.getDeclName() == canonicalName.getDeclName() &&
+ activeName.getEffectiveContext().equalsWithoutResolving(
+ canonicalName.getEffectiveContext())) {
return ImportedName();
}
}
@@ -2192,7 +2165,9 @@
if (!alternateName)
return ImportedName();
- if (alternateName.getDeclName() == canonicalName.getDeclName()) {
+ if (alternateName.getDeclName() == canonicalName.getDeclName() &&
+ alternateName.getEffectiveContext().equalsWithoutResolving(
+ canonicalName.getEffectiveContext())) {
if (getVersion() == getActiveSwiftVersion()) {
assert(canonicalVersion != getActiveSwiftVersion());
return alternateName;
diff --git a/lib/ClangImporter/ImportName.cpp b/lib/ClangImporter/ImportName.cpp
index 8fcb6eb..3712dd9 100644
--- a/lib/ClangImporter/ImportName.cpp
+++ b/lib/ClangImporter/ImportName.cpp
@@ -1779,6 +1779,40 @@
return res;
}
+bool NameImporter::forEachDistinctImportName(
+ const clang::NamedDecl *decl, ImportNameVersion activeVersion,
+ llvm::function_ref<bool(ImportedName, ImportNameVersion)> action) {
+ using ImportNameKey = std::pair<DeclName, EffectiveClangContext>;
+ SmallVector<ImportNameKey, 8> seenNames;
+
+ ImportedName newName = importName(decl, activeVersion);
+ if (!newName)
+ return true;
+ ImportNameKey key(newName.getDeclName(), newName.getEffectiveContext());
+ if (action(newName, activeVersion))
+ seenNames.push_back(key);
+
+ activeVersion.forEachOtherImportNameVersion(
+ [&](ImportNameVersion nameVersion) {
+ // Check to see if the name is different.
+ ImportedName newName = importName(decl, nameVersion);
+ if (!newName)
+ return;
+ ImportNameKey key(newName.getDeclName(), newName.getEffectiveContext());
+
+ bool seen = llvm::any_of(
+ seenNames, [&key](const ImportNameKey &existing) -> bool {
+ return key.first == existing.first &&
+ key.second.equalsWithoutResolving(existing.second);
+ });
+ if (seen)
+ return;
+ if (action(newName, nameVersion))
+ seenNames.push_back(key);
+ });
+ return false;
+}
+
const InheritedNameSet *NameImporter::getAllPropertyNames(
clang::ObjCInterfaceDecl *classDecl,
bool forInstance) {
@@ -1846,4 +1880,3 @@
return known->second.get();
}
-
diff --git a/lib/ClangImporter/ImportName.h b/lib/ClangImporter/ImportName.h
index dc67c5c..c16b069 100644
--- a/lib/ClangImporter/ImportName.h
+++ b/lib/ClangImporter/ImportName.h
@@ -334,6 +334,28 @@
clang::DeclarationName preferredName =
clang::DeclarationName());
+ /// Attempts to import the name of \p decl with each possible
+ /// ImportNameVersion. \p action will be called with each unique name.
+ ///
+ /// In this case, "unique" means either the full name is distinct or the
+ /// effective context is distinct. This method does not attempt to handle
+ /// "unresolved" contexts in any special way---if one name references a
+ /// particular Clang declaration and the other has an unresolved context that
+ /// will eventually reference that declaration, the contexts will still be
+ /// considered distinct.
+ ///
+ /// If \p action returns false, the current name will \e not be added to the
+ /// set of seen names.
+ ///
+ /// The active name for \p activeVerion is always first, followed by the
+ /// other names in the order of
+ /// ImportNameVersion::forEachOtherImportNameVersion.
+ ///
+ /// Returns \c true if it fails to import name for the active version.
+ bool forEachDistinctImportName(
+ const clang::NamedDecl *decl, ImportNameVersion activeVersion,
+ llvm::function_ref<bool(ImportedName, ImportNameVersion)> action);
+
/// Imports the name of the given Clang macro into Swift.
Identifier importMacroName(const clang::IdentifierInfo *clangIdentifier,
const clang::MacroInfo *macro);
diff --git a/lib/ClangImporter/ImporterImpl.h b/lib/ClangImporter/ImporterImpl.h
index bdd0983..d42fb88 100644
--- a/lib/ClangImporter/ImporterImpl.h
+++ b/lib/ClangImporter/ImporterImpl.h
@@ -1352,7 +1352,9 @@
void forEachDistinctName(
const clang::NamedDecl *decl,
llvm::function_ref<bool(importer::ImportedName,
- importer::ImportNameVersion)> action);
+ importer::ImportNameVersion)> action) {
+ getNameImporter().forEachDistinctImportName(decl, CurrentVersion, action);
+ }
/// Dump the Swift-specific name lookup tables we generate.
void dumpSwiftLookupTables();
diff --git a/lib/ClangImporter/SwiftLookupTable.cpp b/lib/ClangImporter/SwiftLookupTable.cpp
index ee59dfd..fa4e0a0 100644
--- a/lib/ClangImporter/SwiftLookupTable.cpp
+++ b/lib/ClangImporter/SwiftLookupTable.cpp
@@ -1633,37 +1633,30 @@
// If we have a name to import as, add this entry to the table.
auto currentVersion =
ImportNameVersion::fromOptions(nameImporter.getLangOpts());
- if (auto importedName = nameImporter.importName(named, currentVersion)) {
- SmallPtrSet<DeclName, 8> distinctNames;
- distinctNames.insert(importedName.getDeclName());
- table.addEntry(importedName.getDeclName(), named,
- importedName.getEffectiveContext());
+ auto failed = nameImporter.forEachDistinctImportName(
+ named, currentVersion,
+ [&](ImportedName importedName, ImportNameVersion version) {
+ table.addEntry(importedName.getDeclName(), named,
+ importedName.getEffectiveContext());
- // Also add the subscript entry, if needed.
- if (importedName.isSubscriptAccessor())
- table.addEntry(DeclName(nameImporter.getContext(),
- DeclBaseName::createSubscript(),
- ArrayRef<Identifier>()),
- named, importedName.getEffectiveContext());
+ // Also add the subscript entry, if needed.
+ if (version == currentVersion && importedName.isSubscriptAccessor()) {
+ table.addEntry(DeclName(nameImporter.getContext(),
+ DeclBaseName::createSubscript(),
+ {Identifier()}),
+ named, importedName.getEffectiveContext());
+ }
- currentVersion.forEachOtherImportNameVersion(
- [&](ImportNameVersion alternateVersion) {
- auto alternateName = nameImporter.importName(named, alternateVersion);
- if (!alternateName)
+ return true;
+ });
+ if (failed) {
+ if (auto category = dyn_cast<clang::ObjCCategoryDecl>(named)) {
+ // If the category is invalid, don't add it.
+ if (category->isInvalidDecl())
return;
- // FIXME: What if the DeclNames are the same but the contexts are
- // different?
- if (distinctNames.insert(alternateName.getDeclName()).second) {
- table.addEntry(alternateName.getDeclName(), named,
- alternateName.getEffectiveContext());
- }
- });
- } else if (auto category = dyn_cast<clang::ObjCCategoryDecl>(named)) {
- // If the category is invalid, don't add it.
- if (category->isInvalidDecl())
- return;
- table.addCategory(category);
+ table.addCategory(category);
+ }
}
// Walk the members of any context that can have nested members.
@@ -1864,4 +1857,3 @@
// Return the new reader.
return std::move(tableReader);
}
-
diff --git a/lib/IDE/TypeReconstruction.cpp b/lib/IDE/TypeReconstruction.cpp
index 97c4343..03eaa60 100644
--- a/lib/IDE/TypeReconstruction.cpp
+++ b/lib/IDE/TypeReconstruction.cpp
@@ -668,9 +668,10 @@
return DeclKind::Enum;
case Demangle::Node::Kind::Protocol:
return DeclKind::Protocol;
+ case Demangle::Node::Kind::Variable:
+ return DeclKind::Var;
default:
llvm_unreachable("Missing alias");
- // FIXME: can we 'log' getNodeKindString(node_kind))
}
}
diff --git a/lib/IRGen/GenProto.cpp b/lib/IRGen/GenProto.cpp
index 8b0561a..496e8a7 100644
--- a/lib/IRGen/GenProto.cpp
+++ b/lib/IRGen/GenProto.cpp
@@ -2855,7 +2855,7 @@
}
static CanType getSubstSelfType(CanSILFunctionType origFnType,
- const SubstitutionMap &subs) {
+ SubstitutionMap subs) {
// Grab the apparent 'self' type. If there isn't a 'self' type,
// we're not going to try to access this anyway.
assert(!origFnType->getParameters().empty());
@@ -2896,11 +2896,11 @@
CanSILFunctionType polyFn)
: PolymorphicConvention(IGF.IGM, polyFn), IGF(IGF) {}
- void emit(const SubstitutionMap &subs,
+ void emit(SubstitutionMap subs,
WitnessMetadata *witnessMetadata, Explosion &out);
private:
- void emitEarlySources(const SubstitutionMap &subs, Explosion &out) {
+ void emitEarlySources(SubstitutionMap subs, Explosion &out) {
for (auto &source : getSources()) {
switch (source.getKind()) {
// Already accounted for in the parameters.
@@ -2929,13 +2929,13 @@
/// Pass all the arguments necessary for the given function.
void irgen::emitPolymorphicArguments(IRGenFunction &IGF,
CanSILFunctionType origFnType,
- const SubstitutionMap &subs,
+ SubstitutionMap subs,
WitnessMetadata *witnessMetadata,
Explosion &out) {
EmitPolymorphicArguments(IGF, origFnType).emit(subs, witnessMetadata, out);
}
-void EmitPolymorphicArguments::emit(const SubstitutionMap &subs,
+void EmitPolymorphicArguments::emit(SubstitutionMap subs,
WitnessMetadata *witnessMetadata,
Explosion &out) {
// Add all the early sources.
@@ -2980,7 +2980,7 @@
NecessaryBindings
NecessaryBindings::forFunctionInvocations(IRGenModule &IGM,
CanSILFunctionType origType,
- const SubstitutionMap &subs) {
+ SubstitutionMap subs) {
NecessaryBindings bindings;
// Bail out early if we don't have polymorphic parameters.
@@ -3066,7 +3066,7 @@
void
GenericTypeRequirements::enumerateFulfillments(IRGenModule &IGM,
- const SubstitutionMap &subs,
+ SubstitutionMap subs,
FulfillmentCallback callback) {
if (empty()) return;
@@ -3084,7 +3084,7 @@
}
void GenericTypeRequirements::emitInitOfBuffer(IRGenFunction &IGF,
- const SubstitutionMap &subs,
+ SubstitutionMap subs,
Address buffer) {
if (Requirements.empty()) return;
@@ -3128,7 +3128,7 @@
CanGenericSignature generics,
ModuleDecl &module,
GenericRequirement requirement,
- const SubstitutionMap &subs) {
+ SubstitutionMap subs) {
CanType depTy = requirement.TypeParameter;
CanType argType = depTy.subst(subs)->getCanonicalType();
diff --git a/lib/IRGen/GenProto.h b/lib/IRGen/GenProto.h
index ed6cf2a..69dfee8 100644
--- a/lib/IRGen/GenProto.h
+++ b/lib/IRGen/GenProto.h
@@ -139,7 +139,7 @@
/// generics clause.
void emitPolymorphicArguments(IRGenFunction &IGF,
CanSILFunctionType origType,
- const SubstitutionMap &subs,
+ SubstitutionMap subs,
WitnessMetadata *witnessMetadata,
Explosion &args);
diff --git a/lib/IRGen/GenericRequirement.h b/lib/IRGen/GenericRequirement.h
index 42c8ed4..6805794 100644
--- a/lib/IRGen/GenericRequirement.h
+++ b/lib/IRGen/GenericRequirement.h
@@ -62,7 +62,7 @@
CanGenericSignature signature,
ModuleDecl &module,
GenericRequirement requirement,
- const SubstitutionMap &subs);
+ SubstitutionMap subs);
using EmitGenericRequirementFn =
llvm::function_ref<llvm::Value*(GenericRequirement reqt)>;
@@ -141,10 +141,10 @@
llvm::function_ref<void(unsigned requirementIndex,
CanType type,
Optional<ProtocolConformanceRef> conf)>;
- void enumerateFulfillments(IRGenModule &IGM, const SubstitutionMap &subs,
+ void enumerateFulfillments(IRGenModule &IGM, SubstitutionMap subs,
FulfillmentCallback callback);
- void emitInitOfBuffer(IRGenFunction &IGF, const SubstitutionMap &subs,
+ void emitInitOfBuffer(IRGenFunction &IGF, SubstitutionMap subs,
Address buffer);
void bindFromBuffer(IRGenFunction &IGF, Address buffer, MetadataState state,
diff --git a/lib/IRGen/NecessaryBindings.h b/lib/IRGen/NecessaryBindings.h
index d1c9e3c..a7a65ff 100644
--- a/lib/IRGen/NecessaryBindings.h
+++ b/lib/IRGen/NecessaryBindings.h
@@ -49,7 +49,7 @@
/// signature.
static NecessaryBindings forFunctionInvocations(IRGenModule &IGM,
CanSILFunctionType origType,
- const SubstitutionMap &subs);
+ SubstitutionMap subs);
/// Add whatever information is necessary to reconstruct type metadata
/// for the given type.
diff --git a/lib/Markup/LineList.cpp b/lib/Markup/LineList.cpp
index 00b5de9..0afeb5e 100644
--- a/lib/Markup/LineList.cpp
+++ b/lib/Markup/LineList.cpp
@@ -25,7 +25,7 @@
return "";
auto FirstLine = Lines.begin();
- while (FirstLine->Text.empty() && FirstLine != Lines.end())
+ while (FirstLine != Lines.end() && FirstLine->Text.empty())
++FirstLine;
if (FirstLine == Lines.end())
diff --git a/lib/Migrator/APIDiffMigratorPass.cpp b/lib/Migrator/APIDiffMigratorPass.cpp
index 957ee92..b23b46d 100644
--- a/lib/Migrator/APIDiffMigratorPass.cpp
+++ b/lib/Migrator/APIDiffMigratorPass.cpp
@@ -260,6 +260,21 @@
SF->getASTContext().SourceMgr, Range).str() == "nil";
}
+ bool isDotMember(CharSourceRange Range) {
+ auto S = Range.str();
+ return S.startswith(".") && S.substr(1).find(".") == StringRef::npos;
+ }
+
+ bool isDotMember(SourceRange Range) {
+ return isDotMember(Lexer::getCharSourceRangeFromSourceRange(
+ SF->getASTContext().SourceMgr, Range));
+ }
+
+ bool isDotMember(Expr *E) {
+ auto Range = E->getSourceRange();
+ return Range.isValid() && isDotMember(Range);
+ }
+
std::vector<APIDiffItem*> getRelatedDiffItems(ValueDecl *VD) {
std::vector<APIDiffItem*> results;
auto addDiffItems = [&](ValueDecl *VD) {
@@ -308,11 +323,11 @@
}
- bool isSimpleReplacement(APIDiffItem *Item, std::string &Text) {
+ bool isSimpleReplacement(APIDiffItem *Item, bool isDotMember, std::string &Text) {
if (auto *MD = dyn_cast<TypeMemberDiffItem>(Item)) {
if (MD->Subkind == TypeMemberDiffItemSubKind::SimpleReplacement) {
- Text = (llvm::Twine(MD->newTypeName) + "." + MD->getNewName().base()).
- str();
+ Text = (llvm::Twine(isDotMember ? "" : MD->newTypeName) + "." +
+ MD->getNewName().base()).str();
return true;
}
}
@@ -375,7 +390,7 @@
Type T, ReferenceMetaData Data) override {
for (auto *Item: getRelatedDiffItems(CtorTyRef ? CtorTyRef: D)) {
std::string RepText;
- if (isSimpleReplacement(Item, RepText)) {
+ if (isSimpleReplacement(Item, isDotMember(Range), RepText)) {
Editor.replace(Range, RepText);
return true;
}
@@ -450,8 +465,9 @@
for (auto *I: getRelatedDiffItems(VD)) {
if (auto *Item = dyn_cast<TypeMemberDiffItem>(I)) {
if (Item->Subkind == TypeMemberDiffItemSubKind::QualifiedReplacement) {
- Editor.replace(ToReplace, (llvm::Twine(Item->newTypeName) + "." +
- Item->getNewName().base()).str());
+ Editor.replace(ToReplace,
+ (llvm::Twine(isDotMember(ToReplace) ? "" : Item->newTypeName) + "." +
+ Item->getNewName().base()).str());
return true;
}
}
@@ -725,7 +741,7 @@
StringRef LeftComment;
StringRef RightComment;
for (auto *Item: getRelatedDiffItems(RD)) {
- if (isSimpleReplacement(Item, Rename)) {
+ if (isSimpleReplacement(Item, isDotMember(Reference), Rename)) {
} else if (auto *CI = dyn_cast<CommonDiffItem>(Item)) {
if (CI->isStringRepresentableChange() &&
CI->NodeKind == SDKNodeKind::DeclVar) {
diff --git a/lib/ParseSIL/ParseSIL.cpp b/lib/ParseSIL/ParseSIL.cpp
index 7760c83..368ade5 100644
--- a/lib/ParseSIL/ParseSIL.cpp
+++ b/lib/ParseSIL/ParseSIL.cpp
@@ -1604,17 +1604,16 @@
return parses[index].replacement;
},
[&](CanType dependentType, Type replacementType,
- ProtocolType *protoTy) ->Optional<ProtocolConformanceRef> {
+ ProtocolDecl *proto) ->Optional<ProtocolConformanceRef> {
auto M = SP.P.SF.getParentModule();
- auto conformance = M->lookupConformance(replacementType,
- protoTy->getDecl());
+ auto conformance = M->lookupConformance(replacementType, proto);
if (conformance) return conformance;
SP.P.diagnose(loc, diag::sil_substitution_mismatch, replacementType,
- protoTy);
+ proto->getDeclaredType());
failed = true;
- return ProtocolConformanceRef(protoTy->getDecl());
+ return ProtocolConformanceRef(proto);
});
return failed ? SubstitutionMap() : subMap;
diff --git a/lib/SIL/Linker.cpp b/lib/SIL/Linker.cpp
index c75498f..9d51f75 100644
--- a/lib/SIL/Linker.cpp
+++ b/lib/SIL/Linker.cpp
@@ -283,7 +283,7 @@
}
}
-void SILLinkerVisitor::visitApplySubstitutions(const SubstitutionMap &subs) {
+void SILLinkerVisitor::visitApplySubstitutions(SubstitutionMap subs) {
for (auto &reqt : subs.getGenericSignature()->getRequirements()) {
switch (reqt.getKind()) {
case RequirementKind::Conformance: {
diff --git a/lib/SIL/Linker.h b/lib/SIL/Linker.h
index a04c0f6..093578e 100644
--- a/lib/SIL/Linker.h
+++ b/lib/SIL/Linker.h
@@ -68,7 +68,7 @@
void visitFunctionRefInst(FunctionRefInst *FRI);
void visitProtocolConformance(ProtocolConformanceRef C,
const Optional<SILDeclRef> &Member);
- void visitApplySubstitutions(const SubstitutionMap &subs);
+ void visitApplySubstitutions(SubstitutionMap subs);
void visitWitnessMethodInst(WitnessMethodInst *WMI) {
visitProtocolConformance(WMI->getConformance(), WMI->getMember());
}
diff --git a/lib/SIL/SILFunctionType.cpp b/lib/SIL/SILFunctionType.cpp
index 6857a38..75d7819 100644
--- a/lib/SIL/SILFunctionType.cpp
+++ b/lib/SIL/SILFunctionType.cpp
@@ -24,7 +24,6 @@
#include "swift/AST/GenericEnvironment.h"
#include "swift/AST/Module.h"
#include "swift/AST/ProtocolConformance.h"
-#include "swift/Basic/StringExtras.h"
#include "swift/SIL/SILModule.h"
#include "swift/SIL/SILType.h"
#include "clang/AST/Attr.h"
@@ -1742,12 +1741,23 @@
StringRef text = name.get();
while (!text.empty() && text[0] == '_') text = text.substr(1);
- StringRef firstWord = camel_case::getFirstWord(text);
+ // Does the given selector start with the given string as a prefix, in the
+ // sense of the selector naming conventions?
+ // This implementation matches the one used by
+ // clang::Selector::getMethodFamily, to make sure we behave the same as Clang
+ // ARC. We're not just calling that method here because it means allocating a
+ // clang::IdentifierInfo, which requires a Clang ASTContext.
+ auto hasPrefix = [](StringRef text, StringRef prefix) {
+ if (!text.startswith(prefix)) return false;
+ if (text.size() == prefix.size()) return true;
+ assert(text.size() > prefix.size());
+ return !clang::isLowercase(text[prefix.size()]);
+ };
auto result = SelectorFamily::None;
if (false) /*for #define purposes*/;
#define CHECK_PREFIX(LABEL, PREFIX) \
- else if (firstWord == PREFIX) result = SelectorFamily::LABEL;
+ else if (hasPrefix(text, PREFIX)) result = SelectorFamily::LABEL;
FOREACH_FAMILY(CHECK_PREFIX)
#undef CHECK_PREFIX
@@ -2450,7 +2460,7 @@
return STST.subst(*this);
}
-SILType SILType::subst(SILModule &silModule, const SubstitutionMap &subs) const{
+SILType SILType::subst(SILModule &silModule, SubstitutionMap subs) const{
return subst(silModule,
QuerySubstitutionMap{subs},
LookUpConformanceInSubstitutionMap(subs));
@@ -2461,7 +2471,7 @@
/// type, except using the original conventions.
CanSILFunctionType
SILFunctionType::substGenericArgs(SILModule &silModule,
- const SubstitutionMap &subs) {
+ SubstitutionMap subs) {
if (!isPolymorphic()) {
return CanSILFunctionType(this);
}
diff --git a/lib/SIL/SILProfiler.cpp b/lib/SIL/SILProfiler.cpp
index d00e165..1509b15 100644
--- a/lib/SIL/SILProfiler.cpp
+++ b/lib/SIL/SILProfiler.cpp
@@ -27,6 +27,8 @@
#include <forward_list>
+#define DEBUG_TYPE "SILProfiler"
+
using namespace swift;
/// Check if a closure has a body.
@@ -198,15 +200,30 @@
MapRegionCounters(llvm::DenseMap<ASTNode, unsigned> &CounterMap)
: CounterMap(CounterMap) {}
+ void mapRegion(ASTNode N) {
+ CounterMap[N] = NextCounter;
+
+ DEBUG({
+ llvm::dbgs() << "Assigned counter #" << NextCounter << " to: ";
+ auto *E = N.dyn_cast<Expr *>();
+ if (E)
+ llvm::dbgs() << Expr::getKindName(E->getKind()) << "\n";
+ auto *S = N.dyn_cast<Stmt *>();
+ if (S)
+ llvm::dbgs() << Stmt::getKindName(S->getKind()) << "\n";
+ });
+
+ ++NextCounter;
+ }
+
bool walkToDeclPre(Decl *D) override {
if (isUnmapped(D))
return false;
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(D)) {
- return visitFunctionDecl(
- *this, AFD, [&] { CounterMap[AFD->getBody()] = NextCounter++; });
+ return visitFunctionDecl(*this, AFD, [&] { mapRegion(AFD->getBody()); });
} else if (auto *TLCD = dyn_cast<TopLevelCodeDecl>(D)) {
- CounterMap[TLCD->getBody()] = NextCounter++;
+ mapRegion(TLCD->getBody());
} else if (auto *NTD = dyn_cast<NominalTypeDecl>(D)) {
return visitNominalTypeDecl(*this, NTD,
[&] { WithinNominalType = true; });
@@ -216,34 +233,31 @@
std::pair<bool, Stmt *> walkToStmtPre(Stmt *S) override {
if (auto *IS = dyn_cast<IfStmt>(S)) {
- CounterMap[IS->getThenStmt()] = NextCounter++;
+ mapRegion(IS->getThenStmt());
} else if (auto *US = dyn_cast<GuardStmt>(S)) {
- CounterMap[US->getBody()] = NextCounter++;
+ mapRegion(US->getBody());
} else if (auto *WS = dyn_cast<WhileStmt>(S)) {
- CounterMap[WS->getBody()] = NextCounter++;
+ mapRegion(WS->getBody());
} else if (auto *RWS = dyn_cast<RepeatWhileStmt>(S)) {
- CounterMap[RWS->getBody()] = NextCounter++;
+ mapRegion(RWS->getBody());
} else if (auto *FES = dyn_cast<ForEachStmt>(S)) {
- CounterMap[FES->getBody()] = NextCounter++;
+ mapRegion(FES->getBody());
walkPatternForProfiling(FES->getIterator(), *this);
} else if (auto *SS = dyn_cast<SwitchStmt>(S)) {
- CounterMap[SS] = NextCounter++;
+ mapRegion(SS);
} else if (auto *CS = dyn_cast<CaseStmt>(S)) {
- CounterMap[CS] = NextCounter++;
- } else if (auto *DCS = dyn_cast<DoCatchStmt>(S)) {
- CounterMap[DCS] = NextCounter++;
+ mapRegion(CS);
} else if (auto *CS = dyn_cast<CatchStmt>(S)) {
- CounterMap[CS->getBody()] = NextCounter++;
+ mapRegion(CS->getBody());
}
return {true, S};
}
std::pair<bool, Expr *> walkToExprPre(Expr *E) override {
if (auto *IE = dyn_cast<IfExpr>(E)) {
- CounterMap[IE->getThenExpr()] = NextCounter++;
+ mapRegion(IE->getThenExpr());
} else if (auto *ACE = dyn_cast<AbstractClosureExpr>(E)) {
- return visitClosureExpr(*this, ACE,
- [&] { CounterMap[ACE] = NextCounter++; });
+ return visitClosureExpr(*this, ACE, [&] { mapRegion(ACE); });
}
return {true, E};
}
@@ -327,6 +341,33 @@
llvm_unreachable("Unhandled Kind in switch.");
}
+
+ void print(raw_ostream &OS) const {
+ switch (K) {
+ case Kind::Zero:
+ OS << "zero";
+ return;
+ case Kind::Node:
+ OS << "node(" << Node.getOpaqueValue() << ")";
+ return;
+ case Kind::Add:
+ case Kind::Sub:
+ LHS->print(OS);
+ OS << ' ' << ((K == Kind::Add) ? '+' : '-') << ' ';
+ RHS->print(OS);
+ return;
+ case Kind::Ref:
+ OS << "ref(";
+ LHS->print(OS);
+ OS << ")";
+ return;
+ }
+ llvm_unreachable("Unhandled Kind in switch.");
+ }
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+ LLVM_DUMP_METHOD void dump() const { print(llvm::errs()); }
+#endif
};
/// \brief A region of source code that can be mapped to a counter.
@@ -522,10 +563,6 @@
CounterMap[CS] = NextCounter++;
auto csCount = loadExecutionCount(CS);
LoadedCounterMap[CS] = csCount;
- } else if (auto *DCS = dyn_cast<DoCatchStmt>(S)) {
- CounterMap[DCS] = NextCounter++;
- auto dcsCount = loadExecutionCount(DCS);
- LoadedCounterMap[DCS] = dcsCount;
} else if (auto *CS = dyn_cast<CatchStmt>(S)) {
auto csBody = CS->getBody();
CounterMap[csBody] = NextCounter++;
@@ -587,6 +624,9 @@
/// \brief A stack of active repeat-while loops.
std::vector<RepeatWhileStmt *> RepeatWhileStack;
+ /// \brief A stack of active do-catch statements.
+ std::vector<DoCatchStmt *> DoCatchStack;
+
CounterExpr *ExitCounter = nullptr;
Stmt *ImplicitTopLevelBody = nullptr;
@@ -872,10 +912,16 @@
assignCounter(DS);
} else if (auto *DCS = dyn_cast<DoCatchStmt>(S)) {
+ // The do-catch body is visited the same number of times as its parent.
assignCounter(DCS->getBody(), CounterExpr::Ref(getCurrentCounter()));
- assignCounter(DCS);
+
+ // Initialize the exit count of the do-catch to the entry count, then
+ // subtract off non-local exits as they are visited.
+ assignCounter(DCS, CounterExpr::Ref(getCurrentCounter()));
+ DoCatchStack.push_back(DCS);
} else if (auto *CS = dyn_cast<CatchStmt>(S)) {
+ assert(DoCatchStack.size() && "catch stmt with no parent");
assignCounter(CS->getBody());
}
return {true, S};
@@ -914,11 +960,17 @@
} else if (auto *BS = dyn_cast<BreakStmt>(S)) {
// When we break from a loop, we need to adjust the exit count.
- if (auto *RWS = dyn_cast<RepeatWhileStmt>(BS->getTarget())) {
+ Stmt *BreakTarget = BS->getTarget();
+ if (auto *RWS = dyn_cast<RepeatWhileStmt>(BreakTarget)) {
subtractFromCounter(RWS->getCond(), getCurrentCounter());
- } else if (!isa<SwitchStmt>(BS->getTarget())) {
+ } else if (!isa<SwitchStmt>(BreakTarget)) {
addToCounter(BS->getTarget(), getCurrentCounter());
}
+
+ // The break also affects the exit counts of active do-catch statements.
+ for (auto *DCS : DoCatchStack)
+ subtractFromCounter(DCS, getCurrentCounter());
+
terminateRegion(S);
} else if (auto *FS = dyn_cast<FallthroughStmt>(S)) {
@@ -931,13 +983,23 @@
} else if (isa<CaseStmt>(S)) {
popRegions(S);
- } else if (isa<DoCatchStmt>(S)) {
+ } else if (auto *DCS = dyn_cast<DoCatchStmt>(S)) {
+ assert(DoCatchStack.back() == DCS && "Malformed do-catch stack");
+ DoCatchStack.pop_back();
replaceCount(CounterExpr::Ref(getCounter(S)), getEndLoc(S));
+ } else if (isa<CatchStmt>(S)) {
+ assert(DoCatchStack.size() && "catch stmt with no parent");
+
} else if (isa<ReturnStmt>(S) || isa<FailStmt>(S) || isa<ThrowStmt>(S)) {
- // When we return, we may need to adjust some loop condition counts.
- for (auto *RWS : RepeatWhileStack)
- subtractFromCounter(RWS->getCond(), getCurrentCounter());
+ // When we return, adjust loop condition counts and do-catch exit counts
+ // to reflect the early exit.
+ if (isa<ReturnStmt>(S) || isa<FailStmt>(S)) {
+ for (auto *RWS : RepeatWhileStack)
+ subtractFromCounter(RWS->getCond(), getCurrentCounter());
+ for (auto *DCS : DoCatchStack)
+ subtractFromCounter(DCS, getCurrentCounter());
+ }
terminateRegion(S);
}
@@ -1030,6 +1092,7 @@
CurrentFuncName, getEquivalentPGOLinkage(CurrentFuncLinkage),
CurrentFileName);
+ DEBUG(llvm::dbgs() << "Assigning counters to: " << CurrentFuncName << "\n");
Root.walk(Mapper);
NumRegionCounters = Mapper.NextCounter;
diff --git a/lib/SIL/SILType.cpp b/lib/SIL/SILType.cpp
index 1a4ba44..1a9cf83 100644
--- a/lib/SIL/SILType.cpp
+++ b/lib/SIL/SILType.cpp
@@ -179,7 +179,7 @@
}
SILType SILType::substGenericArgs(SILModule &M,
- const SubstitutionMap &SubMap) const {
+ SubstitutionMap SubMap) const {
auto fnTy = castTo<SILFunctionType>();
auto canFnTy = CanSILFunctionType(fnTy->substGenericArgs(M, SubMap));
return SILType::getPrimitiveObjectType(canFnTy);
diff --git a/lib/SIL/TypeLowering.cpp b/lib/SIL/TypeLowering.cpp
index 6b9bcd3..fe78eed 100644
--- a/lib/SIL/TypeLowering.cpp
+++ b/lib/SIL/TypeLowering.cpp
@@ -2390,9 +2390,9 @@
[&](SubstitutableType *type) -> Type {
return signature->getCanonicalTypeInContext(type);
},
- [](Type depTy, Type replacementTy, ProtocolType *conformedTy)
+ [](Type depTy, Type replacementTy, ProtocolDecl *proto)
-> ProtocolConformanceRef {
- return ProtocolConformanceRef(conformedTy->getDecl());
+ return ProtocolConformanceRef(proto);
});
auto boxTy = SILBoxType::get(C, layout, subMap);
diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp
index f690664..039fd16 100644
--- a/lib/SILGen/SILGenApply.cpp
+++ b/lib/SILGen/SILGenApply.cpp
@@ -1677,477 +1677,7 @@
Expr *getExpr() const { return ExprAndIsIndirect.getPointer(); }
bool isIndirect() const { return ExprAndIsIndirect.getInt(); }
};
-
-/// A delayed argument. Call arguments are evaluated in two phases:
-/// a formal evaluation phase and a formal access phase. The primary
-/// example of this is an l-value that is passed by reference, where
-/// the access to the l-value does not begin until the formal access
-/// phase, but there are other examples, generally relating to pointer
-/// conversions.
-///
-/// A DelayedArgument represents the part of evaluating an argument
-/// that's been delayed until the formal access phase.
-class DelayedArgument {
-public:
- enum KindTy {
- /// This is a true inout argument.
- InOut,
-
- /// This is a borrowed direct argument.
- BorrowDirect,
-
- /// This is a borrowed indirect argument.
- BorrowIndirect,
-
- LastLVKindWithoutExtra = BorrowIndirect,
-
- /// The l-value needs to be converted to a pointer type.
- LValueToPointer,
-
- /// An array l-value needs to be converted to a pointer type.
- LValueArrayToPointer,
-
- LastLVKind = LValueArrayToPointer,
-
- /// An array r-value needs to be converted to a pointer type.
- RValueArrayToPointer,
-
- /// A string r-value needs to be converted to a pointer type.
- RValueStringToPointer,
- };
-
-private:
- KindTy Kind;
-
- struct LValueStorage {
- LValue LV;
- SILLocation Loc;
-
- LValueStorage(LValue &&lv, SILLocation loc) : LV(std::move(lv)), Loc(loc) {}
- };
- struct RValueStorage {
- ManagedValue RV;
-
- RValueStorage(ManagedValue rv) : RV(rv) {}
- };
-
- using ValueMembers = ExternalUnionMembers<RValueStorage, LValueStorage>;
- static ValueMembers::Index getValueMemberIndexForKind(KindTy kind) {
- return (kind <= LastLVKind ? ValueMembers::indexOf<LValueStorage>()
- : ValueMembers::indexOf<RValueStorage>());
- }
-
- /// Storage for either the l-value or the r-value.
- ExternalUnion<KindTy, ValueMembers, getValueMemberIndexForKind> Value;
-
- LValueStorage &LV() { return Value.get<LValueStorage>(Kind); }
- const LValueStorage &LV() const { return Value.get<LValueStorage>(Kind); }
- RValueStorage &RV() { return Value.get<RValueStorage>(Kind); }
- const RValueStorage &RV() const { return Value.get<RValueStorage>(Kind); }
-
- /// The original argument expression, which will be emitted down
- /// to the point from which the l-value or r-value was generated.
- OriginalArgument Original;
-
- using PointerAccessInfo = SILGenFunction::PointerAccessInfo;
- using ArrayAccessInfo = SILGenFunction::ArrayAccessInfo;
-
- using ExtraMembers =
- ExternalUnionMembers<void, ArrayAccessInfo, PointerAccessInfo>;
- static ExtraMembers::Index getExtraMemberIndexForKind(KindTy kind) {
- switch (kind) {
- case LValueToPointer:
- return ExtraMembers::indexOf<PointerAccessInfo>();
- case LValueArrayToPointer:
- case RValueArrayToPointer:
- return ExtraMembers::indexOf<ArrayAccessInfo>();
- default:
- return ExtraMembers::indexOf<void>();
- }
- }
-
- ExternalUnion<KindTy, ExtraMembers, getExtraMemberIndexForKind> Extra;
-
-public:
- DelayedArgument(KindTy kind, LValue &&lv, SILLocation loc)
- : Kind(kind) {
- assert(kind <= LastLVKindWithoutExtra &&
- "this constructor should only be used for simple l-value kinds");
- Value.emplace<LValueStorage>(Kind, std::move(lv), loc);
- }
-
- DelayedArgument(KindTy kind, ManagedValue rv, OriginalArgument original)
- : Kind(kind), Original(original) {
- Value.emplace<RValueStorage>(Kind, rv);
- }
-
- DelayedArgument(SILGenFunction::PointerAccessInfo pointerInfo,
- LValue &&lv, SILLocation loc, OriginalArgument original)
- : Kind(LValueToPointer), Original(original) {
- Value.emplace<LValueStorage>(Kind, std::move(lv), loc);
- Extra.emplace<PointerAccessInfo>(Kind, pointerInfo);
- }
-
- DelayedArgument(SILGenFunction::ArrayAccessInfo arrayInfo,
- LValue &&lv, SILLocation loc, OriginalArgument original)
- : Kind(LValueArrayToPointer), Original(original) {
- Value.emplace<LValueStorage>(Kind, std::move(lv), loc);
- Extra.emplace<ArrayAccessInfo>(Kind, arrayInfo);
- }
-
- DelayedArgument(KindTy kind,
- SILGenFunction::ArrayAccessInfo arrayInfo,
- ManagedValue rv, OriginalArgument original)
- : Kind(kind), Original(original) {
- Value.emplace<RValueStorage>(Kind, rv);
- Extra.emplace<ArrayAccessInfo>(Kind, arrayInfo);
- }
-
- DelayedArgument(DelayedArgument &&other)
- : Kind(other.Kind), Original(other.Original) {
- Value.moveConstruct(Kind, std::move(other.Value));
- Extra.moveConstruct(Kind, std::move(other.Extra));
- }
-
- DelayedArgument &operator=(DelayedArgument &&other) {
- Value.moveAssign(Kind, other.Kind, std::move(other.Value));
- Extra.moveAssign(Kind, other.Kind, std::move(other.Extra));
- Kind = other.Kind;
- Original = other.Original;
- return *this;
- }
-
- ~DelayedArgument() {
- Extra.destruct(Kind);
- Value.destruct(Kind);
- }
-
- bool isSimpleInOut() const { return Kind == InOut; }
- SILLocation getInOutLocation() const {
- assert(isSimpleInOut());
- return LV().Loc;
- }
-
- ManagedValue emit(SILGenFunction &SGF) {
- switch (Kind) {
- case InOut:
- return emitInOut(SGF);
- case BorrowDirect:
- return emitBorrowDirect(SGF);
- case BorrowIndirect:
- return emitBorrowIndirect(SGF);
- case LValueToPointer:
- case LValueArrayToPointer:
- case RValueArrayToPointer:
- case RValueStringToPointer:
- return finishOriginalArgument(SGF);
- }
- llvm_unreachable("bad kind");
- }
-
-private:
- ManagedValue emitInOut(SILGenFunction &SGF) {
- return emitAddress(SGF, AccessKind::ReadWrite);
- }
-
- ManagedValue emitBorrowIndirect(SILGenFunction &SGF) {
- return emitAddress(SGF, AccessKind::Read);
- }
-
- ManagedValue emitBorrowDirect(SILGenFunction &SGF) {
- ManagedValue address = emitAddress(SGF, AccessKind::Read);
- return SGF.B.createLoadBorrow(LV().Loc, address);
- }
-
- ManagedValue emitAddress(SILGenFunction &SGF, AccessKind accessKind) {
- auto tsanKind =
- (accessKind == AccessKind::Read ? TSanKind::None : TSanKind::InoutAccess);
- return SGF.emitAddressOfLValue(LV().Loc, std::move(LV().LV),
- accessKind, tsanKind);
- }
-
- /// Replay the original argument expression.
- ManagedValue finishOriginalArgument(SILGenFunction &SGF) {
- auto results = finishOriginalExpr(SGF, Original.getExpr());
- auto value = results.first; // just let the owner go
-
- if (Original.isIndirect() && !value.getType().isAddress()) {
- value = value.materialize(SGF, Original.getExpr());
- }
-
- return value;
- }
-
- // (value, owner)
- std::pair<ManagedValue, ManagedValue>
- finishOriginalExpr(SILGenFunction &SGF, Expr *expr) {
-
- // This needs to handle all of the recursive cases from
- // ArgEmission::maybeEmitDelayed.
-
- expr = expr->getSemanticsProvidingExpr();
-
- // Handle injections into optionals.
- if (auto inject = dyn_cast<InjectIntoOptionalExpr>(expr)) {
- auto ownedValue =
- finishOriginalExpr(SGF, inject->getSubExpr());
- auto &optionalTL = SGF.getTypeLowering(expr->getType());
-
- auto optValue = SGF.emitInjectOptional(inject, optionalTL, SGFContext(),
- [&](SGFContext ctx) { return ownedValue.first; });
- return {optValue, ownedValue.second};
- }
-
- // Handle try!.
- if (auto forceTry = dyn_cast<ForceTryExpr>(expr)) {
- // Handle throws from the accessor? But what if the writeback throws?
- SILGenFunction::ForceTryEmission emission(SGF, forceTry);
- return finishOriginalExpr(SGF, forceTry->getSubExpr());
- }
-
- // Handle optional evaluations.
- if (auto optEval = dyn_cast<OptionalEvaluationExpr>(expr)) {
- return finishOptionalEvaluation(SGF, optEval);
- }
-
- // Done with the recursive cases. Make sure we handled everything.
- assert(isa<InOutToPointerExpr>(expr) ||
- isa<ArrayToPointerExpr>(expr) ||
- isa<StringToPointerExpr>(expr));
-
- switch (Kind) {
- case InOut:
- case BorrowDirect:
- case BorrowIndirect:
- llvm_unreachable("no original expr to finish in these cases");
-
- case LValueToPointer:
- return {SGF.emitLValueToPointer(LV().Loc, std::move(LV().LV),
- Extra.get<PointerAccessInfo>(Kind)),
- /*owner*/ ManagedValue()};
-
- case LValueArrayToPointer:
- return SGF.emitArrayToPointer(LV().Loc, std::move(LV().LV),
- Extra.get<ArrayAccessInfo>(Kind));
-
- case RValueArrayToPointer: {
- auto pointerExpr = cast<ArrayToPointerExpr>(expr);
- auto optArrayValue = RV().RV;
- auto arrayValue = emitBindOptionals(SGF, optArrayValue,
- pointerExpr->getSubExpr());
- return SGF.emitArrayToPointer(pointerExpr, arrayValue,
- Extra.get<ArrayAccessInfo>(Kind));
- }
-
- case RValueStringToPointer: {
- auto pointerExpr = cast<StringToPointerExpr>(expr);
- auto optStringValue = RV().RV;
- auto stringValue =
- emitBindOptionals(SGF, optStringValue, pointerExpr->getSubExpr());
- return SGF.emitStringToPointer(pointerExpr, stringValue,
- pointerExpr->getType());
- }
- }
- llvm_unreachable("bad kind");
- }
-
- ManagedValue emitBindOptionals(SILGenFunction &SGF, ManagedValue optValue,
- Expr *expr) {
- expr = expr->getSemanticsProvidingExpr();
- auto bind = dyn_cast<BindOptionalExpr>(expr);
-
- // If we don't find a bind, the value isn't optional.
- if (!bind) return optValue;
-
- // Recurse.
- optValue = emitBindOptionals(SGF, optValue, bind->getSubExpr());
-
- // Check whether the value is non-nil and if the value is not-nil, return
- // the unwrapped value.
- return SGF.emitBindOptional(bind, optValue, bind->getDepth());
- }
-
- std::pair<ManagedValue, ManagedValue>
- finishOptionalEvaluation(SILGenFunction &SGF, OptionalEvaluationExpr *eval) {
- SmallVector<ManagedValue, 2> results;
-
- SGF.emitOptionalEvaluation(eval, eval->getType(), results, SGFContext(),
- [&](SmallVectorImpl<ManagedValue> &results, SGFContext C) {
- // Recurse.
- auto values = finishOriginalExpr(SGF, eval->getSubExpr());
-
- // Our primary result is the value.
- results.push_back(values.first);
-
- // Our secondary result is the owner, if we have one.
- if (auto owner = values.second) results.push_back(owner);
- });
-
- assert(results.size() == 1 || results.size() == 2);
-
- ManagedValue value = results[0];
-
- ManagedValue owner;
- if (results.size() == 2) {
- owner = results[1];
-
- // Create a new value-dependence here if the primary result is
- // trivial.
- auto &valueTL = SGF.getTypeLowering(value.getType());
- if (valueTL.isTrivial()) {
- SILValue dependentValue =
- SGF.B.createMarkDependence(eval, value.forward(SGF),
- owner.getValue());
- value = SGF.emitManagedRValueWithCleanup(dependentValue, valueTL);
- }
- }
-
- return {value, owner};
- }
-};
-
-} // end anonymous namespace
-
-/// Perform the formal-access phase of call argument emission by emitting
-/// all of the delayed arguments.
-static void emitDelayedArguments(SILGenFunction &SGF,
- MutableArrayRef<DelayedArgument> delayedArgs,
- MutableArrayRef<SmallVector<ManagedValue, 4>> args) {
- assert(!delayedArgs.empty());
-
- SmallVector<std::pair<SILValue, SILLocation>, 4> emittedInoutArgs;
- auto delayedNext = delayedArgs.begin();
-
- // The assumption we make is that 'args' and 'inoutArgs' were built
- // up in parallel, with empty spots being dropped into 'args'
- // wherever there's an inout argument to insert.
- //
- // Note that this also begins the formal accesses in evaluation order.
- for (auto &siteArgs : args) {
- for (ManagedValue &siteArg : siteArgs) {
- if (siteArg) continue;
-
- assert(delayedNext != delayedArgs.end());
- auto &delayedArg = *delayedNext;
-
- // Emit the delayed argument and replace it in the arguments array.
- auto value = delayedArg.emit(SGF);
- siteArg = value;
-
- // Remember all the simple inouts we emitted so we can perform
- // a basic inout-aliasing analysis.
- // This should be completely obviated by static enforcement.
- if (delayedArg.isSimpleInOut()) {
- emittedInoutArgs.push_back({value.getValue(),
- delayedArg.getInOutLocation()});
- }
-
- if (++delayedNext == delayedArgs.end())
- goto done;
- }
- }
-
- llvm_unreachable("ran out of null arguments before we ran out of inouts");
-
-done:
-
- // Check to see if we have multiple inout arguments which obviously
- // alias. Note that we could do this in a later SILDiagnostics pass
- // as well: this would be stronger (more equivalences exposed) but
- // would have worse source location information.
- for (auto i = emittedInoutArgs.begin(), e = emittedInoutArgs.end();
- i != e; ++i) {
- for (auto j = emittedInoutArgs.begin(); j != i; ++j) {
- if (!RValue::areObviouslySameValue(i->first, j->first)) continue;
-
- SGF.SGM.diagnose(i->second, diag::inout_argument_alias)
- .highlight(i->second.getSourceRange());
- SGF.SGM.diagnose(j->second, diag::previous_inout_alias)
- .highlight(j->second.getSourceRange());
- }
- }
-}
-
-namespace {
-
-/// A destination for an argument other than just "onto to the end
-/// of the arguments lists".
-///
-/// This allows us to re-use the argument expression emitter for
-/// some weird cases, like a shuffled tuple where some of the
-/// arguments are going into a varargs array.
-struct ArgSpecialDest {
- VarargsInfo *SharedInfo;
- unsigned Index;
- CleanupHandle Cleanup;
-
- ArgSpecialDest() : SharedInfo(nullptr) {}
- explicit ArgSpecialDest(VarargsInfo &info, unsigned index)
- : SharedInfo(&info), Index(index) {}
-
- // Reference semantics: need to preserve the cleanup handle.
- ArgSpecialDest(const ArgSpecialDest &) = delete;
- ArgSpecialDest &operator=(const ArgSpecialDest &) = delete;
- ArgSpecialDest(ArgSpecialDest &&other)
- : SharedInfo(other.SharedInfo), Index(other.Index),
- Cleanup(other.Cleanup) {
- other.SharedInfo = nullptr;
- }
- ArgSpecialDest &operator=(ArgSpecialDest &&other) {
- assert(!isValid() && "overwriting valid special destination!");
- SharedInfo = other.SharedInfo;
- Index = other.Index;
- Cleanup = other.Cleanup;
- other.SharedInfo = nullptr;
- return *this;
- }
-
- ~ArgSpecialDest() {
- assert(!isValid() && "failed to deactivate special dest");
- }
-
- /// Is this a valid special destination?
- ///
- /// Most of the time, most arguments don't have special
- /// destinations, and making an array of Optional<Special special
- /// destinations has t
- bool isValid() const { return SharedInfo != nullptr; }
-
- /// Fill this special destination with a value.
- void fill(SILGenFunction &SGF, ArgumentSource &&arg,
- AbstractionPattern _unused_origType,
- SILType loweredSubstParamType) {
- assert(isValid() && "filling an invalid destination");
-
- SILLocation loc = arg.getLocation();
- auto destAddr = SharedInfo->getBaseAddress();
- if (Index != 0) {
- SILValue index = SGF.B.createIntegerLiteral(loc,
- SILType::getBuiltinWordType(SGF.getASTContext()), Index);
- destAddr = SGF.B.createIndexAddr(loc, destAddr, index);
- }
-
- assert(destAddr->getType() == loweredSubstParamType.getAddressType());
-
- auto &destTL = SharedInfo->getBaseTypeLowering();
- Cleanup =
- SGF.enterDormantFormalAccessTemporaryCleanup(destAddr, loc, destTL);
-
- TemporaryInitialization init(destAddr, Cleanup);
- std::move(arg).forwardInto(SGF, SharedInfo->getBaseAbstractionPattern(),
- &init, destTL);
- }
-
- /// Deactivate this special destination. Must always be called
- /// before destruction.
- void deactivate(SILGenFunction &SGF) {
- assert(isValid() && "deactivating an invalid destination");
- if (Cleanup.isValid())
- SGF.Cleanups.forwardCleanup(Cleanup);
- SharedInfo = nullptr;
- }
-};
-
+
/// A possibly-discontiguous slice of function parameters claimed by a
/// function application.
class ClaimedParamsRef {
@@ -2306,6 +1836,527 @@
}
};
+/// A delayed argument. Call arguments are evaluated in two phases:
+/// a formal evaluation phase and a formal access phase. The primary
+/// example of this is an l-value that is passed by reference, where
+/// the access to the l-value does not begin until the formal access
+/// phase, but there are other examples, generally relating to pointer
+/// conversions.
+///
+/// A DelayedArgument represents the part of evaluating an argument
+/// that's been delayed until the formal access phase.
+class DelayedArgument {
+public:
+ enum KindTy {
+ /// This is a true inout argument.
+ InOut,
+
+ LastLVKindWithoutExtra = InOut,
+
+ /// The l-value needs to be converted to a pointer type.
+ LValueToPointer,
+
+ /// An array l-value needs to be converted to a pointer type.
+ LValueArrayToPointer,
+
+ LastLVKind = LValueArrayToPointer,
+
+ /// An array r-value needs to be converted to a pointer type.
+ RValueArrayToPointer,
+
+ /// A string r-value needs to be converted to a pointer type.
+ RValueStringToPointer,
+
+ LastRVKind = RValueStringToPointer,
+
+ /// A default argument that needs to be evaluated.
+ DefaultArgument,
+ };
+
+private:
+ KindTy Kind;
+
+ struct LValueStorage {
+ LValue LV;
+ SILLocation Loc;
+
+ LValueStorage(LValue &&lv, SILLocation loc) : LV(std::move(lv)), Loc(loc) {}
+ };
+ struct RValueStorage {
+ ManagedValue RV;
+
+ RValueStorage(ManagedValue rv) : RV(rv) {}
+ };
+ struct DefaultArgumentStorage {
+ SILLocation loc;
+ ConcreteDeclRef defaultArgsOwner;
+ unsigned destIndex;
+ CanType resultType;
+ AbstractionPattern origResultType;
+ ClaimedParamsRef paramsToEmit;
+ SILFunctionTypeRepresentation functionRepresentation;
+
+ DefaultArgumentStorage(SILLocation loc,
+ ConcreteDeclRef defaultArgsOwner,
+ unsigned destIndex,
+ CanType resultType,
+ AbstractionPattern origResultType,
+ ClaimedParamsRef paramsToEmit,
+ SILFunctionTypeRepresentation functionRepresentation)
+ : loc(loc), defaultArgsOwner(defaultArgsOwner), destIndex(destIndex),
+ resultType(resultType), origResultType(origResultType),
+ paramsToEmit(paramsToEmit),
+ functionRepresentation(functionRepresentation)
+ {}
+ };
+
+ using ValueMembers =
+ ExternalUnionMembers<RValueStorage, LValueStorage,
+ DefaultArgumentStorage>;
+ static ValueMembers::Index getValueMemberIndexForKind(KindTy kind) {
+ return (kind <= LastLVKind ? ValueMembers::indexOf<LValueStorage>() :
+ kind <= LastRVKind ? ValueMembers::indexOf<RValueStorage>()
+ : ValueMembers::indexOf<DefaultArgumentStorage>());
+ }
+
+ /// Storage for either the l-value or the r-value.
+ ExternalUnion<KindTy, ValueMembers, getValueMemberIndexForKind> Value;
+
+ LValueStorage &LV() { return Value.get<LValueStorage>(Kind); }
+ const LValueStorage &LV() const { return Value.get<LValueStorage>(Kind); }
+ RValueStorage &RV() { return Value.get<RValueStorage>(Kind); }
+ const RValueStorage &RV() const { return Value.get<RValueStorage>(Kind); }
+
+ /// The original argument expression, which will be emitted down
+ /// to the point from which the l-value or r-value was generated.
+ OriginalArgument Original;
+
+ using PointerAccessInfo = SILGenFunction::PointerAccessInfo;
+ using ArrayAccessInfo = SILGenFunction::ArrayAccessInfo;
+
+ using ExtraMembers =
+ ExternalUnionMembers<void,
+ ArrayAccessInfo,
+ PointerAccessInfo>;
+ static ExtraMembers::Index getExtraMemberIndexForKind(KindTy kind) {
+ switch (kind) {
+ case LValueToPointer:
+ return ExtraMembers::indexOf<PointerAccessInfo>();
+ case LValueArrayToPointer:
+ case RValueArrayToPointer:
+ return ExtraMembers::indexOf<ArrayAccessInfo>();
+ default:
+ return ExtraMembers::indexOf<void>();
+ }
+ }
+
+ ExternalUnion<KindTy, ExtraMembers, getExtraMemberIndexForKind> Extra;
+
+public:
+ DelayedArgument(KindTy kind, LValue &&lv, SILLocation loc)
+ : Kind(kind) {
+ assert(kind <= LastLVKindWithoutExtra &&
+ "this constructor should only be used for simple l-value kinds");
+ Value.emplace<LValueStorage>(Kind, std::move(lv), loc);
+ }
+
+ DelayedArgument(KindTy kind, ManagedValue rv, OriginalArgument original)
+ : Kind(kind), Original(original) {
+ Value.emplace<RValueStorage>(Kind, rv);
+ }
+
+ DelayedArgument(SILGenFunction::PointerAccessInfo pointerInfo,
+ LValue &&lv, SILLocation loc, OriginalArgument original)
+ : Kind(LValueToPointer), Original(original) {
+ Value.emplace<LValueStorage>(Kind, std::move(lv), loc);
+ Extra.emplace<PointerAccessInfo>(Kind, pointerInfo);
+ }
+
+ DelayedArgument(SILGenFunction::ArrayAccessInfo arrayInfo,
+ LValue &&lv, SILLocation loc, OriginalArgument original)
+ : Kind(LValueArrayToPointer), Original(original) {
+ Value.emplace<LValueStorage>(Kind, std::move(lv), loc);
+ Extra.emplace<ArrayAccessInfo>(Kind, arrayInfo);
+ }
+
+ DelayedArgument(KindTy kind,
+ SILGenFunction::ArrayAccessInfo arrayInfo,
+ ManagedValue rv, OriginalArgument original)
+ : Kind(kind), Original(original) {
+ Value.emplace<RValueStorage>(Kind, rv);
+ Extra.emplace<ArrayAccessInfo>(Kind, arrayInfo);
+ }
+
+ DelayedArgument(SILLocation loc,
+ ConcreteDeclRef defaultArgsOwner,
+ unsigned destIndex,
+ CanType resultType,
+ AbstractionPattern origResultType,
+ ClaimedParamsRef params,
+ SILFunctionTypeRepresentation functionTypeRepresentation)
+ : Kind(DefaultArgument) {
+ Value.emplace<DefaultArgumentStorage>(Kind, loc, defaultArgsOwner,
+ destIndex,
+ resultType,
+ origResultType, params,
+ functionTypeRepresentation);
+ }
+
+ DelayedArgument(DelayedArgument &&other)
+ : Kind(other.Kind), Original(other.Original) {
+ Value.moveConstruct(Kind, std::move(other.Value));
+ Extra.moveConstruct(Kind, std::move(other.Extra));
+ }
+
+ DelayedArgument &operator=(DelayedArgument &&other) {
+ Value.moveAssign(Kind, other.Kind, std::move(other.Value));
+ Extra.moveAssign(Kind, other.Kind, std::move(other.Extra));
+ Kind = other.Kind;
+ Original = other.Original;
+ return *this;
+ }
+
+ ~DelayedArgument() {
+ Extra.destruct(Kind);
+ Value.destruct(Kind);
+ }
+
+ bool isSimpleInOut() const { return Kind == InOut; }
+ SILLocation getInOutLocation() const {
+ assert(isSimpleInOut());
+ return LV().Loc;
+ }
+
+ void emit(SILGenFunction &SGF,
+ SmallVectorImpl<ManagedValue> &args,
+ int &argIndex) {
+ switch (Kind) {
+ case InOut:
+ args[argIndex] = emitInOut(SGF);
+ return;
+ case LValueToPointer:
+ case LValueArrayToPointer:
+ case RValueArrayToPointer:
+ case RValueStringToPointer:
+ args[argIndex] = finishOriginalArgument(SGF);
+ return;
+ case DefaultArgument:
+ emitDefaultArgument(SGF, Value.get<DefaultArgumentStorage>(Kind),
+ args, argIndex);
+ return;
+ }
+ llvm_unreachable("bad kind");
+ }
+
+private:
+ ManagedValue emitInOut(SILGenFunction &SGF) {
+ return emitAddress(SGF, AccessKind::ReadWrite);
+ }
+
+ ManagedValue emitBorrowIndirect(SILGenFunction &SGF) {
+ return emitAddress(SGF, AccessKind::Read);
+ }
+
+ ManagedValue emitBorrowDirect(SILGenFunction &SGF) {
+ ManagedValue address = emitAddress(SGF, AccessKind::Read);
+ return SGF.B.createLoadBorrow(LV().Loc, address);
+ }
+
+ ManagedValue emitAddress(SILGenFunction &SGF, AccessKind accessKind) {
+ auto tsanKind =
+ (accessKind == AccessKind::Read ? TSanKind::None : TSanKind::InoutAccess);
+ return SGF.emitAddressOfLValue(LV().Loc, std::move(LV().LV),
+ accessKind, tsanKind);
+ }
+
+ /// Replay the original argument expression.
+ ManagedValue finishOriginalArgument(SILGenFunction &SGF) {
+ auto results = finishOriginalExpr(SGF, Original.getExpr());
+ auto value = results.first; // just let the owner go
+
+ if (Original.isIndirect() && !value.getType().isAddress()) {
+ value = value.materialize(SGF, Original.getExpr());
+ }
+
+ return value;
+ }
+
+ void emitDefaultArgument(SILGenFunction &SGF,
+ const DefaultArgumentStorage &info,
+ SmallVectorImpl<ManagedValue> &args,
+ int &argIndex);
+
+ // (value, owner)
+ std::pair<ManagedValue, ManagedValue>
+ finishOriginalExpr(SILGenFunction &SGF, Expr *expr) {
+
+ // This needs to handle all of the recursive cases from
+ // ArgEmission::maybeEmitDelayed.
+
+ expr = expr->getSemanticsProvidingExpr();
+
+ // Handle injections into optionals.
+ if (auto inject = dyn_cast<InjectIntoOptionalExpr>(expr)) {
+ auto ownedValue =
+ finishOriginalExpr(SGF, inject->getSubExpr());
+ auto &optionalTL = SGF.getTypeLowering(expr->getType());
+
+ auto optValue = SGF.emitInjectOptional(inject, optionalTL, SGFContext(),
+ [&](SGFContext ctx) { return ownedValue.first; });
+ return {optValue, ownedValue.second};
+ }
+
+ // Handle try!.
+ if (auto forceTry = dyn_cast<ForceTryExpr>(expr)) {
+ // Handle throws from the accessor? But what if the writeback throws?
+ SILGenFunction::ForceTryEmission emission(SGF, forceTry);
+ return finishOriginalExpr(SGF, forceTry->getSubExpr());
+ }
+
+ // Handle optional evaluations.
+ if (auto optEval = dyn_cast<OptionalEvaluationExpr>(expr)) {
+ return finishOptionalEvaluation(SGF, optEval);
+ }
+
+ // Done with the recursive cases. Make sure we handled everything.
+ assert(isa<InOutToPointerExpr>(expr) ||
+ isa<ArrayToPointerExpr>(expr) ||
+ isa<StringToPointerExpr>(expr));
+
+ switch (Kind) {
+ case InOut:
+ case DefaultArgument:
+ llvm_unreachable("no original expr to finish in these cases");
+
+ case LValueToPointer:
+ return {SGF.emitLValueToPointer(LV().Loc, std::move(LV().LV),
+ Extra.get<PointerAccessInfo>(Kind)),
+ /*owner*/ ManagedValue()};
+
+ case LValueArrayToPointer:
+ return SGF.emitArrayToPointer(LV().Loc, std::move(LV().LV),
+ Extra.get<ArrayAccessInfo>(Kind));
+
+ case RValueArrayToPointer: {
+ auto pointerExpr = cast<ArrayToPointerExpr>(expr);
+ auto optArrayValue = RV().RV;
+ auto arrayValue = emitBindOptionals(SGF, optArrayValue,
+ pointerExpr->getSubExpr());
+ return SGF.emitArrayToPointer(pointerExpr, arrayValue,
+ Extra.get<ArrayAccessInfo>(Kind));
+ }
+
+ case RValueStringToPointer: {
+ auto pointerExpr = cast<StringToPointerExpr>(expr);
+ auto optStringValue = RV().RV;
+ auto stringValue =
+ emitBindOptionals(SGF, optStringValue, pointerExpr->getSubExpr());
+ return SGF.emitStringToPointer(pointerExpr, stringValue,
+ pointerExpr->getType());
+ }
+ }
+ llvm_unreachable("bad kind");
+ }
+
+ ManagedValue emitBindOptionals(SILGenFunction &SGF, ManagedValue optValue,
+ Expr *expr) {
+ expr = expr->getSemanticsProvidingExpr();
+ auto bind = dyn_cast<BindOptionalExpr>(expr);
+
+ // If we don't find a bind, the value isn't optional.
+ if (!bind) return optValue;
+
+ // Recurse.
+ optValue = emitBindOptionals(SGF, optValue, bind->getSubExpr());
+
+ // Check whether the value is non-nil and if the value is not-nil, return
+ // the unwrapped value.
+ return SGF.emitBindOptional(bind, optValue, bind->getDepth());
+ }
+
+ std::pair<ManagedValue, ManagedValue>
+ finishOptionalEvaluation(SILGenFunction &SGF, OptionalEvaluationExpr *eval) {
+ SmallVector<ManagedValue, 2> results;
+
+ SGF.emitOptionalEvaluation(eval, eval->getType(), results, SGFContext(),
+ [&](SmallVectorImpl<ManagedValue> &results, SGFContext C) {
+ // Recurse.
+ auto values = finishOriginalExpr(SGF, eval->getSubExpr());
+
+ // Our primary result is the value.
+ results.push_back(values.first);
+
+ // Our secondary result is the owner, if we have one.
+ if (auto owner = values.second) results.push_back(owner);
+ });
+
+ assert(results.size() == 1 || results.size() == 2);
+
+ ManagedValue value = results[0];
+
+ ManagedValue owner;
+ if (results.size() == 2) {
+ owner = results[1];
+
+ // Create a new value-dependence here if the primary result is
+ // trivial.
+ auto &valueTL = SGF.getTypeLowering(value.getType());
+ if (valueTL.isTrivial()) {
+ SILValue dependentValue =
+ SGF.B.createMarkDependence(eval, value.forward(SGF),
+ owner.getValue());
+ value = SGF.emitManagedRValueWithCleanup(dependentValue, valueTL);
+ }
+ }
+
+ return {value, owner};
+ }
+};
+
+} // end anonymous namespace
+
+/// Perform the formal-access phase of call argument emission by emitting
+/// all of the delayed arguments.
+static void emitDelayedArguments(SILGenFunction &SGF,
+ MutableArrayRef<DelayedArgument> delayedArgs,
+ MutableArrayRef<SmallVector<ManagedValue, 4>> args) {
+ assert(!delayedArgs.empty());
+
+ SmallVector<std::pair<SILValue, SILLocation>, 4> emittedInoutArgs;
+ auto delayedNext = delayedArgs.begin();
+
+ // The assumption we make is that 'args' and 'delayedArgs' were built
+ // up in parallel, with empty spots being dropped into 'args'
+ // wherever there's a delayed argument to insert.
+ //
+ // Note that this also begins the formal accesses in evaluation order.
+ for (auto &siteArgs : args) {
+ // NB: siteArgs.size() may change during iteration
+ for (int i = 0; i < (int)siteArgs.size(); ++i) {
+ auto &siteArg = siteArgs[i];
+
+ if (siteArg) continue;
+
+ assert(delayedNext != delayedArgs.end());
+ auto &delayedArg = *delayedNext;
+
+ // Emit the delayed argument and replace it in the arguments array.
+ delayedArg.emit(SGF, siteArgs, i);
+
+ // Remember all the simple inouts we emitted so we can perform
+ // a basic inout-aliasing analysis.
+ // This should be completely obviated by static enforcement.
+ if (delayedArg.isSimpleInOut()) {
+ emittedInoutArgs.push_back({siteArg.getValue(),
+ delayedArg.getInOutLocation()});
+ }
+
+ if (++delayedNext == delayedArgs.end())
+ goto done;
+ }
+ }
+
+ llvm_unreachable("ran out of null arguments before we ran out of inouts");
+
+done:
+
+ // Check to see if we have multiple inout arguments which obviously
+ // alias. Note that we could do this in a later SILDiagnostics pass
+ // as well: this would be stronger (more equivalences exposed) but
+ // would have worse source location information.
+ for (auto i = emittedInoutArgs.begin(), e = emittedInoutArgs.end();
+ i != e; ++i) {
+ for (auto j = emittedInoutArgs.begin(); j != i; ++j) {
+ if (!RValue::areObviouslySameValue(i->first, j->first)) continue;
+
+ SGF.SGM.diagnose(i->second, diag::inout_argument_alias)
+ .highlight(i->second.getSourceRange());
+ SGF.SGM.diagnose(j->second, diag::previous_inout_alias)
+ .highlight(j->second.getSourceRange());
+ }
+ }
+}
+
+namespace {
+
+/// A destination for an argument other than just "onto to the end
+/// of the arguments lists".
+///
+/// This allows us to re-use the argument expression emitter for
+/// some weird cases, like a shuffled tuple where some of the
+/// arguments are going into a varargs array.
+struct ArgSpecialDest {
+ VarargsInfo *SharedInfo;
+ unsigned Index;
+ CleanupHandle Cleanup;
+
+ ArgSpecialDest() : SharedInfo(nullptr) {}
+ explicit ArgSpecialDest(VarargsInfo &info, unsigned index)
+ : SharedInfo(&info), Index(index) {}
+
+ // Reference semantics: need to preserve the cleanup handle.
+ ArgSpecialDest(const ArgSpecialDest &) = delete;
+ ArgSpecialDest &operator=(const ArgSpecialDest &) = delete;
+ ArgSpecialDest(ArgSpecialDest &&other)
+ : SharedInfo(other.SharedInfo), Index(other.Index),
+ Cleanup(other.Cleanup) {
+ other.SharedInfo = nullptr;
+ }
+ ArgSpecialDest &operator=(ArgSpecialDest &&other) {
+ assert(!isValid() && "overwriting valid special destination!");
+ SharedInfo = other.SharedInfo;
+ Index = other.Index;
+ Cleanup = other.Cleanup;
+ other.SharedInfo = nullptr;
+ return *this;
+ }
+
+ ~ArgSpecialDest() {
+ assert(!isValid() && "failed to deactivate special dest");
+ }
+
+ /// Is this a valid special destination?
+ ///
+ /// Most of the time, most arguments don't have special
+ /// destinations, and making an array of Optional<Special special
+ /// destinations has t
+ bool isValid() const { return SharedInfo != nullptr; }
+
+ /// Fill this special destination with a value.
+ void fill(SILGenFunction &SGF, ArgumentSource &&arg,
+ AbstractionPattern _unused_origType,
+ SILType loweredSubstParamType) {
+ assert(isValid() && "filling an invalid destination");
+
+ SILLocation loc = arg.getLocation();
+ auto destAddr = SharedInfo->getBaseAddress();
+ if (Index != 0) {
+ SILValue index = SGF.B.createIntegerLiteral(loc,
+ SILType::getBuiltinWordType(SGF.getASTContext()), Index);
+ destAddr = SGF.B.createIndexAddr(loc, destAddr, index);
+ }
+
+ assert(destAddr->getType() == loweredSubstParamType.getAddressType());
+
+ auto &destTL = SharedInfo->getBaseTypeLowering();
+ Cleanup =
+ SGF.enterDormantFormalAccessTemporaryCleanup(destAddr, loc, destTL);
+
+ TemporaryInitialization init(destAddr, Cleanup);
+ std::move(arg).forwardInto(SGF, SharedInfo->getBaseAbstractionPattern(),
+ &init, destTL);
+ }
+
+ /// Deactivate this special destination. Must always be called
+ /// before destruction.
+ void deactivate(SILGenFunction &SGF) {
+ assert(isValid() && "deactivating an invalid destination");
+ if (Cleanup.isValid())
+ SGF.Cleanups.forwardCleanup(Cleanup);
+ SharedInfo = nullptr;
+ }
+};
+
using ArgSpecialDestArray = MutableArrayRef<ArgSpecialDest>;
class TupleShuffleArgEmitter;
@@ -2832,6 +2883,40 @@
}
};
+void DelayedArgument::emitDefaultArgument(SILGenFunction &SGF,
+ const DefaultArgumentStorage &info,
+ SmallVectorImpl<ManagedValue> &args,
+ int &argIndex) {
+ auto value = SGF.emitApplyOfDefaultArgGenerator(info.loc,
+ info.defaultArgsOwner,
+ info.destIndex,
+ info.resultType,
+ info.origResultType);
+
+ SmallVector<ManagedValue, 4> loweredArgs;
+ SmallVector<DelayedArgument, 4> delayedArgs;
+ Optional<ForeignErrorConvention> errorConvention = None;
+ auto emitter = ArgEmitter(SGF, info.functionRepresentation,
+ info.paramsToEmit,
+ loweredArgs, delayedArgs,
+ errorConvention, ImportAsMemberStatus());
+
+ emitter.emitTopLevel(ArgumentSource(info.loc, std::move(value)),
+ info.origResultType);
+ assert(delayedArgs.empty());
+ assert(!errorConvention);
+
+ // Splice the emitted default argument into the argument list.
+ if (loweredArgs.size() == 1) {
+ args[argIndex] = loweredArgs.front();
+ } else {
+ args.erase(args.begin() + argIndex);
+ args.insert(args.begin() + argIndex,
+ loweredArgs.begin(), loweredArgs.end());
+ argIndex += loweredArgs.size() - 1;
+ }
+}
+
struct ElementExtent {
/// The parameters which go into this tuple element.
/// This is set in the first pass.
@@ -3116,16 +3201,22 @@
continue;
}
- // If this is default initialization, call the default argument
- // generator.
+ // If this is default initialization, prepare to emit the default argument
+ // generator later.
if (innerIndex == TupleShuffleExpr::DefaultInitialize) {
// Otherwise, emit the default initializer, then map that as a
// default argument.
CanType eltType = outerElements[outerIndex].getType()->getCanonicalType();
auto origType = getOutputOrigElementType(outerIndex);
- RValue value = parent.SGF.emitApplyOfDefaultArgGenerator(
- outer, defaultArgsOwner, outerIndex, eltType, origType);
- parent.emit(ArgumentSource(outer, std::move(value)), origType);
+
+ auto numParams = getFlattenedValueCount(origType, eltType,
+ ImportAsMemberStatus());
+ parent.DelayedArguments.emplace_back(outer, defaultArgsOwner,
+ outerIndex, eltType, origType,
+ parent.ParamInfos.slice(0, numParams),
+ parent.Rep);
+ parent.ParamInfos = parent.ParamInfos.slice(numParams);
+ parent.Args.push_back(ManagedValue());
continue;
}
@@ -4432,7 +4523,7 @@
RValue
SILGenFunction::emitApplyOfLibraryIntrinsic(SILLocation loc,
FuncDecl *fn,
- const SubstitutionMap &subMap,
+ SubstitutionMap subMap,
ArrayRef<ManagedValue> args,
SGFContext ctx) {
auto callee = Callee::forDirect(*this, SILDeclRef(fn), subMap, loc);
diff --git a/lib/SILGen/SILGenConstructor.cpp b/lib/SILGen/SILGenConstructor.cpp
index 9c2757c..e5283e4 100644
--- a/lib/SILGen/SILGenConstructor.cpp
+++ b/lib/SILGen/SILGenConstructor.cpp
@@ -969,9 +969,8 @@
},
[](CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) {
- return ProtocolConformanceRef(
- conformedProtocol->getDecl());
+ ProtocolDecl *conformedProtocol) {
+ return ProtocolConformanceRef(conformedProtocol);
});
}
diff --git a/lib/SILGen/SILGenExpr.cpp b/lib/SILGen/SILGenExpr.cpp
index 1805ad1..b40c3f2 100644
--- a/lib/SILGen/SILGenExpr.cpp
+++ b/lib/SILGen/SILGenExpr.cpp
@@ -2623,11 +2623,11 @@
RValue
SILGenFunction::emitApplyOfDefaultArgGenerator(SILLocation loc,
- ConcreteDeclRef defaultArgsOwner,
- unsigned destIndex,
- CanType resultType,
+ ConcreteDeclRef defaultArgsOwner,
+ unsigned destIndex,
+ CanType resultType,
AbstractionPattern origResultType,
- SGFContext C) {
+ SGFContext C) {
SILDeclRef generator
= SILDeclRef::getDefaultArgGenerator(defaultArgsOwner.getDecl(),
destIndex);
@@ -3659,7 +3659,7 @@
genericSig->getSubstitutionMap(
[&](SubstitutableType *type) -> Type { return formalTy; },
[&](CanType dependentType, Type replacementType,
- ProtocolType *protoType)->Optional<ProtocolConformanceRef> {
+ ProtocolDecl *proto)->Optional<ProtocolConformanceRef> {
return hashable;
});
}
@@ -4567,30 +4567,12 @@
return mayLieAboutNonOptionalReturn(M, load->getSubExpr());
}
- // A reference to a member property.
- if (auto member = dyn_cast<MemberRefExpr>(expr)) {
+ // A reference to a potentially dynamic member/subscript property.
+ if (auto member = dyn_cast<LookupExpr>(expr)) {
return isVerbatimNullableTypeInC(M, member->getType()) &&
mayLieAboutNonOptionalReturn(M, member->getMember().getDecl());
}
- // A reference to a subscript.
- if (auto subscript = dyn_cast<SubscriptExpr>(expr)) {
- return isVerbatimNullableTypeInC(M, subscript->getType()) &&
- mayLieAboutNonOptionalReturn(M, subscript->getDecl().getDecl());
- }
-
- // A reference to a member property found via dynamic lookup.
- if (auto member = dyn_cast<DynamicMemberRefExpr>(expr)) {
- return isVerbatimNullableTypeInC(M, member->getType()) &&
- mayLieAboutNonOptionalReturn(M, member->getMember().getDecl());
- }
-
- // A reference to a subscript found via dynamic lookup.
- if (auto subscript = dyn_cast<DynamicSubscriptExpr>(expr)) {
- return isVerbatimNullableTypeInC(M, subscript->getType()) &&
- mayLieAboutNonOptionalReturn(M, subscript->getMember().getDecl());
- }
-
return false;
}
@@ -5389,34 +5371,15 @@
void SILGenFunction::emitOpenExistentialExprImpl(
OpenExistentialExpr *E,
llvm::function_ref<void(Expr *)> emitSubExpr) {
+ Optional<FormalEvaluationScope> writebackScope;
+
// Emit the existential value.
if (E->getExistentialValue()->getType()->is<LValueType>()) {
- // Open the existential container right away. We need the dynamic type
- // to be opened in order to evaluate the subexpression.
- AccessKind accessKind;
- if (E->hasLValueAccessKind())
- accessKind = E->getLValueAccessKind();
- else
- accessKind = E->getExistentialValue()->getLValueAccessKind();
- auto lv = emitLValue(E->getExistentialValue(), accessKind);
- auto formalOpenedType = E->getOpaqueValue()->getType()
- ->getWithoutSpecifierType()
- ->getCanonicalType();
- lv = emitOpenExistentialLValue(E, std::move(lv),
- CanArchetypeType(E->getOpenedArchetype()),
- formalOpenedType,
- accessKind);
-
- auto addr = emitAddressOfLValue(E, std::move(lv), accessKind);
- bool inserted = OpaqueLValues.insert({E->getOpaqueValue(),
- {addr.getValue(), formalOpenedType}})
- .second;
+ bool inserted = OpaqueValueExprs.insert({E->getOpaqueValue(), E}).second;
(void)inserted;
assert(inserted && "already have this opened existential?");
emitSubExpr(E->getSubExpr());
- assert(OpaqueLValues.count(E->getOpaqueValue()) == 0
- && "opened existential not removed?");
return;
}
@@ -5443,12 +5406,6 @@
return RValue(SGF, E, *result);
}
- Optional<FormalEvaluationScope> scope;
- // Begin an evaluation scope for an lvalue existential opened into an
- // rvalue expression.
- if (E->getExistentialValue()->getType()->is<LValueType>())
- scope.emplace(SGF);
-
return SGF.emitOpenExistentialExpr<RValue>(E,
[&](Expr *subExpr) -> RValue {
return visit(subExpr, C);
diff --git a/lib/SILGen/SILGenFunction.cpp b/lib/SILGen/SILGenFunction.cpp
index a7b3a14..3590262 100644
--- a/lib/SILGen/SILGenFunction.cpp
+++ b/lib/SILGen/SILGenFunction.cpp
@@ -130,7 +130,7 @@
SILGenFunction::emitSiblingMethodRef(SILLocation loc,
SILValue selfValue,
SILDeclRef methodConstant,
- const SubstitutionMap &subMap) {
+ SubstitutionMap subMap) {
SILValue methodValue;
// If the method is dynamic, access it through runtime-hookable virtual
diff --git a/lib/SILGen/SILGenFunction.h b/lib/SILGen/SILGenFunction.h
index 4a8cc06..24edce0 100644
--- a/lib/SILGen/SILGenFunction.h
+++ b/lib/SILGen/SILGenFunction.h
@@ -1270,7 +1270,7 @@
emitSiblingMethodRef(SILLocation loc,
SILValue selfValue,
SILDeclRef methodConstant,
- const SubstitutionMap &subMap);
+ SubstitutionMap subMap);
SILValue emitMetatypeOfValue(SILLocation loc, Expr *baseExpr);
@@ -1331,7 +1331,7 @@
RValue emitApplyOfLibraryIntrinsic(SILLocation loc,
FuncDecl *fn,
- const SubstitutionMap &subMap,
+ SubstitutionMap subMap,
ArrayRef<ManagedValue> args,
SGFContext ctx);
@@ -1397,10 +1397,10 @@
llvm::SmallDenseMap<OpaqueValueExpr *, OpaqueValueState>
OpaqueValues;
- /// A mapping from opaque value lvalue expressions to the address of the
- /// opened value in memory.
- llvm::SmallDenseMap<OpaqueValueExpr *, std::pair<SILValue, CanType>>
- OpaqueLValues;
+ /// A mapping from opaque value expressions to the open-existential
+ /// expression that determines them, used while lowering lvalues.
+ llvm::SmallDenseMap<OpaqueValueExpr *, OpenExistentialExpr *>
+ OpaqueValueExprs;
/// RAII object that introduces a temporary binding for an opaque value.
///
diff --git a/lib/SILGen/SILGenLValue.cpp b/lib/SILGen/SILGenLValue.cpp
index 6d2b559..8414287 100644
--- a/lib/SILGen/SILGenLValue.cpp
+++ b/lib/SILGen/SILGenLValue.cpp
@@ -1059,18 +1059,21 @@
subscripts(copied.subscripts.copy(SGF, loc)) ,
baseFormalType(copied.baseFormalType) {}
- virtual SILDeclRef getAccessor(SILGenFunction &SGF,
- AccessKind kind) const = 0;
+ virtual bool doesAccessMutateSelf(SILGenFunction &SGF,
+ AccessKind kind) const = 0;
+ bool doesAccessorMutateSelf(SILGenFunction &SGF,
+ SILDeclRef accessor) const {
+ auto accessorSelf = SGF.SGM.Types.getConstantSelfParameter(accessor);
+ return accessorSelf.getType() && accessorSelf.isIndirectMutating();
+ }
+
AccessKind getBaseAccessKind(SILGenFunction &SGF,
AccessKind kind) const override {
- SILDeclRef accessor = getAccessor(SGF, kind);
- auto accessorSelf = SGF.SGM.Types.getConstantSelfParameter(accessor);
- if (accessorSelf.getType() && accessorSelf.isIndirectMutating()) {
+ if (doesAccessMutateSelf(SGF, kind))
return AccessKind::ReadWrite;
- } else {
+ else
return AccessKind::Read;
- }
}
void printBase(raw_ostream &OS, unsigned indent, StringRef name) const {
@@ -1110,13 +1113,25 @@
{
}
- SILDeclRef getAccessor(SILGenFunction &SGF,
- AccessKind accessKind) const override {
- if (accessKind == AccessKind::Read) {
- return SGF.SGM.getGetterDeclRef(decl);
- } else {
- return SGF.SGM.getSetterDeclRef(decl);
+ bool doesAccessMutateSelf(SILGenFunction &SGF,
+ AccessKind accessKind) const override {
+ switch (accessKind) {
+ case AccessKind::Read: {
+ auto getter = SGF.SGM.getGetterDeclRef(decl);
+ return doesAccessorMutateSelf(SGF, getter);
}
+ case AccessKind::Write: {
+ auto setter = SGF.SGM.getSetterDeclRef(decl);
+ return doesAccessorMutateSelf(SGF, setter);
+ }
+ case AccessKind::ReadWrite: {
+ auto getter = SGF.SGM.getGetterDeclRef(decl);
+ auto setter = SGF.SGM.getSetterDeclRef(decl);
+ return doesAccessorMutateSelf(SGF, getter)
+ || doesAccessorMutateSelf(SGF, setter);
+ }
+ }
+ llvm_unreachable("unknown access kind");
}
void emitAssignWithSetter(SILGenFunction &SGF, SILLocation loc,
@@ -1586,9 +1601,10 @@
{
}
- SILDeclRef getAccessor(SILGenFunction &SGF,
- AccessKind accessKind) const override {
- return SGF.SGM.getAddressorDeclRef(decl, accessKind);
+ bool doesAccessMutateSelf(SILGenFunction &SGF,
+ AccessKind kind) const override {
+ auto addressor = SGF.SGM.getAddressorDeclRef(decl, kind);
+ return doesAccessorMutateSelf(SGF, addressor);
}
ManagedValue offset(SILGenFunction &SGF, SILLocation loc, ManagedValue base,
@@ -2350,18 +2366,20 @@
AccessKind accessKind,
LValueOptions options) {
// Handle an opaque lvalue that refers to an opened existential.
- auto known = SGF.OpaqueLValues.find(e);
- if (known != SGF.OpaqueLValues.end()) {
- // Dig the opened address out of the list.
- SILValue opened = known->second.first;
- CanType openedType = known->second.second;
- SGF.OpaqueLValues.erase(known);
+ auto known = SGF.OpaqueValueExprs.find(e);
+ if (known != SGF.OpaqueValueExprs.end()) {
+ // Dig the open-existential expression out of the list.
+ OpenExistentialExpr *opened = known->second;
+ SGF.OpaqueValueExprs.erase(known);
- // Continue formal evaluation of the lvalue from this address.
- return LValue::forAddress(ManagedValue::forLValue(opened),
- None,
- AbstractionPattern(openedType),
- openedType);
+ // Do formal evaluation of the underlying existential lvalue.
+ auto lv = visitRec(opened->getExistentialValue(), accessKind, options);
+ lv = SGF.emitOpenExistentialLValue(
+ opened, std::move(lv),
+ CanArchetypeType(opened->getOpenedArchetype()),
+ e->getType()->getWithoutSpecifierType()->getCanonicalType(),
+ accessKind);
+ return lv;
}
assert(SGF.OpaqueValues.count(e) && "Didn't bind OpaqueValueExpr");
@@ -2655,12 +2673,29 @@
LValue SILGenLValue::visitOpenExistentialExpr(OpenExistentialExpr *e,
AccessKind accessKind,
LValueOptions options) {
- return SGF.emitOpenExistentialExpr<LValue>(e,
- [&](Expr *subExpr) -> LValue {
- return visitRec(subExpr,
- accessKind,
- options);
- });
+ // If the opaque value is not an lvalue, open the existential immediately.
+ if (!e->getOpaqueValue()->getType()->is<LValueType>()) {
+ return SGF.emitOpenExistentialExpr<LValue>(e,
+ [&](Expr *subExpr) -> LValue {
+ return visitRec(subExpr,
+ accessKind,
+ options);
+ });
+ }
+
+ // Record the fact that we're opening this existential. The actual
+ // opening operation will occur when we see the OpaqueValueExpr.
+ bool inserted = SGF.OpaqueValueExprs.insert({e->getOpaqueValue(), e}).second;
+ (void)inserted;
+ assert(inserted && "already have this opened existential?");
+
+ // Visit the subexpression.
+ LValue lv = visitRec(e->getSubExpr(), accessKind, options);
+
+ // Sanity check that we did see the OpaqueValueExpr.
+ assert(SGF.OpaqueValueExprs.count(e->getOpaqueValue()) == 0 &&
+ "opened existential not removed?");
+ return lv;
}
static LValueTypeData
diff --git a/lib/SILGen/SILGenStmt.cpp b/lib/SILGen/SILGenStmt.cpp
index a24236b..c9256d7 100644
--- a/lib/SILGen/SILGenStmt.cpp
+++ b/lib/SILGen/SILGenStmt.cpp
@@ -680,9 +680,6 @@
llvm::SaveAndRestore<JumpDest> savedThrowDest(SGF.ThrowDest, throwDest);
visit(S->getBody());
- // We emit the counter for exiting the do-block here, as we may not have a
- // valid insertion point when falling out.
- SGF.emitProfilerIncrement(S);
}
// Emit the catch clauses, but only if the body of the function
diff --git a/lib/SILOptimizer/IPO/ClosureSpecializer.cpp b/lib/SILOptimizer/IPO/ClosureSpecializer.cpp
index 8ebe2c2..9788b31 100644
--- a/lib/SILOptimizer/IPO/ClosureSpecializer.cpp
+++ b/lib/SILOptimizer/IPO/ClosureSpecializer.cpp
@@ -57,6 +57,7 @@
#define DEBUG_TYPE "closure-specialization"
#include "swift/Basic/Range.h"
+#include "swift/SIL/InstructionUtils.h"
#include "swift/SIL/SILCloner.h"
#include "swift/SIL/SILFunction.h"
#include "swift/SIL/SILInstruction.h"
@@ -123,8 +124,10 @@
void populateCloned();
- SILValue cloneCalleeConversion(SILValue calleeValue, SILValue NewClosure,
- SILBuilder &Builder);
+ SILValue
+ cloneCalleeConversion(SILValue calleeValue, SILValue NewClosure,
+ SILBuilder &Builder,
+ SmallVectorImpl<PartialApplyInst *> &NeedsRelease);
SILFunction *getCloned() { return &getBuilder().getFunction(); }
static SILFunction *cloneFunction(const CallSiteDescriptor &CallSiteDesc,
@@ -274,7 +277,7 @@
ValueLifetimeAnalysis::Frontier LifetimeFrontier;
llvm::SmallVector<CallSiteDescriptor, 8> CallSites;
- ClosureInfo(SingleValueInstruction *Closure): Closure(Closure) {}
+ ClosureInfo(SingleValueInstruction *Closure) : Closure(Closure) {}
ClosureInfo(ClosureInfo &&) =default;
ClosureInfo &operator=(ClosureInfo &&) =default;
@@ -648,20 +651,39 @@
}
// Clone a chain of ConvertFunctionInsts.
-SILValue ClosureSpecCloner::cloneCalleeConversion(SILValue calleeValue,
- SILValue NewClosure,
- SILBuilder &Builder) {
+SILValue ClosureSpecCloner::cloneCalleeConversion(
+ SILValue calleeValue, SILValue NewClosure, SILBuilder &Builder,
+ SmallVectorImpl<PartialApplyInst *> &NeedsRelease) {
if (calleeValue == CallSiteDesc.getClosure())
return NewClosure;
if (auto *CFI = dyn_cast<ConvertFunctionInst>(calleeValue)) {
- calleeValue = cloneCalleeConversion(CFI->getOperand(), NewClosure, Builder);
+ calleeValue = cloneCalleeConversion(CFI->getOperand(), NewClosure, Builder,
+ NeedsRelease);
return Builder.createConvertFunction(CallSiteDesc.getLoc(), calleeValue,
CFI->getType());
}
+ if (auto *PAI = dyn_cast<PartialApplyInst>(calleeValue)) {
+ assert(isPartialApplyOfReabstractionThunk(PAI) && isSupportedClosure(PAI) &&
+ PAI->getArgument(0)
+ ->getType()
+ .getAs<SILFunctionType>()
+ ->isTrivialNoEscape());
+ calleeValue = cloneCalleeConversion(PAI->getArgument(0), NewClosure,
+ Builder, NeedsRelease);
+ auto FunRef = Builder.createFunctionRef(CallSiteDesc.getLoc(),
+ PAI->getReferencedFunction());
+ auto NewPA = Builder.createPartialApply(
+ CallSiteDesc.getLoc(), FunRef, {}, {calleeValue},
+ PAI->getType().getAs<SILFunctionType>()->getCalleeConvention());
+ NeedsRelease.push_back(NewPA);
+ return NewPA;
+ }
+
auto *Cvt = cast<ConvertEscapeToNoEscapeInst>(calleeValue);
- calleeValue = cloneCalleeConversion(Cvt->getOperand(), NewClosure, Builder);
+ calleeValue = cloneCalleeConversion(Cvt->getOperand(), NewClosure, Builder,
+ NeedsRelease);
return Builder.createConvertEscapeToNoEscape(
CallSiteDesc.getLoc(), calleeValue, Cvt->getType(), false, true);
}
@@ -718,9 +740,17 @@
Builder.createFunctionRef(CallSiteDesc.getLoc(), ClosedOverFun);
auto *NewClosure = CallSiteDesc.createNewClosure(Builder, FnVal, NewPAIArgs);
- // Clone a chain of ConvertFunctionInsts.
+ // Clone a chain of ConvertFunctionInsts. This can create further
+ // reabstraction partial_apply instructions.
+ SmallVector<PartialApplyInst*, 4> NeedsRelease;
SILValue ConvertedCallee = cloneCalleeConversion(
- CallSiteDesc.getClosureCallerArg(), NewClosure, Builder);
+ CallSiteDesc.getClosureCallerArg(), NewClosure, Builder, NeedsRelease);
+
+ // Make sure that we actually emit the releases for reabstraction thunks. We
+ // have guaranteed earlier that we only allow reabstraction thunks if the
+ // closure was passed trivial.
+ assert(NeedsRelease.empty() || CallSiteDesc.isTrivialNoEscapeParameter());
+
ValueMap.insert(std::make_pair(ClosureArg, ConvertedCallee));
BBMap.insert(std::make_pair(ClosureUserEntryBB, ClonedEntryBB));
@@ -736,10 +766,11 @@
// Then insert a release in all non failure exit BBs if our partial apply was
// guaranteed. This is b/c it was passed at +0 originally and we need to
- // balance the initial increment of the newly created closure.
+ // balance the initial increment of the newly created closure(s).
+ bool ClosureHasRefSemantics = CallSiteDesc.closureHasRefSemanticContext();
if ((CallSiteDesc.isClosureGuaranteed() ||
CallSiteDesc.isTrivialNoEscapeParameter()) &&
- CallSiteDesc.closureHasRefSemanticContext()) {
+ (ClosureHasRefSemantics || !NeedsRelease.empty())) {
for (SILBasicBlock *BB : CallSiteDesc.getNonFailureExitBBs()) {
SILBasicBlock *OpBB = BBMap[BB];
@@ -750,13 +781,21 @@
// that it will be executed at the end of the epilogue.
if (isa<ReturnInst>(TI)) {
Builder.setInsertionPoint(TI);
- Builder.createReleaseValue(Loc, SILValue(NewClosure),
- Builder.getDefaultAtomicity());
+ if (ClosureHasRefSemantics)
+ Builder.createReleaseValue(Loc, SILValue(NewClosure),
+ Builder.getDefaultAtomicity());
+ for (auto PAI : NeedsRelease)
+ Builder.createReleaseValue(Loc, SILValue(PAI),
+ Builder.getDefaultAtomicity());
continue;
} else if (isa<ThrowInst>(TI)) {
Builder.setInsertionPoint(TI);
- Builder.createReleaseValue(Loc, SILValue(NewClosure),
- Builder.getDefaultAtomicity());
+ if (ClosureHasRefSemantics)
+ Builder.createReleaseValue(Loc, SILValue(NewClosure),
+ Builder.getDefaultAtomicity());
+ for (auto PAI : NeedsRelease)
+ Builder.createReleaseValue(Loc, SILValue(PAI),
+ Builder.getDefaultAtomicity());
continue;
}
@@ -772,7 +811,12 @@
// value, we will retain the partial apply before we release it and
// potentially eliminate it.
Builder.setInsertionPoint(NoReturnApply.getInstruction());
- Builder.createReleaseValue(Loc, SILValue(NewClosure), Builder.getDefaultAtomicity());
+ if (ClosureHasRefSemantics)
+ Builder.createReleaseValue(Loc, SILValue(NewClosure),
+ Builder.getDefaultAtomicity());
+ for (auto PAI : NeedsRelease)
+ Builder.createReleaseValue(Loc, SILValue(PAI),
+ Builder.getDefaultAtomicity());
}
}
}
@@ -839,6 +883,27 @@
invalidateAnalysis(SILAnalysis::InvalidationKind::Everything);
}
+static void markReabstractionPartialApplyAsUsed(
+ SILValue FirstClosure, SILValue Current,
+ llvm::DenseSet<SingleValueInstruction *> &UsedReabstractionClosure) {
+ if (Current == FirstClosure)
+ return;
+ if (auto PA = dyn_cast<PartialApplyInst>(Current)) {
+ UsedReabstractionClosure.insert(PA);
+ return markReabstractionPartialApplyAsUsed(FirstClosure, PA->getArgument(0),
+ UsedReabstractionClosure);
+ }
+ if (auto Cvt = dyn_cast<ConvertFunctionInst>(Current)) {
+ return markReabstractionPartialApplyAsUsed(FirstClosure, Cvt->getOperand(),
+ UsedReabstractionClosure);
+ }
+ if (auto Cvt = dyn_cast<ConvertEscapeToNoEscapeInst>(Current)) {
+ return markReabstractionPartialApplyAsUsed(FirstClosure, Cvt->getOperand(),
+ UsedReabstractionClosure);
+ }
+ llvm_unreachable("Unexpect instruction");
+}
+
void SILClosureSpecializerTransform::gatherCallSites(
SILFunction *Caller,
llvm::SmallVectorImpl<ClosureInfo*> &ClosureCandidates,
@@ -848,6 +913,10 @@
// make sure that we do not handle call sites with multiple closure arguments.
llvm::DenseSet<FullApplySite> VisitedAI;
+ // We should not look at reabstraction closure twice who we ultimately ended
+ // up using as an argument that we specialize on.
+ llvm::DenseSet<SingleValueInstruction *> UsedReabstractionClosure;
+
// For each basic block BB in Caller...
for (auto &BB : *Caller) {
@@ -857,6 +926,8 @@
if (!isSupportedClosure(&II))
continue;
auto ClosureInst = cast<SingleValueInstruction>(&II);
+ if (UsedReabstractionClosure.count(ClosureInst))
+ continue;
ClosureInfo *CInfo = nullptr;
@@ -868,6 +939,7 @@
// Live range end points.
SmallVector<SILInstruction *, 8> UsePoints;
+ bool HaveUsedReabstraction = false;
// Uses may grow in this loop.
for (size_t UseIndex = 0; UseIndex < Uses.size(); ++UseIndex) {
auto *Use = Uses[UseIndex];
@@ -883,6 +955,26 @@
Uses.append(Cvt->getUses().begin(), Cvt->getUses().end());
continue;
}
+
+ // Look through reabstraction thunks.
+ if (auto *PA = dyn_cast<PartialApplyInst>(Use->getUser())) {
+ // Reabstraction can cause series of partial_apply to be emitted. It
+ // is okay to treat these like conversion instructions. Current
+ // restriction: if the partial_apply does not take ownership of its
+ // argument we don't need to analyze which partial_apply to emit
+ // release for (its all of them).
+ if (isPartialApplyOfReabstractionThunk(PA) &&
+ isSupportedClosure(PA) &&
+ PA->getArgument(0)
+ ->getType()
+ .getAs<SILFunctionType>()
+ ->isTrivialNoEscape()) {
+ Uses.append(PA->getUses().begin(), PA->getUses().end());
+ HaveUsedReabstraction = true;
+ }
+ continue;
+ }
+
// If this use is not an apply inst or an apply inst with
// substitutions, there is nothing interesting for us to do, so
// continue...
@@ -961,6 +1053,14 @@
auto ParamInfo = AI.getSubstCalleeType()->getParameters();
SILParameterInfo ClosureParamInfo = ParamInfo[ClosureParamIndex];
+ // We currently only support copying intermediate reabastraction
+ // closures if the closure is ultimately passed trivially.
+ bool IsClosurePassedTrivially = ClosureParamInfo.getType()
+ ->castTo<SILFunctionType>()
+ ->isTrivialNoEscape();
+ if (HaveUsedReabstraction && !IsClosurePassedTrivially)
+ continue;
+
// Get all non-failure exit BBs in the Apply Callee if our partial apply
// is guaranteed. If we do not understand one of the exit BBs, bail.
//
@@ -969,11 +1069,12 @@
//
// However, thin_to_thick_function closures don't have a context and
// don't need to be released.
+ bool OnlyHaveThinToThickClosure =
+ isa<ThinToThickFunctionInst>(ClosureInst) && !HaveUsedReabstraction;
+
llvm::TinyPtrVector<SILBasicBlock *> NonFailureExitBBs;
- if ((ClosureParamInfo.isGuaranteed() || ClosureParamInfo.getType()
- ->castTo<SILFunctionType>()
- ->isTrivialNoEscape()) &&
- !isa<ThinToThickFunctionInst>(ClosureInst) &&
+ if ((ClosureParamInfo.isGuaranteed() || IsClosurePassedTrivially) &&
+ !OnlyHaveThinToThickClosure &&
!findAllNonFailureExitBBs(ApplyCallee, NonFailureExitBBs)) {
continue;
}
@@ -983,6 +1084,10 @@
if (!CInfo)
CInfo = new ClosureInfo(ClosureInst);
+ // Mark the reabstraction closures as used.
+ if (HaveUsedReabstraction)
+ markReabstractionPartialApplyAsUsed(ClosureInst, Use->get(),
+ UsedReabstractionClosure);
// Now we know that CSDesc is profitable to specialize. Add it to our
// call site list.
CInfo->CallSites.push_back(
diff --git a/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp b/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp
index adb291e..5b34f2c 100644
--- a/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp
+++ b/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp
@@ -813,12 +813,12 @@
return type;
},
[&](CanType origTy, Type substTy,
- ProtocolType *proto) -> Optional<ProtocolConformanceRef> {
+ ProtocolDecl *proto) -> Optional<ProtocolConformanceRef> {
if (substTy->isEqual(ConcreteType)) {
- assert(proto->getDecl() == Conformance.getRequirement());
+ assert(proto == Conformance.getRequirement());
return Conformance;
}
- return ProtocolConformanceRef(proto->getDecl());
+ return ProtocolConformanceRef(proto);
});
// Handle polymorphic functions by properly substituting
diff --git a/lib/SILOptimizer/Utils/Generics.cpp b/lib/SILOptimizer/Utils/Generics.cpp
index db7ec64..4b0e12d 100644
--- a/lib/SILOptimizer/Utils/Generics.cpp
+++ b/lib/SILOptimizer/Utils/Generics.cpp
@@ -690,7 +690,7 @@
/// Create a new substituted type with the updated signature.
CanSILFunctionType
ReabstractionInfo::createSubstitutedType(SILFunction *OrigF,
- const SubstitutionMap &SubstMap,
+ SubstitutionMap SubstMap,
bool HasUnboundGenericParams) {
auto &M = OrigF->getModule();
if ((SpecializedGenericSig &&
diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp
index ca67203..993b651 100644
--- a/lib/Sema/CSApply.cpp
+++ b/lib/Sema/CSApply.cpp
@@ -81,16 +81,15 @@
auto &tc = getConstraintSystem().getTypeChecker();
auto lookupConformanceFn =
- [&](CanType original, Type replacement, ProtocolType *protoType)
+ [&](CanType original, Type replacement, ProtocolDecl *protoType)
-> Optional<ProtocolConformanceRef> {
if (replacement->hasError() ||
isOpenedAnyObject(replacement) ||
replacement->is<GenericTypeParamType>()) {
- return ProtocolConformanceRef(protoType->getDecl());
+ return ProtocolConformanceRef(protoType);
}
- return tc.conformsToProtocol(replacement,
- protoType->getDecl(),
+ return tc.conformsToProtocol(replacement, protoType,
getConstraintSystem().DC,
(ConformanceCheckFlags::InExpression|
ConformanceCheckFlags::Used));
@@ -759,14 +758,8 @@
return ctorRef->getArg();
} else if (auto apply = dyn_cast<ApplyExpr>(expr)) {
return apply->getFn();
- } else if (auto memberRef = dyn_cast<MemberRefExpr>(expr)) {
- return memberRef->getBase();
- } else if (auto dynMemberRef = dyn_cast<DynamicMemberRefExpr>(expr)) {
- return dynMemberRef->getBase();
- } else if (auto subscriptRef = dyn_cast<SubscriptExpr>(expr)) {
- return subscriptRef->getBase();
- } else if (auto dynSubscriptRef = dyn_cast<DynamicSubscriptExpr>(expr)) {
- return dynSubscriptRef->getBase();
+ } else if (auto lookupRef = dyn_cast<LookupExpr>(expr)) {
+ return lookupRef->getBase();
} else if (auto load = dyn_cast<LoadExpr>(expr)) {
return load->getSubExpr();
} else if (auto inout = dyn_cast<InOutExpr>(expr)) {
@@ -1836,7 +1829,7 @@
assert(type->isEqual(genericSig->getGenericParams()[0]));
return valueType;
},
- [&](CanType origType, Type replacementType, ProtocolType *protoType)
+ [&](CanType origType, Type replacementType, ProtocolDecl *protoType)
-> ProtocolConformanceRef {
assert(bridgedToObjectiveCConformance);
return *bridgedToObjectiveCConformance;
@@ -1865,7 +1858,6 @@
return bridgeFromObjectiveC(object, valueType, false);
}
- TypeAliasDecl *MaxIntegerTypeDecl = nullptr;
TypeAliasDecl *MaxFloatTypeDecl = nullptr;
public:
@@ -1928,28 +1920,6 @@
}
}
- // Find the maximum-sized builtin integer type.
-
- if (!MaxIntegerTypeDecl) {
- SmallVector<ValueDecl *, 1> lookupResults;
- tc.getStdlibModule(dc)->lookupValue(/*AccessPath=*/{},
- tc.Context.Id_MaxBuiltinIntegerType,
- NLKind::QualifiedLookup,
- lookupResults);
- if (lookupResults.size() == 1) {
- MaxIntegerTypeDecl = dyn_cast<TypeAliasDecl>(lookupResults.front());
- tc.validateDecl(MaxIntegerTypeDecl);
- }
- }
- if (!MaxIntegerTypeDecl ||
- !MaxIntegerTypeDecl->hasInterfaceType() ||
- !MaxIntegerTypeDecl->getDeclaredInterfaceType()->is<BuiltinIntegerType>()) {
- tc.diagnose(expr->getLoc(), diag::no_MaxBuiltinIntegerType_found);
- return nullptr;
- }
- tc.validateDecl(MaxIntegerTypeDecl);
- auto maxType = MaxIntegerTypeDecl->getUnderlyingTypeLoc().getType();
-
DeclName initName(tc.Context, DeclBaseName::createConstructor(),
{ tc.Context.Id_integerLiteral });
DeclName builtinInitName(tc.Context, DeclBaseName::createConstructor(),
@@ -1963,7 +1933,9 @@
tc.Context.Id_IntegerLiteralType,
initName,
builtinProtocol,
- maxType,
+ // Note that 'MaxIntegerType' is guaranteed to be available.
+ // Otherwise it would be caught by CSGen::visitLiteralExpr
+ tc.getMaxIntegerType(dc),
builtinInitName,
nullptr,
diag::integer_literal_broken_proto,
diff --git a/lib/Sema/CSGen.cpp b/lib/Sema/CSGen.cpp
index 830442c..1ac031c 100644
--- a/lib/Sema/CSGen.cpp
+++ b/lib/Sema/CSGen.cpp
@@ -1179,7 +1179,44 @@
auto protocol = CS.getTypeChecker().getLiteralProtocol(expr);
if (!protocol)
return nullptr;
-
+
+ // Make sure that MaxIntegerType is defined if it would used later
+ // during constraint solving (CSApply).
+ if (isa<IntegerLiteralExpr>(expr) ||
+ (isa<MagicIdentifierLiteralExpr>(expr) &&
+ dyn_cast<MagicIdentifierLiteralExpr>(expr)->isColumn())) {
+
+ auto maxIntType = CS.TC.getMaxIntegerType(CS.DC);
+ if (maxIntType.isNull()) {
+ CS.TC.diagnose(expr->getLoc(), diag::no_MaxBuiltinIntegerType_found);
+ return nullptr;
+ }
+
+ // In the case of integer literal, make sure that the literal value
+ // will fit within the bit width of the maximum integer type.
+ if (IntegerLiteralExpr *intLit = dyn_cast<IntegerLiteralExpr>(expr)) {
+ unsigned maxWidth =
+ maxIntType->castTo<BuiltinIntegerType>()->getGreatestWidth();
+ APInt magnitude = intLit->getRawMagnitude();
+ unsigned magWidth = magnitude.getActiveBits();
+ bool isNegative = intLit->isNegative();
+
+ // Compute the literal bit width in the signed two's complement form.
+ // This is generally one more than the magnitude width, but is the
+ // same when the literal is of the form -2^i (for some Nat `i`).
+ unsigned signedLitWidth =
+ (isNegative && (magnitude.countTrailingZeros() == magWidth - 1))
+ ? magWidth
+ : (magWidth + 1);
+
+ if (signedLitWidth > maxWidth) { // overflow?
+ CS.TC.diagnose(expr->getLoc(),
+ diag::integer_literal_overflows_maxwidth, maxWidth,
+ signedLitWidth);
+ return nullptr;
+ }
+ }
+ }
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr),
TVO_PrefersSubtypeBinding);
diff --git a/lib/Sema/TypeCheckConstraints.cpp b/lib/Sema/TypeCheckConstraints.cpp
index 0afa47c..9b51a89 100644
--- a/lib/Sema/TypeCheckConstraints.cpp
+++ b/lib/Sema/TypeCheckConstraints.cpp
@@ -2805,9 +2805,9 @@
types[origType] = replacement;
return replacement;
},
- [&](CanType origType, Type substType, ProtocolType *conformedProtocol)
+ [&](CanType origType, Type substType, ProtocolDecl *conformedProtocol)
-> Optional<ProtocolConformanceRef> {
- return ProtocolConformanceRef(conformedProtocol->getDecl());
+ return ProtocolConformanceRef(conformedProtocol);
});
}
diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp
index f4837d1..869657c 100644
--- a/lib/Sema/TypeCheckDecl.cpp
+++ b/lib/Sema/TypeCheckDecl.cpp
@@ -3000,7 +3000,11 @@
return new (TC.Context) IntegerLiteralExpr("0", SourceLoc(),
/*Implicit=*/true);
}
-
+ // If the prevValue is not a well-typed integer, then break.
+ // This could happen if the literal value overflows _MaxBuiltinIntegerType.
+ if (!prevValue->getType())
+ return nullptr;
+
if (auto intLit = dyn_cast<IntegerLiteralExpr>(prevValue)) {
APInt nextVal = intLit->getValue() + 1;
bool negative = nextVal.slt(0);
@@ -8297,8 +8301,7 @@
},
[](CanType dependentType,
Type replacementType,
- ProtocolType *protoType) {
- auto proto = protoType->getDecl();
+ ProtocolDecl *proto) {
return ProtocolConformanceRef(proto);
});
diff --git a/lib/Sema/TypeCheckProtocol.cpp b/lib/Sema/TypeCheckProtocol.cpp
index 62bc01a..33b36ee 100644
--- a/lib/Sema/TypeCheckProtocol.cpp
+++ b/lib/Sema/TypeCheckProtocol.cpp
@@ -687,7 +687,7 @@
cs.emplace(tc, dc, ConstraintSystemOptions());
auto reqGenericEnv = reqEnvironment->getSyntheticEnvironment();
- auto &reqSubMap = reqEnvironment->getRequirementToSyntheticMap();
+ auto reqSubMap = reqEnvironment->getRequirementToSyntheticMap();
Type selfTy = proto->getSelfInterfaceType().subst(reqSubMap);
if (reqGenericEnv)
@@ -3929,13 +3929,13 @@
TypeChecker::LookUpConformance::operator()(
CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) const {
+ ProtocolDecl *conformedProtocol) const {
if (conformingReplacementType->isTypeParameter())
- return ProtocolConformanceRef(conformedProtocol->getDecl());
+ return ProtocolConformanceRef(conformedProtocol);
return tc.conformsToProtocol(
conformingReplacementType,
- conformedProtocol->getDecl(),
+ conformedProtocol,
dc,
(ConformanceCheckFlags::Used|
ConformanceCheckFlags::InExpression|
diff --git a/lib/Sema/TypeCheckSwitchStmt.cpp b/lib/Sema/TypeCheckSwitchStmt.cpp
index 4d71a6a..b2fcbed 100644
--- a/lib/Sema/TypeCheckSwitchStmt.cpp
+++ b/lib/Sema/TypeCheckSwitchStmt.cpp
@@ -524,14 +524,7 @@
[&](const Space &s) {
return this->intersect(s, TC, DC);
});
- // Optimization: Remove all empty spaces.
- SmallVector<Space, 4> filteredCases;
- std::copy_if(intersectedCases.begin(), intersectedCases.end(),
- std::back_inserter(filteredCases),
- [&](const Space &s) {
- return !s.isEmpty();
- });
- return Space::forDisjunct(filteredCases);
+ return Space::forDisjunct(intersectedCases);
}
PAIRCASE (SpaceKind::Disjunct, SpaceKind::Empty):
@@ -546,14 +539,7 @@
[&](const Space &s) {
return s.intersect(other, TC, DC);
});
- // Optimization: Remove all empty spaces.
- SmallVector<Space, 4> filteredCases;
- std::copy_if(intersectedCases.begin(), intersectedCases.end(),
- std::back_inserter(filteredCases),
- [&](const Space &s) {
- return !s.isEmpty();
- });
- return Space::forDisjunct(filteredCases);
+ return Space::forDisjunct(intersectedCases);
}
PAIRCASE (SpaceKind::Type, SpaceKind::Type): {
// Optimization: The intersection of equal types is that type.
@@ -623,8 +609,10 @@
auto j = other.getSpaces().begin();
for (; i != this->getSpaces().end() && j != other.getSpaces().end();
++i, ++j) {
- auto intersection = (*i).intersect(*j, TC, DC);
- if (intersection.simplify(TC, DC).isEmpty()) {
+ auto intersection = (*i).intersect(*j, TC, DC).simplify(TC, DC);
+ // If at least one of the constructor sub-spaces is empty,
+ // it makes the whole space empty as well.
+ if (intersection.isEmpty()) {
return Space();
}
paramSpace.push_back(intersection);
@@ -1006,16 +994,14 @@
// Simplify each component subspace. If, after simplification, any
// subspace contains an empty, then the whole space is empty.
SmallVector<Space, 4> simplifiedSpaces;
- std::transform(getSpaces().begin(), getSpaces().end(),
- std::back_inserter(simplifiedSpaces),
- [&](const Space &el) {
- return el.simplify(TC, DC);
- });
- for (auto &el : simplifiedSpaces) {
- if (el.isEmpty()) {
+ for (const auto &space : Spaces) {
+ auto simplified = space.simplify(TC, DC);
+ if (simplified.isEmpty())
return Space();
- }
+
+ simplifiedSpaces.push_back(simplified);
}
+
return Space::forConstructor(getType(), Head, canDowngradeToWarning(),
simplifiedSpaces);
}
@@ -1040,19 +1026,7 @@
[&](const Space &el){
return el.simplify(TC, DC);
});
- // If the disjunct is singular, unpack it into its component.
- if (simplifiedSpaces.size() == 1) {
- return simplifiedSpaces.front();
- }
-
- // Otherwise, remove any empties.
- SmallVector<Space, 4> compatifiedSpaces;
- std::copy_if(simplifiedSpaces.begin(), simplifiedSpaces.end(),
- std::back_inserter(compatifiedSpaces),
- [&](const Space &el) {
- return !el.isEmpty();
- });
- return Space::forDisjunct(compatifiedSpaces);
+ return Space::forDisjunct(simplifiedSpaces);
}
default:
return *this;
diff --git a/lib/Sema/TypeCheckType.cpp b/lib/Sema/TypeCheckType.cpp
index ef28745..ba411d2 100644
--- a/lib/Sema/TypeCheckType.cpp
+++ b/lib/Sema/TypeCheckType.cpp
@@ -144,6 +144,31 @@
return ::getStdlibType(*this, UInt8Type, dc, "UInt8");
}
+/// Returns the maximum-sized builtin integer type.
+Type TypeChecker::getMaxIntegerType(DeclContext *dc) {
+ if (!MaxIntegerType.isNull())
+ return MaxIntegerType;
+
+ SmallVector<ValueDecl *, 1> lookupResults;
+ getStdlibModule(dc)->lookupValue(/*AccessPath=*/{},
+ Context.Id_MaxBuiltinIntegerType,
+ NLKind::QualifiedLookup, lookupResults);
+ if (lookupResults.size() != 1)
+ return MaxIntegerType;
+
+ auto *maxIntegerTypeDecl = dyn_cast<TypeAliasDecl>(lookupResults.front());
+ if (!maxIntegerTypeDecl)
+ return MaxIntegerType;
+
+ validateDecl(maxIntegerTypeDecl);
+ if (!maxIntegerTypeDecl->hasInterfaceType() ||
+ !maxIntegerTypeDecl->getDeclaredInterfaceType()->is<BuiltinIntegerType>())
+ return MaxIntegerType;
+
+ MaxIntegerType = maxIntegerTypeDecl->getUnderlyingTypeLoc().getType();
+ return MaxIntegerType;
+}
+
/// Find the standard type of exceptions.
///
/// We call this the "exception type" to try to avoid confusion with
@@ -2310,14 +2335,14 @@
bool ok = true;
subMap = genericSig->getSubstitutionMap(
QueryTypeSubstitutionMap{genericArgMap},
- [&](CanType depTy, Type replacement, ProtocolType *proto)
+ [&](CanType depTy, Type replacement, ProtocolDecl *proto)
-> ProtocolConformanceRef {
- auto result = TC.conformsToProtocol(replacement, proto->getDecl(), DC,
+ auto result = TC.conformsToProtocol(replacement, proto, DC,
ConformanceCheckOptions());
// TODO: getSubstitutions callback ought to return Optional.
if (!result) {
ok = false;
- return ProtocolConformanceRef(proto->getDecl());
+ return ProtocolConformanceRef(proto);
}
return *result;
diff --git a/lib/Sema/TypeChecker.h b/lib/Sema/TypeChecker.h
index 5935a8df..aa14f6f 100644
--- a/lib/Sema/TypeChecker.h
+++ b/lib/Sema/TypeChecker.h
@@ -870,6 +870,7 @@
private:
Type IntLiteralType;
+ Type MaxIntegerType;
Type FloatLiteralType;
Type BooleanLiteralType;
Type UnicodeScalarType;
@@ -1048,6 +1049,7 @@
Type getIntType(DeclContext *dc);
Type getInt8Type(DeclContext *dc);
Type getUInt8Type(DeclContext *dc);
+ Type getMaxIntegerType(DeclContext *dc);
Type getNSObjectType(DeclContext *dc);
Type getNSErrorType(DeclContext *dc);
Type getObjCSelectorType(DeclContext *dc);
@@ -2084,7 +2086,7 @@
Optional<ProtocolConformanceRef>
operator()(CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) const;
+ ProtocolDecl *conformedProtocol) const;
};
/// Completely check the given conformance.
diff --git a/lib/TBDGen/TBDGen.cpp b/lib/TBDGen/TBDGen.cpp
index 57f150e..9a97e82 100644
--- a/lib/TBDGen/TBDGen.cpp
+++ b/lib/TBDGen/TBDGen.cpp
@@ -120,6 +120,12 @@
void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
addSymbol(SILDeclRef(AFD));
+ if (AFD->getAttrs().hasAttribute<CDeclAttr>()) {
+ // A @_cdecl("...") function has an extra symbol, with the name from the
+ // attribute.
+ addSymbol(SILDeclRef(AFD).asForeign());
+ }
+
if (!SwiftModule->getASTContext().isSwiftVersion3())
return;
@@ -216,12 +222,26 @@
visitNominalTypeDecl(CD);
- // The below symbols are only emitted if the class is resilient.
- if (!CD->isResilient())
+ auto hasResilientAncestor =
+ CD->isResilient(SwiftModule, ResilienceExpansion::Minimal);
+ auto ancestor = CD->getSuperclassDecl();
+ while (ancestor && !hasResilientAncestor) {
+ hasResilientAncestor |=
+ ancestor->isResilient(SwiftModule, ResilienceExpansion::Maximal);
+ ancestor = ancestor->getSuperclassDecl();
+ }
+
+ // Types with resilient superclasses have some extra symbols.
+ if (!hasResilientAncestor)
return;
addSymbol(LinkEntity::forClassMetadataBaseOffset(CD));
+ // And classes that are themselves resilient (not just a superclass) have even
+ // more.
+ if (!CD->isResilient())
+ return;
+
// Emit dispatch thunks for every new vtable entry.
struct VTableVisitor : public SILVTableVisitor<VTableVisitor> {
TBDGenVisitor &TBD;
@@ -300,6 +320,8 @@
}
void TBDGenVisitor::visitEnumDecl(EnumDecl *ED) {
+ visitNominalTypeDecl(ED);
+
if (!ED->isResilient())
return;
diff --git a/stdlib/public/SDK/Foundation/CMakeLists.txt b/stdlib/public/SDK/Foundation/CMakeLists.txt
index 67b976d..b6cdce9 100644
--- a/stdlib/public/SDK/Foundation/CMakeLists.txt
+++ b/stdlib/public/SDK/Foundation/CMakeLists.txt
@@ -26,7 +26,6 @@
NSCoder.swift
NSDate.swift
NSDictionary.swift
- NSError.c
NSError.swift
NSExpression.swift
NSFastEnumeration.swift
diff --git a/stdlib/public/SDK/Foundation/NSError.c b/stdlib/public/SDK/Foundation/NSError.c
deleted file mode 100644
index 6d06605..0000000
--- a/stdlib/public/SDK/Foundation/NSError.c
+++ /dev/null
@@ -1,34 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// This source file is part of the Swift.org open source project
-//
-// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
-// Licensed under Apache License v2.0 with Runtime Library Exception
-//
-// See https://swift.org/LICENSE.txt for license information
-// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
-//
-//===----------------------------------------------------------------------===//
-
-#include "swift/Runtime/Config.h"
-
-#if SWIFT_OBJC_INTEROP
-#include "swift/Demangling/ManglingMacros.h"
-
-// Declare dynamic lookup points for ErrorObject.mm. It uses dlsym to
-// find these symbols to locate NS/CFError Error conformance tables and
-// related items. The .desc asm directive ensures that they are
-// preserved even when statically linked into an executable and
-// stripped, so that the dlsym lookup still works.
-#define ERROROBJECT_DYNAMIC_LOOKUP_POINT(symbol) \
- extern void *MANGLE_SYM(symbol); \
- void **MANGLING_CONCAT2(ErrorObjectLookup_, MANGLE_SYM(symbol)) = &MANGLE_SYM(symbol); \
- asm(".desc _ErrorObjectLookup_" MANGLE_AS_STRING(MANGLE_SYM(symbol)) ", 0x10");
-
-ERROROBJECT_DYNAMIC_LOOKUP_POINT(So10CFErrorRefas5Error10FoundationWa)
-ERROROBJECT_DYNAMIC_LOOKUP_POINT(So8NSObjectCs8Hashable10ObjectiveCWa)
-ERROROBJECT_DYNAMIC_LOOKUP_POINT(10Foundation24_getErrorDefaultUserInfoyyXlSgxs0C0RzlF)
-ERROROBJECT_DYNAMIC_LOOKUP_POINT(10Foundation21_bridgeNSErrorToError_3outSbSo0C0C_SpyxGtAA021_ObjectiveCBridgeableE0RzlF)
-ERROROBJECT_DYNAMIC_LOOKUP_POINT(10Foundation26_ObjectiveCBridgeableErrorMp)
-
-#endif
diff --git a/stdlib/public/core/AnyHashable.swift b/stdlib/public/core/AnyHashable.swift
index b1feff9..deac970 100644
--- a/stdlib/public/core/AnyHashable.swift
+++ b/stdlib/public/core/AnyHashable.swift
@@ -287,11 +287,17 @@
}
extension AnyHashable : Hashable {
+ /// The hash value.
@inlinable // FIXME(sil-serialize-all)
public var hashValue: Int {
return _box._hashValue
}
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
_box._hash(into: &hasher)
diff --git a/stdlib/public/core/Arrays.swift.gyb b/stdlib/public/core/Arrays.swift.gyb
index 9829e01..c1cacbf 100644
--- a/stdlib/public/core/Arrays.swift.gyb
+++ b/stdlib/public/core/Arrays.swift.gyb
@@ -2263,6 +2263,11 @@
}
extension ${Self}: Hashable where Element: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(count) // discriminator
diff --git a/stdlib/public/core/Bool.swift b/stdlib/public/core/Bool.swift
index ba3f825..e757c04 100644
--- a/stdlib/public/core/Bool.swift
+++ b/stdlib/public/core/Bool.swift
@@ -87,11 +87,24 @@
self = value
}
- /// Returns a random Boolean value
+ /// Returns a random Boolean value, using the given generator as a source for
+ /// randomness.
///
- /// - Parameter generator: The random number generator to use when getting a
- /// random Boolean.
- /// - Returns: A random Boolean value.
+ /// This method returns `true` and `false` with equal probability. Use this
+ /// method to generate a random Boolean value when you are using a custom
+ /// random number generator.
+ ///
+ /// let flippedHeads = Boolean.random(using: &myGenerator)
+ /// if flippedHeads {
+ /// print("Heads, you win!")
+ /// } else {
+ /// print("Maybe another try?")
+ /// }
+ ///
+ /// - Parameter generator: The random number generator to use when creating
+ /// the new random value.
+ /// - Returns: Either `true` or `false`, randomly chosen with equal
+ /// probability.
@inlinable
public static func random<T: RandomNumberGenerator>(
using generator: inout T
@@ -99,11 +112,23 @@
return (generator.next() >> 17) & 1 == 0
}
- /// Returns a random Boolean value
+ /// Returns a random Boolean value.
///
- /// - Returns: A random Boolean value.
+ /// This method returns `true` and `false` with equal probability.
///
- /// This uses the standard library's default random number generator.
+ /// let flippedHeads = Boolean.random()
+ /// if flippedHeads {
+ /// print("Heads, you win!")
+ /// } else {
+ /// print("Maybe another try?")
+ /// }
+ ///
+ /// `Bool.random()` uses the default random generator, `Random.default`. The
+ /// call in the example above is equivalent to
+ /// `Bool.random(using: &Random.default)`.
+ ///
+ /// - Returns: Either `true` or `false`, randomly chosen with equal
+ /// probability.
@inlinable
public static func random() -> Bool {
return Bool.random(using: &Random.default)
@@ -175,6 +200,11 @@
}
extension Bool: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine((self ? 1 : 0) as UInt8)
diff --git a/stdlib/public/core/CTypes.swift b/stdlib/public/core/CTypes.swift
index 01495bd..6171591 100644
--- a/stdlib/public/core/CTypes.swift
+++ b/stdlib/public/core/CTypes.swift
@@ -174,6 +174,11 @@
}
extension OpaquePointer: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(Int(Builtin.ptrtoint_Word(_rawValue)))
diff --git a/stdlib/public/core/Character.swift b/stdlib/public/core/Character.swift
index cc96725..f868b18 100644
--- a/stdlib/public/core/Character.swift
+++ b/stdlib/public/core/Character.swift
@@ -478,6 +478,11 @@
extension Character: Hashable {
// not @inlinable (performance)
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@effects(releasenone)
public func hash(into hasher: inout Hasher) {
// FIXME(performance): constructing a temporary string is extremely
diff --git a/stdlib/public/core/ClosedRange.swift b/stdlib/public/core/ClosedRange.swift
index 4fb3ba4..c9c1917 100644
--- a/stdlib/public/core/ClosedRange.swift
+++ b/stdlib/public/core/ClosedRange.swift
@@ -168,6 +168,11 @@
extension ClosedRange.Index: Hashable
where Bound: Strideable, Bound.Stride: SignedInteger, Bound: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
switch self {
diff --git a/stdlib/public/core/Codable.swift.gyb b/stdlib/public/core/Codable.swift.gyb
index c9740c3..cd4a284 100644
--- a/stdlib/public/core/Codable.swift.gyb
+++ b/stdlib/public/core/Codable.swift.gyb
@@ -45,6 +45,10 @@
}
/// A type that can convert itself into and out of an external representation.
+///
+/// `Codable` is a type alias for the `Encodable` and `Decodable` protocols.
+/// When you use `Codable` as a type or a generic constraint, it matches
+/// any type that conforms to both protocols.
public typealias Codable = Encodable & Decodable
//===----------------------------------------------------------------------===//
@@ -1095,6 +1099,11 @@
return self.rawValue.hashValue
}
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(self.rawValue)
diff --git a/stdlib/public/core/Collection.swift b/stdlib/public/core/Collection.swift
index 943e4f9..ea57e57 100644
--- a/stdlib/public/core/Collection.swift
+++ b/stdlib/public/core/Collection.swift
@@ -812,7 +812,7 @@
///
/// let names = ["Zoey", "Chloe", "Amani", "Amaia"]
/// let randomName = names.randomElement(using: &myGenerator)!
- /// // randomName == "Amani" (maybe)
+ /// // randomName == "Amani"
///
/// - Parameter generator: The random number generator to use when choosing
/// a random element.
@@ -1038,13 +1038,13 @@
/// Returns a random element of the collection, using the given generator as
/// a source for randomness.
///
- /// You use this method to select a random element from a collection when you
- /// are using a custom random number generator. For example, call
- /// `randomElement(using:)` to select a random element from an array of names.
+ /// Call `randomElement(using:)` to select a random element from an array or
+ /// another collection when you are using a custom random number generator.
+ /// This example picks a name at random from an array:
///
/// let names = ["Zoey", "Chloe", "Amani", "Amaia"]
/// let randomName = names.randomElement(using: &myGenerator)!
- /// // randomName == "Amani" (maybe)
+ /// // randomName == "Amani"
///
/// - Parameter generator: The random number generator to use when choosing
/// a random element.
@@ -1065,12 +1065,12 @@
/// Returns a random element of the collection.
///
- /// For example, call `randomElement()` to select a random element from an
- /// array of names.
+ /// Call `randomElement()` to select a random element from an array or
+ /// another collection. This example picks a name at random from an array:
///
/// let names = ["Zoey", "Chloe", "Amani", "Amaia"]
/// let randomName = names.randomElement()!
- /// // randomName == "Amani" (perhaps)
+ /// // randomName == "Amani"
///
/// This method uses the default random generator, `Random.default`. The call
/// to `names.randomElement()` above is equivalent to calling
diff --git a/stdlib/public/core/Dictionary.swift b/stdlib/public/core/Dictionary.swift
index 90d92d1..5db3387 100644
--- a/stdlib/public/core/Dictionary.swift
+++ b/stdlib/public/core/Dictionary.swift
@@ -1449,6 +1449,11 @@
}
extension Dictionary: Hashable where Value: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
var commutativeHash = 0
diff --git a/stdlib/public/core/DropWhile.swift b/stdlib/public/core/DropWhile.swift
index 908bbb3..e488cee 100644
--- a/stdlib/public/core/DropWhile.swift
+++ b/stdlib/public/core/DropWhile.swift
@@ -183,11 +183,17 @@
}
extension LazyDropWhileCollection.Index: Hashable where Base.Index: Hashable {
+ /// The hash value.
@inlinable // FIXME(sil-serialize-all)
public var hashValue: Int {
return base.hashValue
}
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(base)
diff --git a/stdlib/public/core/Flatten.swift b/stdlib/public/core/Flatten.swift
index 5cb2829..7d36a8a 100644
--- a/stdlib/public/core/Flatten.swift
+++ b/stdlib/public/core/Flatten.swift
@@ -229,6 +229,11 @@
extension FlattenCollection.Index : Hashable
where Base.Index : Hashable, Base.Element.Index : Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(_outer)
diff --git a/stdlib/public/core/FloatingPointTypes.swift.gyb b/stdlib/public/core/FloatingPointTypes.swift.gyb
index 69d9674..6c41aff 100644
--- a/stdlib/public/core/FloatingPointTypes.swift.gyb
+++ b/stdlib/public/core/FloatingPointTypes.swift.gyb
@@ -1521,6 +1521,11 @@
% end
extension ${Self} : Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
var v = self
diff --git a/stdlib/public/core/Hashable.swift b/stdlib/public/core/Hashable.swift
index b099fe5..2cb56ec 100644
--- a/stdlib/public/core/Hashable.swift
+++ b/stdlib/public/core/Hashable.swift
@@ -40,9 +40,9 @@
/// from the `Equatable` protocol, so you must also satisfy that protocol's
/// requirements.
///
-/// A custom type's `Hashable` and `Equatable` requirements are automatically
-/// synthesized by the compiler when you declare `Hashable` conformance in the
-/// type's original declaration and your type meets these criteria:
+/// The compiler automatically synthesizes your custom type's `Hashable` and
+/// requirements when you declare `Hashable` conformance in the type's original
+/// declaration and your type meets these criteria:
///
/// - For a `struct`, all its stored properties must conform to `Hashable`.
/// - For an `enum`, all its associated values must conform to `Hashable`. (An
@@ -51,10 +51,14 @@
///
/// To customize your type's `Hashable` conformance, to adopt `Hashable` in a
/// type that doesn't meet the criteria listed above, or to extend an existing
-/// type to conform to `Hashable`, implement the `hash(into:)` function in your
-/// custom type. To ensure that your type meets the semantic requirements of the
-/// `Hashable` and `Equatable` protocols, it's a good idea to also customize
-/// your type's `Equatable` conformance to match the `hash(into:)` definition.
+/// type to conform to `Hashable`, implement the `hash(into:)` method in your
+/// custom type.
+///
+/// In your `hash(into:)` implementation, call `combine(_:)` on the provided
+/// `Hasher` instance with the essential components of your type. To ensure
+/// that your type meets the semantic requirements of the `Hashable` and
+/// `Equatable` protocols, it's a good idea to also customize your type's
+/// `Equatable` conformance to match.
///
/// As an example, consider a `GridPoint` type that describes a location in a
/// grid of buttons. Here's the initial declaration of the `GridPoint` type:
@@ -67,8 +71,8 @@
///
/// You'd like to create a set of the grid points where a user has already
/// tapped. Because the `GridPoint` type is not hashable yet, it can't be used
-/// as the `Element` type for a set. To add `Hashable` conformance, provide an
-/// `==` operator function and a `hash(into:)` method.
+/// in a set. To add `Hashable` conformance, provide an `==` operator function
+/// and implement the `hash(into:)` method.
///
/// extension GridPoint: Hashable {
/// static func == (lhs: GridPoint, rhs: GridPoint) -> Bool {
@@ -81,12 +85,9 @@
/// }
/// }
///
-/// The `hash(into:)` method in this example feeds the properties `x` and `y`
-/// to the supplied hasher; these are the same properties compared by the
-/// implementation of the `==` operator function.
-///
-/// (Because `x` and `y` are both `Hashable` themselves, you could've also let
-/// the compiler synthesize these implementations for you.)
+/// The `hash(into:)` method in this example feeds the grid point's `x` and `y`
+/// properties into the provided hasher. These properties are the same ones
+/// used to test for equality in the `==` operator function.
///
/// Now that `GridPoint` conforms to the `Hashable` protocol, you can create a
/// set of previously tapped grid points.
@@ -107,16 +108,19 @@
/// your program. Do not save hash values to use during a future execution.
var hashValue: Int { get }
- /// Hash the essential components of this value into the hash function
- /// represented by `hasher`, by feeding them into it using its `combine`
- /// methods.
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
///
- /// Essential components are precisely those that are compared in the type's
- /// implementation of `Equatable`.
+ /// Implement this method to conform to the `Hashable` protocol. The
+ /// components used for hashing must be the same as the components compared
+ /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
+ /// with each of these components.
///
- /// Note that `hash(into:)` doesn't own the hasher passed into it, so it must
- /// not call `finalize()` on it. Doing so may become a compile-time error in
- /// the future.
+ /// - Important: Never call `finalize()` on `hasher`. Doing so may become a
+ /// compile-time error in the future.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
func hash(into hasher: inout Hasher)
// Raw top-level hashing interface. Some standard library types (mostly
diff --git a/stdlib/public/core/Hasher.swift b/stdlib/public/core/Hasher.swift
index 2713311..877c3cf 100644
--- a/stdlib/public/core/Hasher.swift
+++ b/stdlib/public/core/Hasher.swift
@@ -249,7 +249,7 @@
}
}
-/// Represents the universal hash function used by `Set` and `Dictionary`.
+/// The universal hash function used by `Set` and `Dictionary`.
///
/// `Hasher` can be used to map an arbitrary sequence of bytes to an integer
/// hash value. You can feed data to the hasher using a series of calls to
diff --git a/stdlib/public/core/Integers.swift.gyb b/stdlib/public/core/Integers.swift.gyb
index 4ba8392..89916f0 100644
--- a/stdlib/public/core/Integers.swift.gyb
+++ b/stdlib/public/core/Integers.swift.gyb
@@ -3878,6 +3878,11 @@
%# end of concrete type: ${Self}
extension ${Self} : Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
// FIXME(hasher): To correctly bridge `Set`s/`Dictionary`s containing
diff --git a/stdlib/public/core/KeyPath.swift b/stdlib/public/core/KeyPath.swift
index 98a673d..be5890b 100644
--- a/stdlib/public/core/KeyPath.swift
+++ b/stdlib/public/core/KeyPath.swift
@@ -46,11 +46,17 @@
@usableFromInline // FIXME(sil-serialize-all)
internal final var _kvcKeyPathStringPtr: UnsafePointer<CChar>?
+ /// The hash value.
@inlinable // FIXME(sil-serialize-all)
final public var hashValue: Int {
return _hashValue(for: self)
}
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
final public func hash(into hasher: inout Hasher) {
return withBuffer {
diff --git a/stdlib/public/core/LifetimeManager.swift b/stdlib/public/core/LifetimeManager.swift
index 0527821..43a5ddb 100644
--- a/stdlib/public/core/LifetimeManager.swift
+++ b/stdlib/public/core/LifetimeManager.swift
@@ -111,8 +111,7 @@
/// Invokes the given closure with a pointer to the given argument.
///
/// The `withUnsafePointer(to:_:)` function is useful for calling Objective-C
-/// APIs that take in/out parameters (and default-constructible out
-/// parameters) by pointer.
+/// APIs that take in parameters by const pointer.
///
/// The pointer argument to `body` is valid only during the execution of
/// `withUnsafePointer(to:_:)`. Do not store or return the pointer for later
diff --git a/stdlib/public/core/MemoryLayout.swift b/stdlib/public/core/MemoryLayout.swift
index 52f3040..63b9022 100644
--- a/stdlib/public/core/MemoryLayout.swift
+++ b/stdlib/public/core/MemoryLayout.swift
@@ -166,23 +166,61 @@
/// Returns the offset of an inline stored property of `T` within the
/// in-memory representation of `T`.
///
- /// If the given `key` refers to inline, directly addressable storage within
+ /// If the given key refers to inline, directly addressable storage within
/// the in-memory representation of `T`, then the return value is a distance
/// in bytes that can be added to a pointer of type `T` to get a pointer to
- /// the storage accessed by `key`. If the return value is non-nil, then these
- /// formulations are equivalent:
+ /// the storage referenced by `key`.
///
- /// var root: T, value: U
- /// var key: WritableKeyPath<T, U>
- /// // Mutation through the key path...
+ /// If the return value of this method is non-`nil`, then accessing the value
+ /// by key path or by an offset pointer are equivalent. For example, for a
+ /// variable `root` of type `T`, `value` of type `U`, and a key path `key`
+ /// of type `WritableKeyPath<T, U>`:
+ ///
+ /// // Mutation through the key path
/// root[keyPath: key] = value
- /// // ...is exactly equivalent to mutation through the offset pointer...
- /// withUnsafeMutablePointer(to: &root) {
- /// (UnsafeMutableRawPointer($0) + MemoryLayout<T>.offset(of: key))
- /// // ...which can be assumed to be bound to the target type
- /// .assumingMemoryBound(to: U.self).pointee = value
+ ///
+ /// // Mutation through the offset pointer
+ /// withUnsafeMutableBytes(of: &root) { bytes in
+ /// let rawPointerToValue = bytes.baseAddress! + MemoryLayout<T>.offset(of: key)!
+ /// let pointerToValue = rawPointerToValue.assumingMemoryBound(to: U.self)
+ /// pointerToValue.pointee = value
/// }
///
+ /// A property has inline, directly addressable storage when it is a stored
+ /// property for which no additional work is required to extract or set the
+ /// value. Properties are not directly accessible if they trigger any
+ /// `didSet` or `willSet` accessors, perform any representation changes such
+ /// as bridging or closure reabstraction, or mask the value out of
+ /// overlapping storage as for packed bitfields. In addition, because class
+ /// instance properties are always stored out-of-line, their positions are
+ /// not accessible using `offset(of:)`.
+ ///
+ /// For example, in the `ProductCategory` type defined here, only
+ /// `\.updateCounter`, `\.identifier`, and `\.identifier.name` refer to
+ /// properties with inline, directly addressable storage:
+ ///
+ /// struct ProductCategory {
+ /// struct Identifier {
+ /// var name: String // addressable
+ /// }
+ ///
+ /// var identifier: Identifier // addressable
+ /// var updateCounter: Int // addressable
+ /// var products: [Product] { // not addressable: didSet handler
+ /// didSet { updateCounter += 1 }
+ /// }
+ /// var productCount: Int { // not addressable: computed property
+ /// return products.count
+ /// }
+ /// }
+ ///
+ /// When using `offset(of:)` with a type imported from a library, don't
+ /// assume that future versions of the library will have the same behavior.
+ /// If a property is converted from a stored property to a computed property,
+ /// the result of `offset(of:)` changes to `nil`. That kind of conversion is
+ /// non-breaking in other contexts, but would trigger a runtime error if the
+ /// result of `offset(of:)` is force-unwrapped.
+ ///
/// - Parameter key: A key path referring to storage that can be accessed
/// through a value of type `T`.
/// - Returns: The offset in bytes from a pointer to a value of type `T`
@@ -190,28 +228,6 @@
/// such offset is available for the storage referenced by `key`, such as
/// because `key` is computed, has observers, requires reabstraction, or
/// overlaps storage with other properties.
- ///
- /// A property has inline, directly addressable storage when it is a stored
- /// property for which no additional work is required to extract or set the
- /// value. For example:
- ///
- /// struct ProductCategory {
- /// var name: String // inline, directly-addressable
- /// var updateCounter: Int // inline, directly-addressable
- /// var productCount: Int { // computed properties are not directly addressable
- /// return products.count
- /// }
- /// var products: [Product] { // didSet/willSet properties are not directly addressable
- /// didSet { updateCounter += 1 }
- /// }
- /// }
- ///
- /// When using `offset(of:)` with a type imported from a library, don't assume
- /// that future versions of the library will have the same behavior. If a
- /// property is converted from a stored property to a computed property, the
- /// result of `offset(of:)` changes to `nil`. That kind of conversion is
- /// non-breaking in other contexts, but would trigger a runtime error if the
- /// result of `offset(of:)` is force-unwrapped.
@inlinable // FIXME(sil-serialize-all)
@_transparent
public static func offset(of key: PartialKeyPath<T>) -> Int? {
diff --git a/stdlib/public/core/NewtypeWrapper.swift b/stdlib/public/core/NewtypeWrapper.swift
index 97a7c4b..b535310 100644
--- a/stdlib/public/core/NewtypeWrapper.swift
+++ b/stdlib/public/core/NewtypeWrapper.swift
@@ -16,11 +16,17 @@
public protocol _SwiftNewtypeWrapper : RawRepresentable { }
extension _SwiftNewtypeWrapper where Self: Hashable, Self.RawValue : Hashable {
+ /// The hash value.
@inlinable // FIXME(sil-serialize-all)
public var hashValue: Int {
return rawValue.hashValue
}
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(rawValue)
diff --git a/stdlib/public/core/ObjectIdentifier.swift b/stdlib/public/core/ObjectIdentifier.swift
index e0fe671..d049a1f 100644
--- a/stdlib/public/core/ObjectIdentifier.swift
+++ b/stdlib/public/core/ObjectIdentifier.swift
@@ -84,6 +84,11 @@
}
extension ObjectIdentifier: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(Int(Builtin.ptrtoint_Word(_value)))
diff --git a/stdlib/public/core/Optional.swift b/stdlib/public/core/Optional.swift
index 49992db..66c42ef 100644
--- a/stdlib/public/core/Optional.swift
+++ b/stdlib/public/core/Optional.swift
@@ -72,7 +72,7 @@
/// optional chaining to access the `hasSuffix(_:)` method on a `String?`
/// instance.
///
-/// if let isPNG = imagePaths["star"]?.hasSuffix(".png") {
+/// if imagePaths["star"]?.hasSuffix(".png") == true {
/// print("The star image is in PNG format")
/// }
/// // Prints "The star image is in PNG format"
@@ -410,6 +410,11 @@
}
extension Optional: Hashable where Wrapped: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
switch self {
diff --git a/stdlib/public/core/PrefixWhile.swift b/stdlib/public/core/PrefixWhile.swift
index 0865eeb..cc2288b 100644
--- a/stdlib/public/core/PrefixWhile.swift
+++ b/stdlib/public/core/PrefixWhile.swift
@@ -202,6 +202,11 @@
}
extension LazyPrefixWhileCollection.Index: Hashable where Base.Index: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
switch _value {
diff --git a/stdlib/public/core/Random.swift b/stdlib/public/core/Random.swift
index 38e7043..1716a0e 100644
--- a/stdlib/public/core/Random.swift
+++ b/stdlib/public/core/Random.swift
@@ -12,7 +12,7 @@
import SwiftShims
-/// A type that can provide uniformly distributed random data.
+/// A type that provides uniformly distributed random data.
///
/// When you call methods that use random data, such as creating new random
/// values or shuffling a collection, you can pass a `RandomNumberGenerator`
@@ -24,14 +24,14 @@
/// version that uses the default generator. For example, this `Weekday`
/// enumeration provides static methods that return a random day of the week:
///
-/// enum Weekday : CaseIterable {
+/// enum Weekday: CaseIterable {
/// case sunday, monday, tuesday, wednesday, thursday, friday, saturday
///
-/// static func randomWeekday<G: RandomNumberGenerator>(using generator: inout G) -> Weekday {
+/// static func random<G: RandomNumberGenerator>(using generator: inout G) -> Weekday {
/// return Weekday.allCases.randomElement(using: &generator)!
/// }
///
-/// static func randomWeekday() -> Weekday {
+/// static func random() -> Weekday {
/// return Weekday.randomWeekday(using: &Random.default)
/// }
/// }
@@ -118,18 +118,20 @@
/// let x = Int.random(in: 1...100)
/// let y = Int.random(in: 1...100, using: &Random.default)
///
-/// `Random.default` is safe to use in multiple threads, and uses a
-/// cryptographically secure algorithm whenever possible.
+/// `Random.default` is automatically seeded, is safe to use in multiple
+/// threads, and uses a cryptographically secure algorithm whenever possible.
///
/// Platform Implementation of `Random`
/// ===================================
///
-/// - Apple platforms all use `arc4random_buf(3)`.
-/// - `Linux`, `Android`, `Cygwin`, `Haiku`, `FreeBSD`, and `PS4` all try to
-/// use `getrandom(2)`, but if it doesn't exist then they read from
-/// `/dev/urandom`.
-/// - `Fuchsia` calls `getentropy(3)`.
-/// - `Windows` calls `BCryptGenRandom`.
+/// While the `Random.default` generator is automatically seeded and
+/// thread-safe on every platform, the cryptographic quality of the stream of
+/// random data produced by the generator may vary. For more detail, see the
+/// documentation for the APIs used by each platform.
+///
+/// - Apple platforms use `arc4random_buf(3)`.
+/// - Linux platforms use `getrandom(2)` when available; otherwise, they read
+/// from `/dev/urandom`.
public struct Random : RandomNumberGenerator {
/// The default instance of the `Random` random number generator.
public static var `default`: Random {
diff --git a/stdlib/public/core/Range.swift b/stdlib/public/core/Range.swift
index a085817..5c79478 100644
--- a/stdlib/public/core/Range.swift
+++ b/stdlib/public/core/Range.swift
@@ -405,6 +405,11 @@
}
extension Range: Hashable where Bound: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(lowerBound)
diff --git a/stdlib/public/core/RangeReplaceableCollection.swift b/stdlib/public/core/RangeReplaceableCollection.swift
index 1b5a78f..ba754af 100644
--- a/stdlib/public/core/RangeReplaceableCollection.swift
+++ b/stdlib/public/core/RangeReplaceableCollection.swift
@@ -1087,7 +1087,15 @@
}
extension RangeReplaceableCollection where Self: MutableCollection {
- /// Removes from the collection all elements that satisfy the given predicate.
+ /// Removes all the elements that satisfy the given predicate.
+ ///
+ /// Use this method to remove every element in a collection that meets
+ /// particular criteria. This example removes all the odd values from an
+ /// array of numbers:
+ ///
+ /// var numbers = [5, 6, 7, 8, 9, 10, 11]
+ /// numbers.removeAll(where: { $0 % 2 == 1 })
+ /// // numbers == [6, 8, 10]
///
/// - Parameter shouldBeRemoved: A closure that takes an element of the
/// sequence as its argument and returns a Boolean value indicating
@@ -1112,7 +1120,16 @@
}
extension RangeReplaceableCollection {
- /// Removes from the collection all elements that satisfy the given predicate.
+ /// Removes all the elements that satisfy the given predicate.
+ ///
+ /// Use this method to remove every element in a collection that meets
+ /// particular criteria. This example removes all the vowels from a string:
+ ///
+ /// var phrase = "The rain in Spain stays mainly in the plain."
+ ///
+ /// let vowels: Set<Character> = ["a", "e", "i", "o", "u"]
+ /// phrase.removeAll(where: { vowels.contains($0) })
+ /// // phrase == "Th rn n Spn stys mnly n th pln."
///
/// - Parameter shouldBeRemoved: A closure that takes an element of the
/// sequence as its argument and returns a Boolean value indicating
diff --git a/stdlib/public/core/Reverse.swift b/stdlib/public/core/Reverse.swift
index 517bad6..ae7f315 100644
--- a/stdlib/public/core/Reverse.swift
+++ b/stdlib/public/core/Reverse.swift
@@ -191,6 +191,11 @@
}
extension ReversedCollection.Index: Hashable where Base.Index: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(base)
diff --git a/stdlib/public/core/Set.swift b/stdlib/public/core/Set.swift
index 93cd06e..1cbbadc 100644
--- a/stdlib/public/core/Set.swift
+++ b/stdlib/public/core/Set.swift
@@ -484,6 +484,11 @@
}
extension Set: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
// FIXME(ABI)#177: <rdar://problem/18915294> Cache Set<T> hashValue
@@ -3648,6 +3653,11 @@
}
}
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
#if _runtime(_ObjC)
diff --git a/stdlib/public/core/StringGuts.swift b/stdlib/public/core/StringGuts.swift
index 7c7a028..203fece 100644
--- a/stdlib/public/core/StringGuts.swift
+++ b/stdlib/public/core/StringGuts.swift
@@ -966,18 +966,22 @@
}
}
- // TODO (TODO: JIRA): check if we're small and still within capacity
+ // Small strings can accomodate small capacities
+ if capacity <= _SmallUTF8String.capacity {
+ return
+ }
+ let selfCount = self.count
if isASCII {
let storage = _copyToNativeStorage(
of: UInt8.self,
- from: 0..<self.count,
+ from: 0..<selfCount,
unusedCapacity: Swift.max(capacity - count, 0))
self = _StringGuts(_large: storage)
} else {
let storage = _copyToNativeStorage(
of: UTF16.CodeUnit.self,
- from: 0..<self.count,
+ from: 0..<selfCount,
unusedCapacity: Swift.max(capacity - count, 0))
self = _StringGuts(_large: storage)
}
diff --git a/stdlib/public/core/StringHashable.swift b/stdlib/public/core/StringHashable.swift
index 32338e6..d9ffbfa 100644
--- a/stdlib/public/core/StringHashable.swift
+++ b/stdlib/public/core/StringHashable.swift
@@ -186,6 +186,11 @@
}
extension String : Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable
public func hash(into hasher: inout Hasher) {
_guts.hash(into: &hasher)
@@ -198,6 +203,11 @@
}
extension StringProtocol {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable
public func hash(into hasher: inout Hasher) {
_wholeString._guts.hash(_encodedOffsetRange, into: &hasher)
diff --git a/stdlib/public/core/StringIndex.swift b/stdlib/public/core/StringIndex.swift
index 1125bad..dd4e624 100644
--- a/stdlib/public/core/StringIndex.swift
+++ b/stdlib/public/core/StringIndex.swift
@@ -65,6 +65,11 @@
}
extension String.Index : Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(_compoundOffset)
diff --git a/stdlib/public/core/UnicodeScalar.swift b/stdlib/public/core/UnicodeScalar.swift
index b1e0c6b..3a729a1 100644
--- a/stdlib/public/core/UnicodeScalar.swift
+++ b/stdlib/public/core/UnicodeScalar.swift
@@ -311,6 +311,11 @@
}
extension Unicode.Scalar : Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(self.value)
diff --git a/stdlib/public/core/UnsafePointer.swift.gyb b/stdlib/public/core/UnsafePointer.swift.gyb
index 88abd14..9bd12e9 100644
--- a/stdlib/public/core/UnsafePointer.swift.gyb
+++ b/stdlib/public/core/UnsafePointer.swift.gyb
@@ -897,6 +897,11 @@
}
}
extension ${Self}: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(UInt(bitPattern: self))
diff --git a/stdlib/public/core/UnsafeRawPointer.swift.gyb b/stdlib/public/core/UnsafeRawPointer.swift.gyb
index 5ca8fc7..f235e0f 100644
--- a/stdlib/public/core/UnsafeRawPointer.swift.gyb
+++ b/stdlib/public/core/UnsafeRawPointer.swift.gyb
@@ -965,6 +965,11 @@
}
extension ${Self}: Hashable {
+ /// Hashes the essential components of this value by feeding them into the
+ /// given hasher.
+ ///
+ /// - Parameter hasher: The hasher to use when combining the components
+ /// of this instance.
@inlinable // FIXME(sil-serialize-all)
public func hash(into hasher: inout Hasher) {
hasher.combine(Int(bitPattern: self))
diff --git a/stdlib/public/core/VarArgs.swift b/stdlib/public/core/VarArgs.swift
index e51111e..07a6662 100644
--- a/stdlib/public/core/VarArgs.swift
+++ b/stdlib/public/core/VarArgs.swift
@@ -32,6 +32,11 @@
/// arguments. C functions that use the `...` syntax for variadic arguments
/// are not imported, and therefore can't be called using `CVarArg` arguments.
///
+/// If you need to pass an optional pointer as a `CVarArg` argument, use the
+/// `Int(bitPattern:)` initializer to interpret the optional pointer as an
+/// `Int` value, which has the same C variadic calling conventions as a pointer
+/// on all supported platforms.
+///
/// - Note: Declaring conformance to the `CVarArg` protocol for types defined
/// outside the standard library is not supported.
public protocol CVarArg {
@@ -102,6 +107,11 @@
/// execution of `withVaList(_:_:)`. Do not store or return the pointer for
/// later use.
///
+/// If you need to pass an optional pointer as a `CVarArg` argument, use the
+/// `Int(bitPattern:)` initializer to interpret the optional pointer as an
+/// `Int` value, which has the same C variadic calling conventions as a pointer
+/// on all supported platforms.
+///
/// - Parameters:
/// - args: An array of arguments to convert to a C `va_list` pointer.
/// - body: A closure with a `CVaListPointer` parameter that references the
@@ -143,6 +153,11 @@
/// uses, such as in a `class` initializer, you may find that the language
/// rules do not allow you to use `withVaList(_:_:)` as intended.
///
+/// If you need to pass an optional pointer as a `CVarArg` argument, use the
+/// `Int(bitPattern:)` initializer to interpret the optional pointer as an
+/// `Int` value, which has the same C variadic calling conventions as a pointer
+/// on all supported platforms.
+///
/// - Parameter args: An array of arguments to convert to a C `va_list`
/// pointer.
/// - Returns: A pointer that can be used with C functions that take a
diff --git a/stdlib/public/runtime/AnyHashableSupport.cpp b/stdlib/public/runtime/AnyHashableSupport.cpp
index 54de033..2e9035f 100644
--- a/stdlib/public/runtime/AnyHashableSupport.cpp
+++ b/stdlib/public/runtime/AnyHashableSupport.cpp
@@ -194,32 +194,10 @@
return;
}
- case MetadataKind::Struct:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
+ default:
_swift_makeAnyHashableUsingDefaultRepresentation(
value, anyHashableResultPointer, type, hashableWT);
return;
-
- case MetadataKind::ErrorObject:
- // ErrorObject metadata is not used for any Swift-level values, so
- // this case is unreachable.
- _failCorruptType(type);
-
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
- case MetadataKind::Function:
- case MetadataKind::Existential:
- case MetadataKind::Metatype:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- // We assume that the value can not be an existential,
- // because existentials can't conform to Hashable today.
- //
- // FIXME: handle generalized existentials when Swift has them.
- _failCorruptType(type);
}
- _failCorruptType(type);
}
diff --git a/stdlib/public/runtime/Casting.cpp b/stdlib/public/runtime/Casting.cpp
index 26e1ad9..fc98c18 100644
--- a/stdlib/public/runtime/Casting.cpp
+++ b/stdlib/public/runtime/Casting.cpp
@@ -352,21 +352,13 @@
return _unknownClassConformsToObjCProtocol(value, protocol);
return false;
#else
- _failCorruptType(type);
+ return false;
#endif
+
case MetadataKind::Existential: // FIXME
case MetadataKind::ExistentialMetatype: // FIXME
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+ default:
return false;
}
@@ -490,20 +482,11 @@
}
// Non-polymorphic types.
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+ default:
outValue = value;
outType = type;
return;
}
- _failCorruptType(type);
}
extern "C" const Metadata *
@@ -544,23 +527,9 @@
}
// None of the rest of these require deallocation.
- case MetadataKind::Class:
- case MetadataKind::ForeignClass:
- case MetadataKind::ObjCClassWrapper:
- case MetadataKind::Metatype:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+ default:
return;
}
- _failCorruptType(type);
}
#if SWIFT_OBJC_INTEROP
@@ -575,19 +544,7 @@
return (id)metatype->getObjCClassObject();
// Other kinds of metadata don't cast to AnyObject.
- case MetadataKind::Struct:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
- case MetadataKind::Function:
- case MetadataKind::Existential:
- case MetadataKind::Metatype:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::ForeignClass:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
+ default:
return nullptr;
}
}
@@ -603,19 +560,7 @@
return (id)metatype->getObjCClassObject();
// Other kinds of metadata don't cast to AnyObject.
- case MetadataKind::Struct:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
- case MetadataKind::Function:
- case MetadataKind::Existential:
- case MetadataKind::Metatype:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::ForeignClass:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject: {
+ default: {
std::string sourceName = nameForMetadata(metatype);
swift_dynamicCastFailure(metatype, sourceName.c_str(),
nullptr, "AnyObject",
@@ -876,12 +821,7 @@
#endif
LLVM_FALLTHROUGH;
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
+ default:
return fallbackForNonClass();
}
@@ -1010,7 +950,7 @@
= static_cast<const ObjCClassWrapperMetadata *>(targetType)->Class;
return swift_dynamicCastObjCClass(object, targetClassType);
#else
- _failCorruptType(targetType);
+ return nullptr;
#endif
}
@@ -1019,7 +959,7 @@
auto targetClassType = static_cast<const ForeignClassMetadata*>(targetType);
return swift_dynamicCastForeignClass(object, targetClassType);
#else
- _failCorruptType(targetType);
+ return nullptr;
#endif
}
@@ -1027,20 +967,9 @@
return _dynamicCastUnknownClassToExistential(object,
static_cast<const ExistentialTypeMetadata *>(targetType));
}
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+ default:
return nullptr;
}
- _failCorruptType(targetType);
}
/// Perform a dynamic class of some sort of class instance to some
@@ -1060,7 +989,7 @@
= static_cast<const ObjCClassWrapperMetadata *>(targetType)->Class;
return swift_dynamicCastObjCClassUnconditional(object, targetClassType);
#else
- _failCorruptType(targetType);
+ swift_dynamicCastFailure(_swift_getClass(object), targetType);
#endif
}
@@ -1069,7 +998,7 @@
auto targetClassType = static_cast<const ForeignClassMetadata*>(targetType);
return swift_dynamicCastForeignClassUnconditional(object, targetClassType);
#else
- _failCorruptType(targetType);
+ swift_dynamicCastFailure(_swift_getClass(object), targetType);
#endif
}
@@ -1082,21 +1011,10 @@
swift_dynamicCastFailure(_swift_getClass(object), targetType);
}
-
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+
+ default:
swift_dynamicCastFailure(_swift_getClass(object), targetType);
}
- _failCorruptType(targetType);
}
/******************************************************************************/
@@ -1146,18 +1064,7 @@
return nullptr;
}
- case MetadataKind::Existential:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+ default:
return nullptr;
}
break;
@@ -1177,34 +1084,12 @@
(const ClassMetadata*)targetType))
return origSourceType;
return nullptr;
- case MetadataKind::Existential:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+ default:
return nullptr;
}
break;
- case MetadataKind::Existential:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+ default:
// The cast succeeds only if the metadata pointers are statically
// equivalent.
if (sourceType != targetType)
@@ -1258,18 +1143,7 @@
// If we returned, then the cast succeeded.
return origSourceType;
}
- case MetadataKind::Existential:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+ default:
swift_dynamicCastFailure(sourceType, targetType);
}
break;
@@ -1290,41 +1164,17 @@
(const ClassMetadata*)targetType);
// If we returned, then the cast succeeded.
return origSourceType;
- case MetadataKind::Existential:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+ default:
swift_dynamicCastFailure(sourceType, targetType);
}
break;
- case MetadataKind::Existential:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+ default:
// The cast succeeds only if the metadata pointers are statically
// equivalent.
if (sourceType != targetType)
swift_dynamicCastFailure(sourceType, targetType);
return origSourceType;
}
-
- swift_runtime_unreachable("Unhandled MetadataKind in switch.");
}
/******************************************************************************/
@@ -1688,18 +1538,10 @@
return _dynamicCastUnknownClassToMetatype(dest, object, targetType, flags);
}
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
case MetadataKind::Struct: // AnyHashable, if metatypes implement Hashable
- case MetadataKind::Tuple:
+ default:
return _fail(src, srcType, targetType, flags);
}
- _failCorruptType(srcType);
}
/// Perform a dynamic cast of a metatype to an existential metatype type.
@@ -1863,18 +1705,10 @@
targetType, flags);
}
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
case MetadataKind::Struct: // AnyHashable, if metatypes implement Hashable
- case MetadataKind::Tuple:
+ default:
return _fail(src, srcType, targetType, flags);
}
- _failCorruptType(srcType);
}
/******************************************************************************/
@@ -1935,23 +1769,9 @@
static_cast<const ExistentialTypeMetadata*>(srcType),
targetType, flags);
- case MetadataKind::Class:
- case MetadataKind::Struct:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::ObjCClassWrapper:
- case MetadataKind::ForeignClass:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
+ default:
return _fail(src, srcType, targetType, flags);
}
-
- swift_runtime_unreachable("Unhandled MetadataKind in switch.");
}
/******************************************************************************/
@@ -2519,14 +2339,7 @@
return _fail(src, srcType, targetType, flags);
}
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
+ default:
return _fail(src, srcType, targetType, flags);
}
break;
@@ -2601,26 +2414,14 @@
}
break;
- case MetadataKind::Existential:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
+ default:
break;
}
LLVM_FALLTHROUGH;
// The non-polymorphic types.
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
+ default:
// If there's an exact type match, we're done.
if (srcType == targetType)
return _succeed(dest, src, srcType, flags);
@@ -2643,7 +2444,6 @@
// Otherwise, we have a failure.
return _fail(src, srcType, targetType, flags);
}
- _failCorruptType(srcType);
}
static inline bool swift_isClassOrObjCExistentialTypeImpl(const Metadata *T) {
@@ -3028,19 +2828,7 @@
break;
}
- case MetadataKind::Class:
- case MetadataKind::Struct:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
- case MetadataKind::Function:
- case MetadataKind::Existential:
- case MetadataKind::ObjCClassWrapper:
- case MetadataKind::ForeignClass:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
+ default:
break;
}
return nullptr;
diff --git a/stdlib/public/runtime/Demangle.cpp b/stdlib/public/runtime/Demangle.cpp
index 4a3f522..07fb3fe 100644
--- a/stdlib/public/runtime/Demangle.cpp
+++ b/stdlib/public/runtime/Demangle.cpp
@@ -631,18 +631,19 @@
}
return tupleNode;
}
- case MetadataKind::Opaque: {
- if (auto builtinType = _buildDemanglerForBuiltinType(type, Dem))
- return builtinType;
-
- // FIXME: Some opaque types do have manglings, but we don't have enough info
- // to figure them out.
- break;
- }
case MetadataKind::HeapLocalVariable:
case MetadataKind::HeapGenericLocalVariable:
case MetadataKind::ErrorObject:
break;
+ case MetadataKind::Opaque:
+ default: {
+ if (auto builtinType = _buildDemanglerForBuiltinType(type, Dem))
+ return builtinType;
+
+ // FIXME: Some opaque types do have manglings, but we don't have enough info
+ // to figure them out.
+ break;
+ }
}
// Not a type.
return nullptr;
diff --git a/stdlib/public/runtime/ErrorDefaultImpls.cpp b/stdlib/public/runtime/ErrorDefaultImpls.cpp
index 2599da3..f4ad4a0 100644
--- a/stdlib/public/runtime/ErrorDefaultImpls.cpp
+++ b/stdlib/public/runtime/ErrorDefaultImpls.cpp
@@ -32,20 +32,7 @@
result = T->vw_getEnumTag(error);
break;
- case MetadataKind::Class:
- case MetadataKind::ObjCClassWrapper:
- case MetadataKind::ForeignClass:
- case MetadataKind::Function:
- case MetadataKind::Struct:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
- case MetadataKind::Existential:
- case MetadataKind::Metatype:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
+ default:
result = 1;
break;
}
diff --git a/stdlib/public/runtime/ErrorObject.mm b/stdlib/public/runtime/ErrorObject.mm
index 1896f5c..3367a9f 100644
--- a/stdlib/public/runtime/ErrorObject.mm
+++ b/stdlib/public/runtime/ErrorObject.mm
@@ -220,21 +220,6 @@
object_dispose((id)error);
}
-/// Look up a symbol that points to something else. Treats the symbol as
-/// a void** and dereferences it if it's non-NULL. Returns NULL if the
-/// symbol can't be found or if the value is NULL.
-static void *dynamicLookupSymbol(const char *name) {
- void **ptr = reinterpret_cast<void **>(dlsym(RTLD_DEFAULT, name));
- if (!ptr) return nullptr;
- return *ptr;
-}
-
-/// Look up an indirect pointer to a mangled Swift symbol, automatically
-/// prepending the ErrorObjectLookup_ prefix. Used to find the various
-/// Foundation overlay symbols for Error bridging.
-#define DYNAMIC_LOOKUP_SYMBOL(symbol) \
- dynamicLookupSymbol("ErrorObjectLookup_" MANGLE_AS_STRING(MANGLE_SYM(symbol)))
-
static const WitnessTable *getNSErrorConformanceToError() {
// CFError and NSError are toll-free-bridged, so we can use either type's
// witness table interchangeably. CFError's is potentially slightly more
@@ -243,7 +228,8 @@
// to assume that that's been linked in if a user is using NSError in their
// Swift source.
- auto TheWitnessTable = SWIFT_LAZY_CONSTANT(DYNAMIC_LOOKUP_SYMBOL(So10CFErrorRefas5Error10FoundationWa));
+ auto TheWitnessTable = SWIFT_LAZY_CONSTANT(dlsym(RTLD_DEFAULT,
+ MANGLE_AS_STRING(MANGLE_SYM(So10CFErrorRefas5Error10FoundationWa))));
assert(TheWitnessTable &&
"Foundation overlay not loaded, or 'CFError : Error' conformance "
"not available");
@@ -252,7 +238,8 @@
}
static const HashableWitnessTable *getNSErrorConformanceToHashable() {
- auto TheWitnessTable = SWIFT_LAZY_CONSTANT(DYNAMIC_LOOKUP_SYMBOL(So8NSObjectCs8Hashable10ObjectiveCWa));
+ auto TheWitnessTable = SWIFT_LAZY_CONSTANT(dlsym(RTLD_DEFAULT,
+ MANGLE_AS_STRING(MANGLE_SYM(So8NSObjectCs8Hashable10ObjectiveCWa))));
assert(TheWitnessTable &&
"ObjectiveC overlay not loaded, or 'NSObject : Hashable' conformance "
"not available");
@@ -392,7 +379,8 @@
// public func Foundation._getErrorDefaultUserInfo<T: Error>(_ error: T)
// -> AnyObject?
auto foundationGetDefaultUserInfo = SWIFT_LAZY_CONSTANT(
- reinterpret_cast<GetDefaultFn*> (DYNAMIC_LOOKUP_SYMBOL(10Foundation24_getErrorDefaultUserInfoyyXlSgxs0C0RzlF)));
+ reinterpret_cast<GetDefaultFn*> (dlsym(RTLD_DEFAULT,
+ MANGLE_AS_STRING(MANGLE_SYM(10Foundation24_getErrorDefaultUserInfoyyXlSgxs0C0RzlF)))));
if (!foundationGetDefaultUserInfo) {
SWIFT_CC_PLUSONE_GUARD(T->vw_destroy(error));
return nullptr;
@@ -510,18 +498,7 @@
break;
}
// Not a class.
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Existential:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Function:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
- case MetadataKind::Metatype:
- case MetadataKind::Opaque:
- case MetadataKind::Struct:
- case MetadataKind::Tuple:
+ default:
return false;
}
@@ -532,10 +509,12 @@
bool BridgeFn(NSError *, OpaqueValue*, const Metadata *,
const WitnessTable *);
auto bridgeNSErrorToError = SWIFT_LAZY_CONSTANT(
- reinterpret_cast<BridgeFn*>(DYNAMIC_LOOKUP_SYMBOL(10Foundation21_bridgeNSErrorToError_3outSbSo0C0C_SpyxGtAA021_ObjectiveCBridgeableE0RzlF)));
+ reinterpret_cast<BridgeFn*>(dlsym(RTLD_DEFAULT,
+ MANGLE_AS_STRING(MANGLE_SYM(10Foundation21_bridgeNSErrorToError_3outSbSo0C0C_SpyxGtAA021_ObjectiveCBridgeableE0RzlF)))));
// protocol _ObjectiveCBridgeableError
auto TheObjectiveCBridgeableError = SWIFT_LAZY_CONSTANT(
- reinterpret_cast<const ProtocolDescriptor *>(DYNAMIC_LOOKUP_SYMBOL(10Foundation26_ObjectiveCBridgeableErrorMp)));
+ reinterpret_cast<const ProtocolDescriptor *>(dlsym(RTLD_DEFAULT,
+ MANGLE_AS_STRING(MANGLE_SYM(10Foundation26_ObjectiveCBridgeableErrorMp)))));
// If the Foundation overlay isn't loaded, then arbitrary NSErrors can't be
// bridged.
diff --git a/stdlib/public/runtime/Leaks.mm b/stdlib/public/runtime/Leaks.mm
index 1c15aec..4401155 100644
--- a/stdlib/public/runtime/Leaks.mm
+++ b/stdlib/public/runtime/Leaks.mm
@@ -131,6 +131,9 @@
kindDescriptor = #name; \
break;
#include "swift/ABI/MetadataKind.def"
+ default:
+ kindDescriptor = "unknown";
+ break;
}
if (auto *NTD =
diff --git a/stdlib/public/runtime/Metadata.cpp b/stdlib/public/runtime/Metadata.cpp
index b901d88..2a7a72f 100644
--- a/stdlib/public/runtime/Metadata.cpp
+++ b/stdlib/public/runtime/Metadata.cpp
@@ -3169,23 +3169,9 @@
return wrapper->Class;
}
// Other kinds of types don't have class objects.
- case MetadataKind::Struct:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::ForeignClass:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
- case MetadataKind::Function:
- case MetadataKind::Existential:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::Metatype:
- case MetadataKind::HeapLocalVariable:
- case MetadataKind::HeapGenericLocalVariable:
- case MetadataKind::ErrorObject:
+ default:
return nullptr;
}
-
- swift_runtime_unreachable("Unhandled MetadataKind in switch.");
}
template <> OpaqueValue *Metadata::allocateBoxForExistentialIn(ValueBuffer *buffer) const {
@@ -3259,9 +3245,10 @@
case MetadataKind::NAME: \
return #NAME;
#include "swift/ABI/MetadataKind.def"
+
+ default:
+ return "<unknown>";
}
-
- swift_runtime_unreachable("Unhandled metadata kind?!");
}
#ifndef NDEBUG
diff --git a/stdlib/public/runtime/MetadataLookup.cpp b/stdlib/public/runtime/MetadataLookup.cpp
index 85a6b42..7efbc04 100644
--- a/stdlib/public/runtime/MetadataLookup.cpp
+++ b/stdlib/public/runtime/MetadataLookup.cpp
@@ -1150,8 +1150,10 @@
}
}
+ auto typeName = field.getMangledTypeName(0);
+
auto typeInfo = _getTypeByMangledName(
- field.getMangledTypeName(0),
+ typeName,
[&](unsigned depth, unsigned index) -> const Metadata * {
if (depth >= descriptorPath.size())
return nullptr;
@@ -1175,6 +1177,16 @@
return base->getGenericArgs()[flatIndex];
});
+ // If demangling the type failed, pretend it's an empty type instead with
+ // a log message.
+ if (typeInfo == nullptr) {
+ typeInfo = TypeInfo(&METADATA_SYM(EMPTY_TUPLE_MANGLING), {});
+ warning(0, "SWIFT RUNTIME BUG: unable to demangle type of field '%*s'. "
+ "mangled type name is '%*s'",
+ (int)name.size(), name.data(),
+ (int)typeName.size(), typeName.data());
+ }
+
callback(name, FieldType()
.withType(typeInfo)
.withIndirect(field.isIndirectCase())
diff --git a/stdlib/public/runtime/Private.h b/stdlib/public/runtime/Private.h
index 43b39d8..3bcfcaa 100644
--- a/stdlib/public/runtime/Private.h
+++ b/stdlib/public/runtime/Private.h
@@ -60,7 +60,7 @@
/// itself related info has to be bundled with it.
class TypeInfo {
const Metadata *Type;
- const TypeReferenceOwnership ReferenceOwnership;
+ TypeReferenceOwnership ReferenceOwnership;
public:
TypeInfo() : Type(nullptr), ReferenceOwnership() {}
diff --git a/stdlib/public/runtime/ReflectionMirror.mm b/stdlib/public/runtime/ReflectionMirror.mm
index 361c5b7..69aa285 100644
--- a/stdlib/public/runtime/ReflectionMirror.mm
+++ b/stdlib/public/runtime/ReflectionMirror.mm
@@ -622,8 +622,7 @@
}
/// TODO: Implement specialized mirror witnesses for all kinds.
- case MetadataKind::Function:
- case MetadataKind::Existential:
+ default:
break;
// Types can't have these kinds.
@@ -725,9 +724,9 @@
return "(Heap Generic Local Variable)";
case MetadataKind::ErrorObject:
return "(ErrorType Object)";
+ default:
+ return "(Unknown)";
}
-
- return "(Unknown)";
}
#if SWIFT_OBJC_INTEROP
diff --git a/stdlib/public/runtime/SwiftObject.mm b/stdlib/public/runtime/SwiftObject.mm
index 924859f..d2380e7 100644
--- a/stdlib/public/runtime/SwiftObject.mm
+++ b/stdlib/public/runtime/SwiftObject.mm
@@ -1142,16 +1142,7 @@
break;
// Other kinds of type can never conform to ObjC protocols.
- case MetadataKind::Struct:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
- case MetadataKind::Function:
- case MetadataKind::Existential:
- case MetadataKind::Metatype:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::ForeignClass:
+ default:
swift_dynamicCastFailure(type, nameForMetadata(type).c_str(),
protocols[0], protocol_getName(protocols[0]));
@@ -1188,16 +1179,7 @@
break;
// Other kinds of type can never conform to ObjC protocols.
- case MetadataKind::Struct:
- case MetadataKind::Enum:
- case MetadataKind::Optional:
- case MetadataKind::Opaque:
- case MetadataKind::Tuple:
- case MetadataKind::Function:
- case MetadataKind::Existential:
- case MetadataKind::Metatype:
- case MetadataKind::ExistentialMetatype:
- case MetadataKind::ForeignClass:
+ default:
return nullptr;
case MetadataKind::HeapLocalVariable:
diff --git a/stdlib/public/stubs/LibcShims.cpp b/stdlib/public/stubs/LibcShims.cpp
index a6c6183..d0892da 100644
--- a/stdlib/public/stubs/LibcShims.cpp
+++ b/stdlib/public/stubs/LibcShims.cpp
@@ -322,9 +322,9 @@
// _stdlib_random
//
// Should the implementation of this function add a new platform/change for a
-// platform, make sure to also update the stdlib documentation regarding
-// platform implementation of this function.
-// This can be found at: stdlib/public/core/Random.swift
+// platform, make sure to also update the documentation regarding platform
+// implementation of this function.
+// This can be found at: /docs/Random.md
#if defined(__APPLE__)
diff --git a/test/APINotes/Inputs/custom-modules/ObsoletedAPINotesTest.apinotes b/test/APINotes/Inputs/custom-modules/ObsoletedAPINotesTest.apinotes
index 6b55f0d..85798d4 100644
--- a/test/APINotes/Inputs/custom-modules/ObsoletedAPINotesTest.apinotes
+++ b/test/APINotes/Inputs/custom-modules/ObsoletedAPINotesTest.apinotes
@@ -2,9 +2,13 @@
Classes:
- Name: FooID
SwiftName: Foo_ID
+- Name: BarSub
+ SwiftName: BarContainerCanonical.Sub
SwiftVersions:
- Version: 4
Classes:
- Name: FooID
SwiftName: FooID
+ - Name: BarSub
+ SwiftName: BarContainerOld.Sub
diff --git a/test/APINotes/Inputs/custom-modules/ObsoletedAPINotesTest.h b/test/APINotes/Inputs/custom-modules/ObsoletedAPINotesTest.h
index a1aebcd..7cd99d5 100644
--- a/test/APINotes/Inputs/custom-modules/ObsoletedAPINotesTest.h
+++ b/test/APINotes/Inputs/custom-modules/ObsoletedAPINotesTest.h
@@ -1,3 +1,10 @@
@import Foundation;
@interface FooID: NSObject
@end
+
+@interface BarContainerOld
+@end
+@interface BarContainerCanonical
+@end
+@interface BarSub
+@end
diff --git a/test/APINotes/obsoleted.swift b/test/APINotes/obsoleted.swift
index 8750868..e081c5c 100644
--- a/test/APINotes/obsoleted.swift
+++ b/test/APINotes/obsoleted.swift
@@ -6,3 +6,6 @@
let _: FooID // expected-error{{'FooID' has been renamed to 'Foo_ID'}}
let _: Foo_ID
+
+let _: BarContainerOld.Sub // expected-error{{'Sub' has been renamed to 'BarContainerCanonical.Sub'}}
+let _: BarContainerCanonical.Sub
diff --git a/test/DebugInfo/Inputs/type-reconstr-names.txt b/test/DebugInfo/Inputs/type-reconstr-names.txt
index b99c30c..aae344a 100644
--- a/test/DebugInfo/Inputs/type-reconstr-names.txt
+++ b/test/DebugInfo/Inputs/type-reconstr-names.txt
@@ -5,3 +5,4 @@
$Ss10CollectionP7Element ---> Can't resolve type of $Ss10CollectionP7Element
$Ss15ContiguousArrayV9formIndex5afterySiz_tFSS_Tg5 ---> (inout Int) -> ()
$S12TypeReconstr8PatatinoaySiGD ---> Patatino<Int>
+$S13EyeCandySwift21_previousUniqueNumber33_ADC08935D64EA4F796440E7335798735LLs6UInt64Vvp -> UInt64
diff --git a/test/Driver/pipe_round_robin.swift.gyb b/test/Driver/pipe_round_robin.swift.gyb
index d8d39a0..d706a34 100644
--- a/test/Driver/pipe_round_robin.swift.gyb
+++ b/test/Driver/pipe_round_robin.swift.gyb
@@ -17,12 +17,12 @@
// RUN: %gyb -D N=4 %s -o %t/manyfuncs/file4.swift
//
// We calculate the ratio of poll() calls to read() calls; these should be
-// nearly equal (we test abs(read/poll) < 2.0) if we're doing interleaved
+// nearly equal (we test abs(read/poll) < 3.0) if we're doing interleaved
// reading. If we're doing non-interleaved reading, they become radically
// different (eg. thousands of reads per poll).
//
// RUN: %target-build-swift -j 4 -module-name manyfuncs -typecheck -stats-output-dir %t/stats -Xfrontend -debug-time-function-bodies %t/manyfuncs/*.swift
-// RUN: %utils/process-stats-dir.py --evaluate 'abs(float(NumDriverPipeReads) / float(NumDriverPipePolls)) < 2.0' %t/stats
+// RUN: %utils/process-stats-dir.py --evaluate 'abs(float(NumDriverPipeReads) / float(NumDriverPipePolls)) < 3.0' %t/stats
% for i in range(1,1000):
func process_${N}_function_${i}(_ x: Int) -> Int {
diff --git a/test/Migrator/qualified-replacement.swift b/test/Migrator/qualified-replacement.swift
index 47bb412..a8e68b3 100644
--- a/test/Migrator/qualified-replacement.swift
+++ b/test/Migrator/qualified-replacement.swift
@@ -14,6 +14,8 @@
_ = Cities.CityKind.Town
_ = ToplevelType()
_ = ToplevelType(recordName: "")
+ bar(.orderedSame)
}
func foo(_: ToplevelType) {}
+func bar(_ : FooComparisonResult) {}
diff --git a/test/Migrator/qualified-replacement.swift.expected b/test/Migrator/qualified-replacement.swift.expected
index b3ec305..7b1344c 100644
--- a/test/Migrator/qualified-replacement.swift.expected
+++ b/test/Migrator/qualified-replacement.swift.expected
@@ -10,10 +10,12 @@
_ = NewPropertyUserInterface.newFieldPlus
NewPropertyUserInterface.newMethodPlus(1)
_ = NewFooComparisonResult.NewFooOrderedSame
- let _ : FooComparisonResult = NewFooComparisonResult.NewFooOrderedSame
+ let _ : FooComparisonResult = .NewFooOrderedSame
_ = NewCityKind.NewTown
_ = ToplevelWrapper.internalType()
_ = ToplevelWrapper.internalType(recordName: "")
+ bar(.NewFooOrderedSame)
}
func foo(_: ToplevelWrapper.internalType) {}
+func bar(_ : FooComparisonResult) {}
diff --git a/test/Profiler/coverage_exceptions.swift b/test/Profiler/coverage_exceptions.swift
index c434f82..b697e8a 100644
--- a/test/Profiler/coverage_exceptions.swift
+++ b/test/Profiler/coverage_exceptions.swift
@@ -15,9 +15,9 @@
func baz(_ fn: () throws -> ()) rethrows {
do {
try fn()
- } catch SomeErr.Err1 { // CHECK: [[@LINE]]:24 -> {{[0-9]+}}:4 : 2
+ } catch SomeErr.Err1 { // CHECK: [[@LINE]]:24 -> {{[0-9]+}}:4 : 1
return
- } // CHECK-NEXT: [[@LINE]]:4 -> {{[0-9]+}}:2 : 1
+ } // CHECK-NEXT: [[@LINE]]:4 -> {{[0-9]+}}:2 : (0 - 1)
try fn()
} // CHECK-NEXT: }
@@ -30,16 +30,16 @@
throw SomeErr.Err1
x += 2 // [[@LINE]]:5 -> [[@LINE+1]]:4 : zero
} catch SomeErr.Err1 {
- // CHECK: [[@LINE-1]]:24 -> [[@LINE+1]]:4 : 2
+ // CHECK: [[@LINE-1]]:24 -> [[@LINE+1]]:4 : 1
} catch _ {
- // CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:4 : 3
- } // CHECK: [[@LINE]]:4 -> {{[0-9:]+}} : 1
+ // CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:4 : 2
+ } // CHECK: [[@LINE]]:4 -> {{[0-9:]+}} : 0
do {
try baz(bar)
} catch _ {
- // CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:4 : 5
- } // CHECK: [[@LINE]]:4 -> {{[0-9:]+}} : 4
+ // CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:4 : 3
+ } // CHECK: [[@LINE]]:4 -> {{[0-9:]+}} : 0
do {
try baz { () throws -> () in throw SomeErr.Err1 }
@@ -50,7 +50,65 @@
return x
}
-foo()
+let _ = foo()
+
+// rdar://34244637 - Coverage after a do-catch is incorrect
+// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_catch.goo
+func goo(_ b: Bool) -> Int { // CHECK-NEXT: [[@LINE]]:28 {{.*}} : 0
+ do { // CHECK-NEXT: [[@LINE]]:6 -> [[@LINE+2]]:4 : 0
+ throw SomeErr.Err1
+ } catch { // CHECK-NEXT: [[@LINE]]:11 {{.*}} : 1
+ if b { // CHECK-NEXT: [[@LINE]]:10 {{.*}} : 2
+ return 1
+ } // CHECK-NEXT: [[@LINE]]:6 {{.*}} : (1 - 2)
+ } // CHECK: [[@LINE]]:4 {{.*}} : (0 - 2)
+ return 0
+}
+
+// Test coverage with nested do-catches
+// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_catch.hoo
+func hoo() -> Int {
+ do {
+ try bar()
+ do {
+ throw SomeErr.Err1
+ } catch {
+ return 0
+ } // CHECK: [[@LINE]]:6 {{.*}} : (0 - 1)
+
+ } catch {
+ return 1
+ } // CHECK: [[@LINE]]:4 {{.*}} : ((0 - 1) - 2)
+
+}
+
+// Test coverage with a do-catch inside of a repeat-while
+// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_catch.ioo
+func ioo() -> Int {
+ repeat { // CHECK: [[@LINE]]:10 {{.*}} : 1
+ do {
+ throw SomeErr.Err1
+ } catch { // CHECK: [[@LINE]]:13 {{.*}} : 2
+ return 0
+ } // CHECK: [[@LINE]]:6 {{.*}} : (1 - 2)
+
+ } while false // CHECK: [[@LINE]]:11 {{.*}} : (1 - 2)
+ return 1
+}
+
+// Test coverage with a break inside a do-catch inside of a repeat-while
+// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_catch.joo
+func joo() -> Int {
+ repeat { // CHECK: [[@LINE]]:10 {{.*}} : 1
+ do {
+ try bar()
+ } catch { // CHECK: [[@LINE]]:13 {{.*}} : 2
+ break
+ } // CHECK: [[@LINE]]:6 {{.*}} : (1 - 2)
+
+ } while false // CHECK: [[@LINE]]:11 {{.*}} : (1 - 2)
+ return 1
+}
struct S {
// CHECK: sil_coverage_map {{.*}}// __ntd_S_line:[[@LINE-1]]
@@ -58,7 +116,7 @@
do {
throw SomeErr.Err1
} catch {
- // CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:6 : 2
- } // CHECK: [[@LINE]]:6 -> [[@LINE+1]]:4 : 1
+ // CHECK: [[@LINE-1]]:13 -> [[@LINE+1]]:6 : 1
+ } // CHECK: [[@LINE]]:6 -> [[@LINE+1]]:4 : 0
}
}
diff --git a/test/Profiler/coverage_smoke.swift b/test/Profiler/coverage_smoke.swift
index 31d4918..110c59b 100644
--- a/test/Profiler/coverage_smoke.swift
+++ b/test/Profiler/coverage_smoke.swift
@@ -133,6 +133,40 @@
: "true"; // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1
}
+// rdar://34244637: Wrong coverage for do/catch sequence
+enum CustomError : Error {
+ case Err
+}
+func throwError(_ b: Bool) throws {
+ if b {
+ throw CustomError.Err
+ }
+}
+func catchError(_ b: Bool) -> Int {
+ do {
+ try throwError(b) // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}2
+ } catch { // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}2
+ return 1 // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1
+ } // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1
+ let _ = 1 + 1 // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1
+ return 0 // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1
+}
+let _ = catchError(true)
+let _ = catchError(false)
+
+func catchError2(_ b: Bool) -> Int {
+ do {
+ throw CustomError.Err // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}2
+ } catch {
+ if b { // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}2
+ return 1 // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1
+ }
+ }
+ return 0 // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1
+}
+let _ = catchError2(true)
+let _ = catchError2(false)
+
main() // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1
foo() // CHECK-COV: {{ *}}[[@LINE]]|{{ *}}1
call_closure()
diff --git a/test/Profiler/coverage_while.swift b/test/Profiler/coverage_while.swift
index 4d9f24c..d78680f 100644
--- a/test/Profiler/coverage_while.swift
+++ b/test/Profiler/coverage_while.swift
@@ -120,8 +120,6 @@
}
} while false // CHECK-DAG: [[@LINE]]:13 -> [[@LINE]]:18 : ([[RWS9]] - [[RET1]])
} while false // CHECK-DAG: [[@LINE]]:11 -> [[@LINE]]:16 : ([[RWS8]] - [[RET1]])
-
- // TODO(vsk): need tests for fail and throw statements.
}
eoo()
diff --git a/test/Profiler/instrprof_basic.swift b/test/Profiler/instrprof_basic.swift
index 3e18d99..1d0d3de 100644
--- a/test/Profiler/instrprof_basic.swift
+++ b/test/Profiler/instrprof_basic.swift
@@ -47,13 +47,12 @@
// CHECK: sil hidden @[[F_EXCEPTIONS:.*exceptions.*]] :
// CHECK: %[[NAME:.*]] = string_literal utf8 "{{.*}}instrprof_basic.swift:[[F_EXCEPTIONS]]"
// CHECK: %[[HASH:.*]] = integer_literal $Builtin.Int64,
-// CHECK: %[[NCOUNTS:.*]] = integer_literal $Builtin.Int32, 3
+// CHECK: %[[NCOUNTS:.*]] = integer_literal $Builtin.Int32, 2
// CHECK: %[[INDEX:.*]] = integer_literal $Builtin.Int32, 0
// CHECK: builtin "int_instrprof_increment"(%[[NAME]] : {{.*}}, %[[HASH]] : {{.*}}, %[[NCOUNTS]] : {{.*}}, %[[INDEX]] : {{.*}})
func exceptions() {
do {
try throwing_nop()
- // CHECK: builtin "int_instrprof_increment"
} catch {
// CHECK: builtin "int_instrprof_increment"
return
diff --git a/test/SILGen/assignment.swift b/test/SILGen/assignment.swift
index de5338a..1804c96 100644
--- a/test/SILGen/assignment.swift
+++ b/test/SILGen/assignment.swift
@@ -43,11 +43,11 @@
// CHECK-LABEL: sil hidden @$S10assignment15copyRightToLeft1pyAA1P_pz_tF : $@convention(thin) (@inout P) -> () {
func copyRightToLeft(p: inout P) {
// CHECK: bb0(%0 : @trivial $*P):
- // CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0 : $*P
- // CHECK: [[WRITE_OPEN:%.*]] = open_existential_addr mutable_access [[WRITE]]
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] %0 : $*P
// CHECK: [[READ_OPEN:%.*]] = open_existential_addr immutable_access [[READ]]
// CHECK: end_access [[READ]] : $*P
+ // CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0 : $*P
+ // CHECK: [[WRITE_OPEN:%.*]] = open_existential_addr mutable_access [[WRITE]]
// CHECK: end_access [[WRITE]] : $*P
p.left = p.right
}
diff --git a/test/SILGen/class_bound_protocols.swift b/test/SILGen/class_bound_protocols.swift
index c273d87..2e29ffb 100644
--- a/test/SILGen/class_bound_protocols.swift
+++ b/test/SILGen/class_bound_protocols.swift
@@ -176,7 +176,7 @@
// CHECK-NEXT: [[X_PAYLOAD:%.*]] = open_existential_ref [[X_VALUE]] : $InheritsMutatingMethod to $@opened("{{.*}}") InheritsMutatingMethod
// CHECK-NEXT: [[TEMPORARY:%.*]] = alloc_stack $@opened("{{.*}}") InheritsMutatingMethod
// CHECK-NEXT: store [[X_PAYLOAD]] to [init] [[TEMPORARY]] : $*@opened("{{.*}}") InheritsMutatingMethod
- // CHECK-NEXT: [[X_PAYLOAD_RELOADED:%.*]] = load_borrow [[TEMPORARY]]
+ // CHECK-NEXT: [[X_PAYLOAD_RELOADED:%.*]] = load [take] [[TEMPORARY]]
//
// ** *NOTE* This extra copy is here since RValue invariants enforce that all
// ** loadable objects are actually loaded. So we form the RValue and
@@ -184,15 +184,14 @@
// ** pass to an in_guaranteed method. PredictableMemOpts is able to handle this
// ** type of temporary codegen successfully.
// CHECK-NEXT: [[TEMPORARY_2:%.*]] = alloc_stack $@opened("{{.*}}") InheritsMutatingMethod
- // CHECK-NEXT: store_borrow [[X_PAYLOAD_RELOADED:%.*]] to [[TEMPORARY_2]]
+ // CHECK-NEXT: store [[X_PAYLOAD_RELOADED:%.*]] to [init] [[TEMPORARY_2]]
//
// CHECK-NEXT: [[METHOD:%.*]] = witness_method $@opened("{{.*}}") InheritsMutatingMethod, #HasMutatingMethod.mutatingCounter!getter.1 : <Self where Self : HasMutatingMethod> (Self) -> () -> Value, [[X_PAYLOAD]] : $@opened("{{.*}}") InheritsMutatingMethod : $@convention(witness_method: HasMutatingMethod) <τ_0_0 where τ_0_0 : HasMutatingMethod> (@in_guaranteed τ_0_0) -> Value
// CHECK-NEXT: [[RESULT_VALUE:%.*]] = apply [[METHOD]]<@opened("{{.*}}") InheritsMutatingMethod>([[TEMPORARY_2]]) : $@convention(witness_method: HasMutatingMethod) <τ_0_0 where τ_0_0 : HasMutatingMethod> (@in_guaranteed τ_0_0) -> Value
+ // CHECK-NEXT: destroy_addr [[TEMPORARY_2]] : $*@opened("{{.*}}") InheritsMutatingMethod
// CHECK-NEXT: dealloc_stack [[TEMPORARY_2]]
- // CHECK-NEXT: end_borrow [[X_PAYLOAD_RELOADED]]
+ // CHECK-NEXT: end_access [[X_ADDR]] : $*InheritsMutatingMethod
// CHECK-NEXT: assign [[RESULT_VALUE]] to [[RESULT]] : $*Value
- // CHECK-NEXT: destroy_addr [[TEMPORARY]]
- // CHECK-NEXT: end_access [[X_ADDR]]
// CHECK-NEXT: dealloc_stack [[TEMPORARY]] : $*@opened("{{.*}}") InheritsMutatingMethod
// CHECK-NEXT: dealloc_stack [[RESULT_BOX]] : $*Value
_ = x.mutatingCounter
diff --git a/test/SILGen/objc_thunks.swift b/test/SILGen/objc_thunks.swift
index 6be13d4..c6d48b4 100644
--- a/test/SILGen/objc_thunks.swift
+++ b/test/SILGen/objc_thunks.swift
@@ -64,6 +64,36 @@
// CHECK-NEXT: return [[RES]]
// CHECK-NEXT: }
+ // NS_RETURNS_RETAINED by family (-mutableCopy)
+ @objc func mutableCopyFoo() -> Gizmo { return self }
+ // CHECK-LABEL: sil hidden [thunk] @$S11objc_thunks6HoozitC14mutableCopyFooSo5GizmoCyFTo : $@convention(objc_method) (Hoozit) -> @owned Gizmo
+ // CHECK: bb0([[THIS:%.*]] : @unowned $Hoozit):
+ // CHECK-NEXT: [[THIS_COPY:%.*]] = copy_value [[THIS]]
+ // CHECK-NEXT: [[BORROWED_THIS_COPY:%.*]] = begin_borrow [[THIS_COPY]]
+ // CHECK-NEXT: // function_ref
+ // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @$S11objc_thunks6HoozitC14mutableCopyFooSo5GizmoCyF : $@convention(method) (@guaranteed Hoozit) -> @owned Gizmo
+ // CHECK-NEXT: [[RES:%.*]] = apply [[NATIVE]]([[BORROWED_THIS_COPY]])
+ // CHECK-NEXT: end_borrow [[BORROWED_THIS_COPY]] from [[THIS_COPY]]
+ // CHECK-NEXT: destroy_value [[THIS_COPY]]
+ // CHECK-NEXT: return [[RES]]
+ // CHECK-NEXT: }
+
+ // NS_RETURNS_RETAINED by family (-copy). This is different from Swift's
+ // normal notion of CamelCase, but it's what Clang does, so we should match
+ // it.
+ @objc func copy8() -> Gizmo { return self }
+ // CHECK-LABEL: sil hidden [thunk] @$S11objc_thunks6HoozitC5copy8So5GizmoCyFTo : $@convention(objc_method) (Hoozit) -> @owned Gizmo
+ // CHECK: bb0([[THIS:%.*]] : @unowned $Hoozit):
+ // CHECK-NEXT: [[THIS_COPY:%.*]] = copy_value [[THIS]]
+ // CHECK-NEXT: [[BORROWED_THIS_COPY:%.*]] = begin_borrow [[THIS_COPY]]
+ // CHECK-NEXT: // function_ref
+ // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @$S11objc_thunks6HoozitC5copy8So5GizmoCyF : $@convention(method) (@guaranteed Hoozit) -> @owned Gizmo
+ // CHECK-NEXT: [[RES:%.*]] = apply [[NATIVE]]([[BORROWED_THIS_COPY]])
+ // CHECK-NEXT: end_borrow [[BORROWED_THIS_COPY]] from [[THIS_COPY]]
+ // CHECK-NEXT: destroy_value [[THIS_COPY]]
+ // CHECK-NEXT: return [[RES]]
+ // CHECK-NEXT: }
+
// NS_RETURNS_RETAINED by family (-copy)
@objc(copyDuplicate) func makeDuplicate() -> Gizmo { return self }
// CHECK-LABEL: sil hidden [thunk] @$S11objc_thunks6HoozitC13makeDuplicateSo5GizmoCyFTo : $@convention(objc_method) (Hoozit) -> @owned Gizmo
diff --git a/test/SILGen/properties.swift b/test/SILGen/properties.swift
index 6ac91fe..8d1cf14 100644
--- a/test/SILGen/properties.swift
+++ b/test/SILGen/properties.swift
@@ -1215,12 +1215,12 @@
// CHECK-NEXT: [[C_FIELD_PAYLOAD:%.*]] = open_existential_addr immutable_access [[C_FIELD_BOX]] : $*NonmutatingProtocol to $*@opened("{{.*}}") NonmutatingProtocol
// CHECK-NEXT: [[C_FIELD_COPY:%.*]] = alloc_stack $@opened("{{.*}}") NonmutatingProtocol
// CHECK-NEXT: copy_addr [[C_FIELD_PAYLOAD]] to [initialization] [[C_FIELD_COPY]] : $*@opened("{{.*}}") NonmutatingProtocol
+// CHECK-NEXT: destroy_addr [[C_FIELD_BOX]] : $*NonmutatingProtocol
+// CHECK-NEXT: destroy_value [[C]] : $ReferenceType
// CHECK-NEXT: [[GETTER:%.*]] = witness_method $@opened("{{.*}}") NonmutatingProtocol, #NonmutatingProtocol.x!getter.1 : <Self where Self : NonmutatingProtocol> (Self) -> () -> Int, [[C_FIELD_PAYLOAD]] : $*@opened("{{.*}}") NonmutatingProtocol : $@convention(witness_method: NonmutatingProtocol) <τ_0_0 where τ_0_0 : NonmutatingProtocol> (@in_guaranteed τ_0_0) -> Int
// CHECK-NEXT: [[RESULT_VALUE:%.*]] = apply [[GETTER]]<@opened("{{.*}}") NonmutatingProtocol>([[C_FIELD_COPY]]) : $@convention(witness_method: NonmutatingProtocol) <τ_0_0 where τ_0_0 : NonmutatingProtocol> (@in_guaranteed τ_0_0) -> Int
// CHECK-NEXT: assign [[RESULT_VALUE]] to [[UNINIT]] : $*Int
// CHECK-NEXT: destroy_addr [[C_FIELD_COPY]] : $*@opened("{{.*}}") NonmutatingProtocol
-// CHECK-NEXT: destroy_addr [[C_FIELD_BOX]] : $*NonmutatingProtocol
-// CHECK-NEXT: destroy_value [[C]] : $ReferenceType
// CHECK-NEXT: dealloc_stack [[C_FIELD_COPY]] : $*@opened("{{.*}}") NonmutatingProtocol
// CHECK-NEXT: dealloc_stack [[C_FIELD_BOX]] : $*NonmutatingProtocol
// CHECK-NEXT: dealloc_stack [[RESULT]] : $*Int
diff --git a/test/SILGen/protocol-extension-default-arg-existential-objc.swift b/test/SILGen/protocol-extension-default-arg-existential-objc.swift
new file mode 100644
index 0000000..dbc2951
--- /dev/null
+++ b/test/SILGen/protocol-extension-default-arg-existential-objc.swift
@@ -0,0 +1,12 @@
+// RUN: %target-swift-frontend -emit-sil -verify %s
+// REQUIRES: objc_interop
+
+import Foundation
+
+class Foo: NSObject {
+ dynamic func bridged(x: String = "foo") {}
+}
+
+func invokeMethodsWithDefaultArgs(x: Foo) {
+ x.bridged()
+}
diff --git a/test/SILGen/protocol-extension-default-arg-existential.swift b/test/SILGen/protocol-extension-default-arg-existential.swift
new file mode 100644
index 0000000..78f377e
--- /dev/null
+++ b/test/SILGen/protocol-extension-default-arg-existential.swift
@@ -0,0 +1,39 @@
+// RUN: %target-swift-frontend -emit-sil -verify %s
+
+//
+// Make sure neither rdar://problem/37031037 (default arguments on protocol extension methods
+// depend on Self and normally get evaluated before an existential self value
+// gets opened) nor rdar://problem/39524104 (if you open the existential self
+// earlier in an attempt to fix this, then you get undesirable exclusivity
+// conflicts on constructs like `existential.x = existential.y`) regress.
+//
+
+protocol MethodWithDefaultArgGenerator {
+ var a: Int { get set }
+ var b: Int { get nonmutating set }
+
+ mutating func mutate(_ x: inout Int)
+}
+
+protocol P { static var value: Self { get } }
+extension Int: P { static var value: Int { return 0 } }
+
+extension MethodWithDefaultArgGenerator {
+ mutating func foo(_ x: Int = 0) {}
+
+ mutating func reabstracted<T>(_ x: T.Type = T.self) -> T { fatalError() }
+ mutating func indirected<T: P>(_ x: T = T.value) -> T { fatalError() }
+
+ mutating func exploded(x y: (Int, String) = (0, "foo")) {}
+}
+func invokeMethodsWithDefaultArgs(x: inout MethodWithDefaultArgGenerator) {
+ x.foo()
+ _ = x.reabstracted() as Int
+ _ = x.indirected() as Int
+ x.exploded()
+}
+func checkAgainstExclusivityViolations(x: inout MethodWithDefaultArgGenerator) {
+ x.a = x.a
+ x.mutate(&x.b)
+}
+
diff --git a/test/SILGen/protocols.swift b/test/SILGen/protocols.swift
index d9ca6ab..f38954c 100644
--- a/test/SILGen/protocols.swift
+++ b/test/SILGen/protocols.swift
@@ -27,10 +27,10 @@
// CHECK: [[PROJ:%[0-9]+]] = open_existential_addr immutable_access [[READ]] : $*SubscriptableGet to $*[[OPENED:@opened(.*) SubscriptableGet]]
// CHECK: [[ALLOCSTACK:%[0-9]+]] = alloc_stack $[[OPENED]]
// CHECK: copy_addr [[PROJ]] to [initialization] [[ALLOCSTACK]] : $*[[OPENED]]
+// CHECK-NEXT: end_access [[READ]] : $*SubscriptableGet
// CHECK-NEXT: [[METH:%[0-9]+]] = witness_method $[[OPENED]], #SubscriptableGet.subscript!getter.1
// CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[METH]]<[[OPENED]]>(%0, [[ALLOCSTACK]])
// CHECK-NEXT: destroy_addr [[ALLOCSTACK]]
-// CHECK-NEXT: end_access [[READ]] : $*SubscriptableGet
// CHECK-NEXT: dealloc_stack [[ALLOCSTACK]] : $*[[OPENED]]
// CHECK-NEXT: return [[RESULT]]
@@ -134,9 +134,9 @@
// CHECK: [[PROJ:%[0-9]+]] = open_existential_addr immutable_access [[READ]] : $*PropertyWithGetter to $*[[OPENED:@opened(.*) PropertyWithGetter]]
// CHECK: [[COPY:%.*]] = alloc_stack $[[OPENED]]
// CHECK-NEXT: copy_addr [[PROJ]] to [initialization] [[COPY]] : $*[[OPENED]]
+// CHECK-NEXT: end_access [[READ]] : $*PropertyWithGetter
// CHECK-NEXT: [[METH:%[0-9]+]] = witness_method $[[OPENED]], #PropertyWithGetter.a!getter.1
// CHECK-NEXT: apply [[METH]]<[[OPENED]]>([[COPY]])
-// CHECK: end_access [[READ]] : $*PropertyWithGetter
func use_property_lvalue_get() -> Int {
return propertyGetSet.b
@@ -458,15 +458,3 @@
// CHECK-LABEL: sil_witness_table hidden StructWithStoredClassProperty: PropertyWithGetter module protocols {
// CHECK-NEXT: method #PropertyWithGetter.a!getter.1: {{.*}} : @$S9protocols29StructWithStoredClassPropertyVAA0fC6GetterA2aDP1aSivgTW
// CHECK-NEXT: }
-
-//
-// rdar://problem/37031037
-//
-
-protocol MethodWithDefaultArgGenerator {}
-extension MethodWithDefaultArgGenerator {
- mutating func foo(_ x: Int = 0) {}
-}
-func invokeMethodWithDefaultArg(x: inout MethodWithDefaultArgGenerator) {
- x.foo()
-}
diff --git a/test/SILGen/scalar_to_tuple_args.swift b/test/SILGen/scalar_to_tuple_args.swift
index 424caf6..1c4b310 100644
--- a/test/SILGen/scalar_to_tuple_args.swift
+++ b/test/SILGen/scalar_to_tuple_args.swift
@@ -14,9 +14,9 @@
var x = 0
// CHECK: [[X_ADDR:%.*]] = global_addr @$S20scalar_to_tuple_args1xSivp : $*Int
+// CHECK: [[WRITE:%.*]] = begin_access [modify] [dynamic] [[X_ADDR]] : $*Int
// CHECK: [[DEFAULT_Y:%.*]] = apply {{.*}} : $@convention(thin) () -> Int
// CHECK: [[DEFAULT_Z:%.*]] = apply {{.*}} : $@convention(thin) () -> Int
-// CHECK: [[WRITE:%.*]] = begin_access [modify] [dynamic] [[X_ADDR]] : $*Int
// CHECK: [[INOUT_WITH_DEFAULTS:%.*]] = function_ref @$S20scalar_to_tuple_args17inoutWithDefaults_1y1zySiz_S2itF
// CHECK: apply [[INOUT_WITH_DEFAULTS]]([[WRITE]], [[DEFAULT_Y]], [[DEFAULT_Z]])
inoutWithDefaults(&x)
diff --git a/test/SILOptimizer/access_marker_verify.swift b/test/SILOptimizer/access_marker_verify.swift
index 53ae790..463e19f 100644
--- a/test/SILOptimizer/access_marker_verify.swift
+++ b/test/SILOptimizer/access_marker_verify.swift
@@ -970,12 +970,12 @@
// CHECK: [[PROJ:%.*]] = project_box %{{.*}} : ${ var StructWithLayout }, 0
// CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] %{{.*}}([[PROJ]]) : $@convention(thin) (@inout_aliasable StructWithLayout) -> Bool
// CHECK: [[CLOSURE:%.*]] = convert_escape_to_noescape [not_guaranteed] [[PA]] : $@callee_guaranteed () -> Bool to $@noescape @callee_guaranteed () -> Bool
-// call default argument
-// CHECK: apply %{{.*}}() : $@convention(thin) () -> StaticString
// call StaticString.init
// CHECK: apply
// call UInt.init(_builtinIntegerLiteral:)
// CHECK: apply
+// call default argument
+// CHECK: apply %{{.*}}() : $@convention(thin) () -> StaticString
// call _sanityCheck(_:_:file:line:)
// CHECK: apply %{{.*}}([[CLOSURE]], {{.*}})
// CHECK: load [trivial] [[PROJ]] : $*StructWithLayout
diff --git a/test/SILOptimizer/closure_specialize.sil b/test/SILOptimizer/closure_specialize.sil
index aa8c51b..743d9d0 100644
--- a/test/SILOptimizer/closure_specialize.sil
+++ b/test/SILOptimizer/closure_specialize.sil
@@ -608,3 +608,127 @@
%empty = tuple ()
return %empty : $()
}
+
+
+sil @testClosureConvertHelper2 : $(Int) -> Int
+
+sil @testClosureThunkNoEscape2 : $@convention(thin) (@noescape @callee_guaranteed () -> @out Int) -> @out Int {
+bb0(%0 : $*Int, %1 : $@noescape @callee_guaranteed () -> @out Int):
+ apply %1(%0) : $@noescape @callee_guaranteed () -> @out Int
+ %8 = tuple ()
+ return %8 : $()
+}
+
+sil [reabstraction_thunk] @reabstractionThunk : $@convention(thin) (@noescape @callee_guaranteed () -> Int) -> @out Int
+
+// CHECK-LABEL: sil shared @$S25testClosureThunkNoEscape20aB14ConvertHelper2SiTf1nc_n : $@convention(thin) (Int) -> @out Int
+// CHECK: [[PA1:%.*]] = partial_apply
+// CHECK: convert_escape_to_noescape
+// CHECK: [[PA2:%.*]] = partial_apply
+// CHECK: convert_escape_to_noescape
+// CHECK: apply
+// CHECK: release_value [[PA1]]
+// CHECK: release_value [[PA2]]
+// CHECK: return
+
+// CHECK-LABEL: sil shared @$S25testClosureThunkNoEscape219reabstractionThunk2SiIegd_Tf1nc_n : $@convention(thin) (@owned @callee_guaranteed () -> Int) -> @out Int {
+// CHECK: bb0(%0 : $*Int, %1 : $@callee_guaranteed () -> Int):
+// CHECK: [[F:%.*]] = function_ref @reabstractionThunk2
+// CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] [[F]](%1)
+// CHECK: [[CVT:%.*]] = convert_escape_to_noescape [[PA]]
+// CHECK: apply [[CVT]](%0) : $@noescape @callee_guaranteed () -> @out Int
+// CHECK: release_value [[PA]] : $@callee_guaranteed () -> @out Int
+// CHECK: return
+
+// CHECK-LABEL: sil @reabstractionTest : $@convention(thin) (Int) -> ()
+// CHECK: [[F:%.*]] = function_ref @$S25testClosureThunkNoEscape20aB14ConvertHelper2SiTf1nc_n
+// CHECK: apply [[F]]
+// CHECK: return
+sil @reabstractionTest : $(Int) -> () {
+bb0(%0 : $Int):
+ %48 = alloc_stack $Int
+ %49 = function_ref @testClosureConvertHelper2 : $@convention(thin) (Int) -> Int
+ %50 = partial_apply [callee_guaranteed] %49(%0) : $@convention(thin) (Int) -> Int
+ %51 = convert_escape_to_noescape %50 : $@callee_guaranteed () -> Int to $@noescape @callee_guaranteed () -> Int
+ %52 = function_ref @reabstractionThunk : $@convention(thin) (@noescape @callee_guaranteed () -> Int) -> @out Int
+ %53 = partial_apply [callee_guaranteed] %52(%51) : $@convention(thin) (@noescape @callee_guaranteed () -> Int) -> @out Int
+ %54 = convert_escape_to_noescape %53 : $@callee_guaranteed () -> @out Int to $@noescape @callee_guaranteed () -> @out Int
+ %55 = function_ref @testClosureThunkNoEscape2 : $@convention(thin) (@noescape @callee_guaranteed () -> @out Int) -> @out Int
+ apply %55(%48, %54) : $@convention(thin) (@noescape @callee_guaranteed () -> @out Int) -> @out Int
+ release_value %50: $@callee_guaranteed () -> Int
+ release_value %53: $@callee_guaranteed () -> @out Int
+ dealloc_stack %48 : $*Int
+ %empty = tuple ()
+ return %empty : $()
+}
+
+// Currently not supported cases.
+
+sil @testClosureThunk4 : $@convention(thin) (@owned @callee_guaranteed () -> @out Int) -> @out Int {
+bb0(%0 : $*Int, %1 : $@callee_guaranteed () -> @out Int):
+ apply %1(%0) : $@callee_guaranteed () -> @out Int
+ release_value %1: $@callee_guaranteed () -> @out Int
+ %8 = tuple ()
+ return %8 : $()
+}
+// CHECK-LABEL: sil @reabstractionTest2
+// CHECK: bb0(%0 : $Int):
+// CHECK: [[STK:%.*]] = alloc_stack $Int
+// CHECK: [[F:%.*]] = function_ref @testClosureConvertHelper2
+// CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] [[F]](%0)
+// CHECK: [[CVT:%.*]] = convert_escape_to_noescape [[PA]]
+// CHECK: [[F2:%.*]] = function_ref @reabstractionThunk
+// CHECK: [[PA2:%.*]] = partial_apply [callee_guaranteed] [[F2]]([[CVT]])
+// CHECK: [[F3:%.*]] = function_ref @testClosureThunk4
+// CHECK: apply [[F3]]([[STK]], [[PA2]])
+// CHECK: release_value [[PA]]
+// CHECK: dealloc_stack [[STK]]
+// CHECK: return
+
+sil @reabstractionTest2 : $(Int) -> () {
+bb0(%0 : $Int):
+ %48 = alloc_stack $Int
+ %49 = function_ref @testClosureConvertHelper2 : $@convention(thin) (Int) -> Int
+ %50 = partial_apply [callee_guaranteed] %49(%0) : $@convention(thin) (Int) -> Int
+ %51 = convert_escape_to_noescape %50 : $@callee_guaranteed () -> Int to $@noescape @callee_guaranteed () -> Int
+ %52 = function_ref @reabstractionThunk : $@convention(thin) (@noescape @callee_guaranteed () -> Int) -> @out Int
+ %53 = partial_apply [callee_guaranteed] %52(%51) : $@convention(thin) (@noescape @callee_guaranteed () -> Int) -> @out Int
+ %55 = function_ref @testClosureThunk4 : $@convention(thin) (@owned @callee_guaranteed () -> @out Int) -> @out Int
+ apply %55(%48, %53) : $@convention(thin) (@owned @callee_guaranteed () -> @out Int) -> @out Int
+ release_value %50: $@callee_guaranteed () -> Int
+ dealloc_stack %48 : $*Int
+ %empty = tuple ()
+ return %empty : $()
+}
+
+// Only support the ulitmate partial_apply.
+sil [reabstraction_thunk] @reabstractionThunk2 : $@convention(thin) (@guaranteed @callee_guaranteed () -> Int) -> @out Int
+
+// CHECK-LABEL: sil @reabstractionTest3 : $@convention(thin) (Int) -> () {
+// CHECK: bb0(%0 : $Int):
+// CHECK: [[STK:%.*]] = alloc_stack $Int
+// CHECK: [[F:%.*]] = function_ref @testClosureConvertHelper2
+// CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] [[F]](%0)
+// CHECK: [[F2:%.*]] = function_ref @reabstractionThunk2
+// CHECK: [[SPEC:%.*]] = function_ref @$S25testClosureThunkNoEscape219reabstractionThunk2SiIegd_Tf1nc_n : $@convention(thin) (@owned @callee_guaranteed () -> Int) -> @out Int
+// CHECK: retain_value [[PA]] : $@callee_guaranteed () -> Int
+// CHECK: %8 = apply [[SPEC]]([[STK]], [[PA]]) : $@convention(thin) (@owned @callee_guaranteed () -> Int) -> @out Int
+// CHECK: strong_release [[PA]] : $@callee_guaranteed () -> Int
+// CHECK: dealloc_stack [[STK]] : $*Int
+// CHECK: return
+
+sil @reabstractionTest3 : $(Int) -> () {
+bb0(%0 : $Int):
+ %48 = alloc_stack $Int
+ %49 = function_ref @testClosureConvertHelper2 : $@convention(thin) (Int) -> Int
+ %50 = partial_apply [callee_guaranteed] %49(%0) : $@convention(thin) (Int) -> Int
+ %52 = function_ref @reabstractionThunk2 : $@convention(thin) (@guaranteed @callee_guaranteed () -> Int) -> @out Int
+ %53 = partial_apply [callee_guaranteed] %52(%50) : $@convention(thin) (@guaranteed @callee_guaranteed () -> Int) -> @out Int
+ %54 = convert_escape_to_noescape %53 : $@callee_guaranteed () -> @out Int to $@noescape @callee_guaranteed () -> @out Int
+ %55 = function_ref @testClosureThunkNoEscape2 : $@convention(thin) (@noescape @callee_guaranteed () -> @out Int) -> @out Int
+ apply %55(%48, %54) : $@convention(thin) (@noescape @callee_guaranteed () -> @out Int) -> @out Int
+ release_value %53: $@callee_guaranteed () -> @out Int
+ dealloc_stack %48 : $*Int
+ %empty = tuple ()
+ return %empty : $()
+}
diff --git a/test/SILOptimizer/diagnostic_constant_propagation.swift b/test/SILOptimizer/diagnostic_constant_propagation.swift
index 00ae476..543b30a 100644
--- a/test/SILOptimizer/diagnostic_constant_propagation.swift
+++ b/test/SILOptimizer/diagnostic_constant_propagation.swift
@@ -8,6 +8,8 @@
// References: <rdar://problem/29937936>, <rdar://problem/29939484>,
// <https://bugs.swift.org/browse/SR-5964>, <rdar://problem/39120081>
+import StdlibUnittest
+
func testArithmeticOverflow() {
let xu8 : UInt8 = 250
let yu8 : UInt8 = 250
@@ -39,6 +41,18 @@
// Note: asserts in the shift operators confuse constant propagation
var _: Int8 = (-1 & ~(1<<7))+1 // FIXME: false negative: should expect an error
// like {{arithmetic operation '127 + 1' (on type 'Int8') results in an overflow}}
+
+ // The following cases check that overflows in arithmetic over large literals
+ // without explicit types are caught. Note that if a literal overflows even
+ // Int20148 it will be caught by the Sema phases. Also note that the
+ // overflow is detected during implicit conversion to 'Int'.
+ _blackHole(
+ -00016158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115328 - 1)
+ // expected-error@-1 {{integer literal '-16158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115328' overflows when stored into 'Int'}}
+
+ _blackHole(
+ 00016158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115327 + 1)
+ // expected-error@-1 {{integer literal '16158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115327' overflows when stored into 'Int'}}
}
@_transparent
diff --git a/test/SILOptimizer/exclusivity_static_diagnostics_inlined.swift b/test/SILOptimizer/exclusivity_static_diagnostics_inlined.swift
index 0b29abe..757dadc 100644
--- a/test/SILOptimizer/exclusivity_static_diagnostics_inlined.swift
+++ b/test/SILOptimizer/exclusivity_static_diagnostics_inlined.swift
@@ -2,8 +2,7 @@
// RUN: %target-swift-frontend -enforce-exclusivity=none -emit-sil -Onone %s -o %t/Onone.sil
// RUN: %target-sil-opt %t/Onone.sil -inline -assume-parsing-unqualified-ownership-sil -o %t/inlined.sil
// RUN: %FileCheck %s --check-prefix=INLINE < %t/inlined.sil
-// RUN: not %target-sil-opt -enable-sil-verify-all %t/inlined.sil -enforce-exclusivity=unchecked -diagnose-static-exclusivity -assume-parsing-unqualified-ownership-sil -o /dev/null 2> %t/err.txt
-// RUN: %FileCheck %s --check-prefix=DIAGNOSE < %t/err.txt
+// RUN: %target-sil-opt -enable-sil-verify-all %t/inlined.sil -enforce-exclusivity=unchecked -diagnose-static-exclusivity -assume-parsing-unqualified-ownership-sil -o /dev/null
public protocol SomeP {
var someV: Int { get set }
@@ -23,15 +22,10 @@
//
// INLINE-LABEL: $S5Onone16testNestedAccessyyF
// INLINE: [[OUTER:%.*]] = begin_access [modify] [static] %0 : $*SomeP
+// INLINE: [[INNERREAD:%.*]] = begin_access [read] [static] [[OUTER]] : $*SomeP
// INLINE: [[INNERMOD:%.*]] = begin_access [modify] [static] [[OUTER]] : $*SomeP
// INLINE: %{{.*}} = open_existential_addr mutable_access [[INNERMOD]] : $*SomeP to $*@opened("{{.*}}") SomeP
-// INLINE: [[INNERREAD:%.*]] = begin_access [read] [static] [[OUTER]] : $*SomeP
//
-// DIAGNOSE: error: overlapping accesses, but modification requires exclusive access; consider copying to a local variable
-// DIAGNOSE: %{{.*}} = begin_access [modify] [static] %0 : $*SomeP
-// DIAGNOSE: %{{.*}} = begin_access [read] [static] %0 : $*SomeP
-// DIAGNOSE: %{{.*}} = begin_access [modify] [static] %{{.*}} : $*SomeP
-// DIAGNOSE: %{{.*}} = begin_access [read] [static] %{{.*}} : $*SomeP
public func testNestedAccess() {
var s: SomeP = Some()
assignNonConflict(&s)
diff --git a/test/Sema/diag_max_builtin_overflows.swift b/test/Sema/diag_max_builtin_overflows.swift
new file mode 100644
index 0000000..3209a0c
--- /dev/null
+++ b/test/Sema/diag_max_builtin_overflows.swift
@@ -0,0 +1,80 @@
+// RUN: %target-typecheck-verify-swift
+//
+// Tests that check whether large literals that are outside the range
+// of Builtin.Int2048 are diagnosed in the Sema phase.
+
+import StdlibUnittest
+
+func testMaxIntLiteralOverflow() {
+ // Largest integer expressible in 2048 bits. (Has 512 hex digits.)
+ let max2048: Int64 = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ _blackHole(max2048)
+
+ // Smallest integer expressible in 2048 bits. (Has 512 hex digits.)
+ let min2048: Int64 = -0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ _blackHole(min2048)
+
+ // Smallest positive integer that overflows 2048 bits
+ let firstOverflow: Int64 = 0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ // expected-error@-1 {{integer literal needs 2049 bits, exceeding limit of 2048 bits}}
+ _blackHole(firstOverflow)
+
+ // Largest negative integer that overflows 2048 bits
+ let firstNegOverflow: Int64 = -0x80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
+ // expected-error@-1 {{integer literal needs 2049 bits, exceeding limit of 2048 bits}}
+ _blackHole(firstNegOverflow)
+
+ let max2048Dec: Int64 = 16158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115327
+ _blackHole(max2048Dec)
+
+ // Smallest integer expressible in 2048 bits. (Has 512 hex digits.)
+ let min2048Dec: Int64 = -16158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115328
+ _blackHole(min2048Dec)
+
+ // Smallest positive integer that overflows 2048 bits
+ let firstOverflowDec: Int64 = 16158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115328
+ // expected-error@-1 {{integer literal needs 2049 bits, exceeding limit of 2048 bits}}
+ _blackHole(firstOverflow)
+
+ // Largest negative integer that overflows 2048 bits
+ let firstNegOverflowDec: Int64 = -16158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115329
+ // expected-error@-1 {{integer literal needs 2049 bits, exceeding limit of 2048 bits}}
+ _blackHole(firstOverflow)
+
+ // testing correct handling of C-Octal representation
+ let x: Int64 = 00016158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115327
+ _blackHole(x)
+
+ let y: Int64 = -00016158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115328
+ _blackHole(y)
+}
+
+func testMaxIntLiteralOverflowInArithmetic() {
+ _blackHole(
+ -00016158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115329 - 1)
+ // expected-error@-1 {{integer literal needs 2049 bits, exceeding limit of 2048 bits}}
+
+ // Note that in the following test cases there is no literal overflow,
+ // but there is an arithmetic overflow, which would be detected by the
+ // SIL diagnostic phase: 'DiagnosticConstantPropagation'.
+ _blackHole(
+ -00016158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115328 - 1)
+
+ _blackHole(
+ -00016158503035655503650357438344334975980222051334857742016065172713762327569433945446598600705761456731844358980460949009747059779575245460547544076193224141560315438683650498045875098875194826053398028819192033784138396109321309878080919047169238085235290822926018152521443787945770532904303776199561965192760957166694834171210342487393282284747428088017663161029038902829665513096354230157075129296432088558362971801859230928678799175576150822952201848806616643615613562842355410104862578550863465661734839271290328348967522998634176499319107762583194718667771801067716614802322659239302476074096777926805529798115327 + 1)
+}
+
+func testMaxInLiteralOverflowInEnum() {
+
+ enum TernaryDigit: Int8 {
+ case zero = 0, one, two
+ }
+
+ _blackHole(TernaryDigit(rawValue: 0x800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000))
+ // expected-error@-1 {{integer literal needs 2053 bits, exceeding limit of 2048 bits}}
+
+ enum BuggyTernaryDigit: Int8 { // expected-error {{'BuggyTernaryDigit' declares raw type 'Int8', but does not conform to RawRepresentable and conformance could not be synthesized}}
+ case zero = 0x800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, one, two
+ // expected-error@-1 {{integer literal needs 2053 bits, exceeding limit of 2048 bits}}
+ }
+}
diff --git a/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/APINotesTests.apinotes b/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/APINotesTests.apinotes
new file mode 100644
index 0000000..651ded8
--- /dev/null
+++ b/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/APINotesTests.apinotes
@@ -0,0 +1,47 @@
+Name: APINotesTests
+Classes:
+- Name: GlobalToMember_Class_Payload
+ SwiftName: GlobalToMember_Class_Container.Payload
+- Name: MemberToGlobal_Class_Payload
+ SwiftName: MemberToGlobal_Class_Payload
+- Name: MemberToMember_Class_Payload
+ SwiftName: MemberToMember_Class_Swift4.PayloadFor4
+- Name: MemberToMember_SameName_Class_Payload
+ SwiftName: MemberToMember_SameName_Class_Swift4.Payload
+- Name: MemberToMember_SameContainer_Class_Payload
+ SwiftName: MemberToMember_SameContainer_Class_Container.PayloadFor4
+Typedefs:
+- Name: GlobalToMember_Typedef_Payload
+ SwiftName: GlobalToMember_Typedef_Container.Payload
+- Name: MemberToGlobal_Typedef_Payload
+ SwiftName: MemberToGlobal_Typedef_Payload
+- Name: MemberToMember_Typedef_Payload
+ SwiftName: MemberToMember_Typedef_Swift4.PayloadFor4
+- Name: MemberToMember_SameName_Typedef_Payload
+ SwiftName: MemberToMember_SameName_Typedef_Swift4.Payload
+- Name: MemberToMember_SameContainer_Typedef_Payload
+ SwiftName: MemberToMember_SameContainer_Typedef_Container.PayloadFor4
+SwiftVersions:
+- Version: 3
+ Classes:
+ - Name: GlobalToMember_Class_Payload
+ SwiftName: GlobalToMember_Class_Payload
+ - Name: MemberToGlobal_Class_Payload
+ SwiftName: MemberToGlobal_Class_Container.Payload
+ - Name: MemberToMember_Class_Payload
+ SwiftName: MemberToMember_Class_Swift3.PayloadFor3
+ - Name: MemberToMember_SameContainer_Class_Payload
+ SwiftName: MemberToMember_SameContainer_Class_Container.PayloadFor3
+ - Name: MemberToMember_SameName_Class_Payload
+ SwiftName: MemberToMember_SameName_Class_Swift3.Payload
+ Typedefs:
+ - Name: GlobalToMember_Typedef_Payload
+ SwiftName: GlobalToMember_Typedef_Payload
+ - Name: MemberToGlobal_Typedef_Payload
+ SwiftName: MemberToGlobal_Typedef_Container.Payload
+ - Name: MemberToMember_Typedef_Payload
+ SwiftName: MemberToMember_Typedef_Swift3.PayloadFor3
+ - Name: MemberToMember_SameContainer_Typedef_Payload
+ SwiftName: MemberToMember_SameContainer_Typedef_Container.PayloadFor3
+ - Name: MemberToMember_SameName_Typedef_Payload
+ SwiftName: MemberToMember_SameName_Typedef_Swift3.Payload
diff --git a/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/APINotesTests.h b/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/APINotesTests.h
new file mode 100644
index 0000000..f069369
--- /dev/null
+++ b/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/APINotesTests.h
@@ -0,0 +1,3 @@
+
+#import "Foo.h"
+#import "Decls.h"
diff --git a/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/Decls.h b/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/Decls.h
new file mode 100644
index 0000000..8a8f4b0
--- /dev/null
+++ b/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/Decls.h
@@ -0,0 +1,82 @@
+@import Foundation;
+
+// ===-------------------------------------------------------------------------
+// class Payload
+// ===-------------------------------------------------------------------------
+
+// 3: Payload
+// 4: Namespace.Payload
+@interface GlobalToMember_Class_Container : NSObject
+@end
+@interface GlobalToMember_Class_Payload : NSObject
+@end
+
+// 3: Namespace.Payload
+// 4: Payload
+@interface MemberToGlobal_Class_Container : NSObject
+@end
+@interface MemberToGlobal_Class_Payload: NSObject
+@end
+
+// 3: Namespace_Swift3.PayloadFor3
+// 4: Namespace_Swift4.PayloadFor4
+@interface MemberToMember_Class_Swift3 : NSObject
+@end
+@interface MemberToMember_Class_Swift4 : NSObject
+@end
+@interface MemberToMember_Class_Payload : NSObject
+@end
+
+// 3: Namespace.PayloadFor3
+// 4: Namespace.PayloadFor4
+@interface MemberToMember_SameContainer_Class_Container : NSObject
+@end
+@interface MemberToMember_SameContainer_Class_Payload : NSObject
+@end
+
+// 3: Namespace_Swift3.Payload
+// 4: Namespace_Swift4.Payload
+@interface MemberToMember_SameName_Class_Swift3 : NSObject
+@end
+@interface MemberToMember_SameName_Class_Swift4 : NSObject
+@end
+@interface MemberToMember_SameName_Class_Payload : NSObject
+@end
+
+// ===-------------------------------------------------------------------------
+// typealias Payload
+// ===-------------------------------------------------------------------------
+
+// 3: Payload
+// 4: Namespace.Payload
+@interface GlobalToMember_Typedef_Container : NSObject
+@end
+typedef Foo* GlobalToMember_Typedef_Payload;
+
+// 3: Namespace.Payload
+// 4: Payload
+@interface MemberToGlobal_Typedef_Container : NSObject
+@end
+typedef Foo* MemberToGlobal_Typedef_Payload;
+
+// 3: Namespace_Swift3.PayloadFor3
+// 4: Namespace_Swift4.PayloadFor4
+@interface MemberToMember_Typedef_Swift3 : NSObject
+@end
+@interface MemberToMember_Typedef_Swift4 : NSObject
+@end
+typedef Foo* MemberToMember_Typedef_Payload;
+
+// 3: Namespace.PayloadFor3
+// 4: Namespace.PayloadFor4
+@interface MemberToMember_SameContainer_Typedef_Container : NSObject
+@end
+typedef Foo* MemberToMember_SameContainer_Typedef_Payload;
+
+// 3: Namespace_Swift3.Payload
+// 4: Namespace_Swift4.Payload
+@interface MemberToMember_SameName_Typedef_Swift3 : NSObject
+@end
+@interface MemberToMember_SameName_Typedef_Swift4 : NSObject
+@end
+typedef Foo* MemberToMember_SameName_Typedef_Payload;
diff --git a/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/Foo.h b/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/Foo.h
new file mode 100644
index 0000000..f854476
--- /dev/null
+++ b/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Headers/Foo.h
@@ -0,0 +1,4 @@
+@import Foundation;
+
+@interface Foo : NSObject
+@end
diff --git a/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Modules/module.modulemap b/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Modules/module.modulemap
new file mode 100644
index 0000000..93b7ac0
--- /dev/null
+++ b/test/SourceKit/InterfaceGen/Inputs/mock-sdk/APINotesTests.framework/Modules/module.modulemap
@@ -0,0 +1,4 @@
+framework module APINotesTests {
+ umbrella header "APINotesTests.h"
+ export *
+}
diff --git a/test/SourceKit/InterfaceGen/gen_clang_module.swift b/test/SourceKit/InterfaceGen/gen_clang_module.swift
index 9c943a0..5d2fc59 100644
--- a/test/SourceKit/InterfaceGen/gen_clang_module.swift
+++ b/test/SourceKit/InterfaceGen/gen_clang_module.swift
@@ -90,3 +90,10 @@
// CHECK-IMPORT: source.lang.swift.ref.module ()
// CHECK-IMPORT-NEXT: FooHelper{{$}}
// CHECK-IMPORT-NEXT: FooHelper{{$}}
+
+// RUN: %sourcekitd-test -req=interface-gen -module APINotesTests -- -swift-version 3 -F %S/Inputs/mock-sdk \
+// RUN: %mcp_opt -target %target-triple %clang-importer-sdk-nosource > %t.apinotes_swift3.response
+// RUN: diff -u %s.apinotes_swift3.response %t.apinotes_swift3.response
+// RUN: %sourcekitd-test -req=interface-gen -module APINotesTests -- -swift-version 4 -F %S/Inputs/mock-sdk \
+// RUN: %mcp_opt -target %target-triple %clang-importer-sdk-nosource > %t.apinotes_swift4.response
+// RUN: diff -u %s.apinotes_swift4.response %t.apinotes_swift4.response
diff --git a/test/SourceKit/InterfaceGen/gen_clang_module.swift.apinotes_swift3.response b/test/SourceKit/InterfaceGen/gen_clang_module.swift.apinotes_swift3.response
new file mode 100644
index 0000000..190980e
--- /dev/null
+++ b/test/SourceKit/InterfaceGen/gen_clang_module.swift.apinotes_swift3.response
@@ -0,0 +1,2501 @@
+import Foundation
+
+
+open class Foo : NSObject {
+}
+// ===-------------------------------------------------------------------------
+// class Payload
+// ===-------------------------------------------------------------------------
+
+// 3: Payload
+// 4: Namespace.Payload
+open class GlobalToMember_Class_Container : NSObject {
+}
+public typealias GlobalToMember_Class_Payload = GlobalToMember_Class_Container.Payload
+extension GlobalToMember_Class_Container {
+
+ open class Payload : NSObject {
+ }
+}
+
+// 3: Namespace.Payload
+// 4: Payload
+open class MemberToGlobal_Class_Container : NSObject {
+}
+open class MemberToGlobal_Class_Payload : NSObject {
+}
+extension MemberToGlobal_Class_Container {
+
+ public typealias Payload = MemberToGlobal_Class_Payload
+}
+
+// 3: Namespace_Swift3.PayloadFor3
+// 4: Namespace_Swift4.PayloadFor4
+open class MemberToMember_Class_Swift3 : NSObject {
+}
+open class MemberToMember_Class_Swift4 : NSObject {
+}
+extension MemberToMember_Class_Swift3 {
+
+ public typealias PayloadFor3 = MemberToMember_Class_Swift4.PayloadFor4
+}
+extension MemberToMember_Class_Swift4 {
+
+ open class PayloadFor4 : NSObject {
+ }
+}
+
+// 3: Namespace.PayloadFor3
+// 4: Namespace.PayloadFor4
+open class MemberToMember_SameContainer_Class_Container : NSObject {
+}
+extension MemberToMember_SameContainer_Class_Container {
+
+ public typealias PayloadFor3 = MemberToMember_SameContainer_Class_Container.PayloadFor4
+
+ open class PayloadFor4 : NSObject {
+ }
+}
+
+// 3: Namespace_Swift3.Payload
+// 4: Namespace_Swift4.Payload
+open class MemberToMember_SameName_Class_Swift3 : NSObject {
+}
+open class MemberToMember_SameName_Class_Swift4 : NSObject {
+}
+extension MemberToMember_SameName_Class_Swift3 {
+
+ public typealias Payload = MemberToMember_SameName_Class_Swift4.Payload
+}
+extension MemberToMember_SameName_Class_Swift4 {
+
+ open class Payload : NSObject {
+ }
+}
+
+// ===-------------------------------------------------------------------------
+// typealias Payload
+// ===-------------------------------------------------------------------------
+
+// 3: Payload
+// 4: Namespace.Payload
+open class GlobalToMember_Typedef_Container : NSObject {
+}
+public typealias GlobalToMember_Typedef_Payload = GlobalToMember_Typedef_Container.Payload
+extension GlobalToMember_Typedef_Container {
+
+ public typealias Payload = Foo
+}
+
+// 3: Namespace.Payload
+// 4: Payload
+open class MemberToGlobal_Typedef_Container : NSObject {
+}
+public typealias MemberToGlobal_Typedef_Payload = Foo
+extension MemberToGlobal_Typedef_Container {
+
+ public typealias Payload = MemberToGlobal_Typedef_Payload
+}
+
+// 3: Namespace_Swift3.PayloadFor3
+// 4: Namespace_Swift4.PayloadFor4
+open class MemberToMember_Typedef_Swift3 : NSObject {
+}
+open class MemberToMember_Typedef_Swift4 : NSObject {
+}
+extension MemberToMember_Typedef_Swift3 {
+
+ public typealias PayloadFor3 = MemberToMember_Typedef_Swift4.PayloadFor4
+}
+extension MemberToMember_Typedef_Swift4 {
+
+ public typealias PayloadFor4 = Foo
+}
+
+// 3: Namespace.PayloadFor3
+// 4: Namespace.PayloadFor4
+open class MemberToMember_SameContainer_Typedef_Container : NSObject {
+}
+extension MemberToMember_SameContainer_Typedef_Container {
+
+ public typealias PayloadFor3 = MemberToMember_SameContainer_Typedef_Container.PayloadFor4
+
+ public typealias PayloadFor4 = Foo
+}
+
+// 3: Namespace_Swift3.Payload
+// 4: Namespace_Swift4.Payload
+open class MemberToMember_SameName_Typedef_Swift3 : NSObject {
+}
+open class MemberToMember_SameName_Typedef_Swift4 : NSObject {
+}
+extension MemberToMember_SameName_Typedef_Swift3 {
+
+ public typealias Payload = MemberToMember_SameName_Typedef_Swift4.Payload
+}
+extension MemberToMember_SameName_Typedef_Swift4 {
+
+ public typealias Payload = Foo
+}
+
+[
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 0,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 7,
+ key.length: 10
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 20,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 25,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 31,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 37,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 50,
+ key.length: 80
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 130,
+ key.length: 17
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 147,
+ key.length: 80
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 228,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 242,
+ key.length: 24
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 266,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 271,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 277,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 310,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 323,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 330,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 340,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 371,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 402,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 410,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 420,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 458,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 463,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 469,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 479,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 499,
+ key.length: 24
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 523,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 537,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 542,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 548,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 581,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 594,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 599,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 605,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 636,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 649,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 659,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 697,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 704,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 714,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 724,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 756,
+ key.length: 35
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 791,
+ key.length: 35
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 826,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 831,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 837,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 867,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 880,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 885,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 891,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 921,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 934,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 944,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 979,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 986,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 996,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1010,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1038,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1052,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1062,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1097,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1102,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1108,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1122,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1142,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1170,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1198,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1203,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1209,
+ key.length: 44
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1256,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1269,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1279,
+ key.length: 44
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1331,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1338,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1348,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1362,
+ key.length: 44
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1407,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1424,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1429,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1435,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1449,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1469,
+ key.length: 31
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1500,
+ key.length: 31
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1531,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1536,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1542,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1581,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1594,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1599,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1605,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1644,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1657,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1667,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1711,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1718,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1728,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1738,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1775,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1785,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1795,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1839,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1844,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1850,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1860,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1880,
+ key.length: 80
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1960,
+ key.length: 21
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1981,
+ key.length: 80
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 2062,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 2076,
+ key.length: 24
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2100,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2105,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2111,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2146,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2159,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2166,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2176,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2209,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2242,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2250,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2260,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2300,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2307,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2317,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2327,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 2334,
+ key.length: 24
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 2358,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2372,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2377,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2383,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2418,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2431,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2438,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2448,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2481,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2485,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2495,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2535,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2542,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2552,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2562,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 2596,
+ key.length: 35
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 2631,
+ key.length: 35
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2666,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2671,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2677,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2709,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2722,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2727,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2733,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2765,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2778,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2788,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2825,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2832,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2842,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2856,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2886,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2900,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2910,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2947,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2954,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2964,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2978,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 2985,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 3013,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 3041,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 3046,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3052,
+ key.length: 46
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3101,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 3114,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3124,
+ key.length: 46
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 3178,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 3185,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3195,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3209,
+ key.length: 46
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3256,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 3273,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 3280,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3290,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3304,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 3311,
+ key.length: 31
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 3342,
+ key.length: 31
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 3373,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 3378,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3384,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3425,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 3438,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 3443,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3449,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3490,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 3503,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3513,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 3559,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 3566,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3576,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3586,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3625,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 3635,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3645,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 3691,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 3698,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3708,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 3718,
+ key.length: 3
+ }
+]
+[
+ {
+ key.kind: source.lang.swift.ref.module,
+ key.offset: 7,
+ key.length: 10,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 37,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 310,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 371,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 402,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 420,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 479,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 581,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 636,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 659,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 724,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 867,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 921,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 944,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1010,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1038,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1062,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1122,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1256,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1279,
+ key.length: 44
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1362,
+ key.length: 44
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1407,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1449,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1581,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1644,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1667,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1738,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1775,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1795,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1860,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2146,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2209,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.ref.typealias,
+ key.offset: 2242,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2260,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2327,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2418,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2481,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2495,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.ref.typealias,
+ key.offset: 2562,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2709,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2765,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2788,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2856,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.ref.typealias,
+ key.offset: 2886,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2910,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2978,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 3101,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 3124,
+ key.length: 46
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 3209,
+ key.length: 46
+ },
+ {
+ key.kind: source.lang.swift.ref.typealias,
+ key.offset: 3256,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 3304,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 3425,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 3490,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 3513,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 3586,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.ref.typealias,
+ key.offset: 3625,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 3645,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 3718,
+ key.length: 3
+ }
+]
+[
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "Foo",
+ key.offset: 25,
+ key.length: 24,
+ key.runtime_name: "_TtC4main3Foo",
+ key.nameoffset: 31,
+ key.namelength: 3,
+ key.bodyoffset: 47,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 20,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 37,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "GlobalToMember_Class_Container",
+ key.offset: 271,
+ key.length: 51,
+ key.runtime_name: "_TtC4main30GlobalToMember_Class_Container",
+ key.nameoffset: 277,
+ key.namelength: 30,
+ key.bodyoffset: 320,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 266,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 310,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "GlobalToMember_Class_Payload",
+ key.offset: 330,
+ key.length: 79,
+ key.nameoffset: 340,
+ key.namelength: 28,
+ key.attributes: [
+ {
+ key.offset: 323,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "GlobalToMember_Class_Container",
+ key.offset: 410,
+ key.length: 87,
+ key.nameoffset: 420,
+ key.namelength: 30,
+ key.bodyoffset: 452,
+ key.bodylength: 44,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "Payload",
+ key.offset: 463,
+ key.length: 32,
+ key.nameoffset: 469,
+ key.namelength: 7,
+ key.bodyoffset: 489,
+ key.bodylength: 5,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 458,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 479,
+ key.length: 8
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToGlobal_Class_Container",
+ key.offset: 542,
+ key.length: 51,
+ key.runtime_name: "_TtC4main30MemberToGlobal_Class_Container",
+ key.nameoffset: 548,
+ key.namelength: 30,
+ key.bodyoffset: 591,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 537,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 581,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToGlobal_Class_Payload",
+ key.offset: 599,
+ key.length: 49,
+ key.runtime_name: "_TtC4main28MemberToGlobal_Class_Payload",
+ key.nameoffset: 605,
+ key.namelength: 28,
+ key.bodyoffset: 646,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 594,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 636,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToGlobal_Class_Container",
+ key.offset: 649,
+ key.length: 105,
+ key.nameoffset: 659,
+ key.namelength: 30,
+ key.bodyoffset: 691,
+ key.bodylength: 62,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "Payload",
+ key.offset: 704,
+ key.length: 48,
+ key.nameoffset: 714,
+ key.namelength: 7,
+ key.attributes: [
+ {
+ key.offset: 697,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_Class_Swift3",
+ key.offset: 831,
+ key.length: 48,
+ key.runtime_name: "_TtC4main27MemberToMember_Class_Swift3",
+ key.nameoffset: 837,
+ key.namelength: 27,
+ key.bodyoffset: 877,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 826,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 867,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_Class_Swift4",
+ key.offset: 885,
+ key.length: 48,
+ key.runtime_name: "_TtC4main27MemberToMember_Class_Swift4",
+ key.nameoffset: 891,
+ key.namelength: 27,
+ key.bodyoffset: 931,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 880,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 921,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_Class_Swift3",
+ key.offset: 934,
+ key.length: 117,
+ key.nameoffset: 944,
+ key.namelength: 27,
+ key.bodyoffset: 973,
+ key.bodylength: 77,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "PayloadFor3",
+ key.offset: 986,
+ key.length: 63,
+ key.nameoffset: 996,
+ key.namelength: 11,
+ key.attributes: [
+ {
+ key.offset: 979,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_Class_Swift4",
+ key.offset: 1052,
+ key.length: 88,
+ key.nameoffset: 1062,
+ key.namelength: 27,
+ key.bodyoffset: 1091,
+ key.bodylength: 48,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "PayloadFor4",
+ key.offset: 1102,
+ key.length: 36,
+ key.nameoffset: 1108,
+ key.namelength: 11,
+ key.bodyoffset: 1132,
+ key.bodylength: 5,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1097,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1122,
+ key.length: 8
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameContainer_Class_Container",
+ key.offset: 1203,
+ key.length: 65,
+ key.runtime_name: "_TtC4main44MemberToMember_SameContainer_Class_Container",
+ key.nameoffset: 1209,
+ key.namelength: 44,
+ key.bodyoffset: 1266,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1198,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1256,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_SameContainer_Class_Container",
+ key.offset: 1269,
+ key.length: 198,
+ key.nameoffset: 1279,
+ key.namelength: 44,
+ key.bodyoffset: 1325,
+ key.bodylength: 141,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "PayloadFor3",
+ key.offset: 1338,
+ key.length: 80,
+ key.nameoffset: 1348,
+ key.namelength: 11,
+ key.attributes: [
+ {
+ key.offset: 1331,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "PayloadFor4",
+ key.offset: 1429,
+ key.length: 36,
+ key.nameoffset: 1435,
+ key.namelength: 11,
+ key.bodyoffset: 1459,
+ key.bodylength: 5,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1424,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1449,
+ key.length: 8
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameName_Class_Swift3",
+ key.offset: 1536,
+ key.length: 57,
+ key.runtime_name: "_TtC4main36MemberToMember_SameName_Class_Swift3",
+ key.nameoffset: 1542,
+ key.namelength: 36,
+ key.bodyoffset: 1591,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1531,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1581,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameName_Class_Swift4",
+ key.offset: 1599,
+ key.length: 57,
+ key.runtime_name: "_TtC4main36MemberToMember_SameName_Class_Swift4",
+ key.nameoffset: 1605,
+ key.namelength: 36,
+ key.bodyoffset: 1654,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1594,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1644,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_SameName_Class_Swift3",
+ key.offset: 1657,
+ key.length: 127,
+ key.nameoffset: 1667,
+ key.namelength: 36,
+ key.bodyoffset: 1705,
+ key.bodylength: 78,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "Payload",
+ key.offset: 1718,
+ key.length: 64,
+ key.nameoffset: 1728,
+ key.namelength: 7,
+ key.attributes: [
+ {
+ key.offset: 1711,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_SameName_Class_Swift4",
+ key.offset: 1785,
+ key.length: 93,
+ key.nameoffset: 1795,
+ key.namelength: 36,
+ key.bodyoffset: 1833,
+ key.bodylength: 44,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "Payload",
+ key.offset: 1844,
+ key.length: 32,
+ key.nameoffset: 1850,
+ key.namelength: 7,
+ key.bodyoffset: 1870,
+ key.bodylength: 5,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1839,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1860,
+ key.length: 8
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "GlobalToMember_Typedef_Container",
+ key.offset: 2105,
+ key.length: 53,
+ key.runtime_name: "_TtC4main32GlobalToMember_Typedef_Container",
+ key.nameoffset: 2111,
+ key.namelength: 32,
+ key.bodyoffset: 2156,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 2100,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 2146,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "GlobalToMember_Typedef_Payload",
+ key.offset: 2166,
+ key.length: 83,
+ key.nameoffset: 2176,
+ key.namelength: 30,
+ key.attributes: [
+ {
+ key.offset: 2159,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "GlobalToMember_Typedef_Container",
+ key.offset: 2250,
+ key.length: 82,
+ key.nameoffset: 2260,
+ key.namelength: 32,
+ key.bodyoffset: 2294,
+ key.bodylength: 37,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "Payload",
+ key.offset: 2307,
+ key.length: 23,
+ key.nameoffset: 2317,
+ key.namelength: 7,
+ key.attributes: [
+ {
+ key.offset: 2300,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToGlobal_Typedef_Container",
+ key.offset: 2377,
+ key.length: 53,
+ key.runtime_name: "_TtC4main32MemberToGlobal_Typedef_Container",
+ key.nameoffset: 2383,
+ key.namelength: 32,
+ key.bodyoffset: 2428,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 2372,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 2418,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "MemberToGlobal_Typedef_Payload",
+ key.offset: 2438,
+ key.length: 46,
+ key.nameoffset: 2448,
+ key.namelength: 30,
+ key.attributes: [
+ {
+ key.offset: 2431,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToGlobal_Typedef_Container",
+ key.offset: 2485,
+ key.length: 109,
+ key.nameoffset: 2495,
+ key.namelength: 32,
+ key.bodyoffset: 2529,
+ key.bodylength: 64,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "Payload",
+ key.offset: 2542,
+ key.length: 50,
+ key.nameoffset: 2552,
+ key.namelength: 7,
+ key.attributes: [
+ {
+ key.offset: 2535,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_Typedef_Swift3",
+ key.offset: 2671,
+ key.length: 50,
+ key.runtime_name: "_TtC4main29MemberToMember_Typedef_Swift3",
+ key.nameoffset: 2677,
+ key.namelength: 29,
+ key.bodyoffset: 2719,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 2666,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 2709,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_Typedef_Swift4",
+ key.offset: 2727,
+ key.length: 50,
+ key.runtime_name: "_TtC4main29MemberToMember_Typedef_Swift4",
+ key.nameoffset: 2733,
+ key.namelength: 29,
+ key.bodyoffset: 2775,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 2722,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 2765,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_Typedef_Swift3",
+ key.offset: 2778,
+ key.length: 121,
+ key.nameoffset: 2788,
+ key.namelength: 29,
+ key.bodyoffset: 2819,
+ key.bodylength: 79,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "PayloadFor3",
+ key.offset: 2832,
+ key.length: 65,
+ key.nameoffset: 2842,
+ key.namelength: 11,
+ key.attributes: [
+ {
+ key.offset: 2825,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_Typedef_Swift4",
+ key.offset: 2900,
+ key.length: 83,
+ key.nameoffset: 2910,
+ key.namelength: 29,
+ key.bodyoffset: 2941,
+ key.bodylength: 41,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "PayloadFor4",
+ key.offset: 2954,
+ key.length: 27,
+ key.nameoffset: 2964,
+ key.namelength: 11,
+ key.attributes: [
+ {
+ key.offset: 2947,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameContainer_Typedef_Container",
+ key.offset: 3046,
+ key.length: 67,
+ key.runtime_name: "_TtC4main46MemberToMember_SameContainer_Typedef_Container",
+ key.nameoffset: 3052,
+ key.namelength: 46,
+ key.bodyoffset: 3111,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 3041,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 3101,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_SameContainer_Typedef_Container",
+ key.offset: 3114,
+ key.length: 195,
+ key.nameoffset: 3124,
+ key.namelength: 46,
+ key.bodyoffset: 3172,
+ key.bodylength: 136,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "PayloadFor3",
+ key.offset: 3185,
+ key.length: 82,
+ key.nameoffset: 3195,
+ key.namelength: 11,
+ key.attributes: [
+ {
+ key.offset: 3178,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "PayloadFor4",
+ key.offset: 3280,
+ key.length: 27,
+ key.nameoffset: 3290,
+ key.namelength: 11,
+ key.attributes: [
+ {
+ key.offset: 3273,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameName_Typedef_Swift3",
+ key.offset: 3378,
+ key.length: 59,
+ key.runtime_name: "_TtC4main38MemberToMember_SameName_Typedef_Swift3",
+ key.nameoffset: 3384,
+ key.namelength: 38,
+ key.bodyoffset: 3435,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 3373,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 3425,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameName_Typedef_Swift4",
+ key.offset: 3443,
+ key.length: 59,
+ key.runtime_name: "_TtC4main38MemberToMember_SameName_Typedef_Swift4",
+ key.nameoffset: 3449,
+ key.namelength: 38,
+ key.bodyoffset: 3500,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 3438,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 3490,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_SameName_Typedef_Swift3",
+ key.offset: 3503,
+ key.length: 131,
+ key.nameoffset: 3513,
+ key.namelength: 38,
+ key.bodyoffset: 3553,
+ key.bodylength: 80,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "Payload",
+ key.offset: 3566,
+ key.length: 66,
+ key.nameoffset: 3576,
+ key.namelength: 7,
+ key.attributes: [
+ {
+ key.offset: 3559,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_SameName_Typedef_Swift4",
+ key.offset: 3635,
+ key.length: 88,
+ key.nameoffset: 3645,
+ key.namelength: 38,
+ key.bodyoffset: 3685,
+ key.bodylength: 37,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "Payload",
+ key.offset: 3698,
+ key.length: 23,
+ key.nameoffset: 3708,
+ key.namelength: 7,
+ key.attributes: [
+ {
+ key.offset: 3691,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ }
+]
diff --git a/test/SourceKit/InterfaceGen/gen_clang_module.swift.apinotes_swift4.response b/test/SourceKit/InterfaceGen/gen_clang_module.swift.apinotes_swift4.response
new file mode 100644
index 0000000..9d8951b
--- /dev/null
+++ b/test/SourceKit/InterfaceGen/gen_clang_module.swift.apinotes_swift4.response
@@ -0,0 +1,1819 @@
+import Foundation
+
+
+open class Foo : NSObject {
+}
+// ===-------------------------------------------------------------------------
+// class Payload
+// ===-------------------------------------------------------------------------
+
+// 3: Payload
+// 4: Namespace.Payload
+open class GlobalToMember_Class_Container : NSObject {
+}
+extension GlobalToMember_Class_Container {
+
+ open class Payload : NSObject {
+ }
+}
+
+// 3: Namespace.Payload
+// 4: Payload
+open class MemberToGlobal_Class_Container : NSObject {
+}
+open class MemberToGlobal_Class_Payload : NSObject {
+}
+
+// 3: Namespace_Swift3.PayloadFor3
+// 4: Namespace_Swift4.PayloadFor4
+open class MemberToMember_Class_Swift3 : NSObject {
+}
+open class MemberToMember_Class_Swift4 : NSObject {
+}
+extension MemberToMember_Class_Swift4 {
+
+ open class PayloadFor4 : NSObject {
+ }
+}
+
+// 3: Namespace.PayloadFor3
+// 4: Namespace.PayloadFor4
+open class MemberToMember_SameContainer_Class_Container : NSObject {
+}
+extension MemberToMember_SameContainer_Class_Container {
+
+ open class PayloadFor4 : NSObject {
+ }
+}
+
+// 3: Namespace_Swift3.Payload
+// 4: Namespace_Swift4.Payload
+open class MemberToMember_SameName_Class_Swift3 : NSObject {
+}
+open class MemberToMember_SameName_Class_Swift4 : NSObject {
+}
+extension MemberToMember_SameName_Class_Swift4 {
+
+ open class Payload : NSObject {
+ }
+}
+
+// ===-------------------------------------------------------------------------
+// typealias Payload
+// ===-------------------------------------------------------------------------
+
+// 3: Payload
+// 4: Namespace.Payload
+open class GlobalToMember_Typedef_Container : NSObject {
+}
+extension GlobalToMember_Typedef_Container {
+
+ public typealias Payload = Foo
+}
+
+// 3: Namespace.Payload
+// 4: Payload
+open class MemberToGlobal_Typedef_Container : NSObject {
+}
+public typealias MemberToGlobal_Typedef_Payload = Foo
+
+// 3: Namespace_Swift3.PayloadFor3
+// 4: Namespace_Swift4.PayloadFor4
+open class MemberToMember_Typedef_Swift3 : NSObject {
+}
+open class MemberToMember_Typedef_Swift4 : NSObject {
+}
+extension MemberToMember_Typedef_Swift4 {
+
+ public typealias PayloadFor4 = Foo
+}
+
+// 3: Namespace.PayloadFor3
+// 4: Namespace.PayloadFor4
+open class MemberToMember_SameContainer_Typedef_Container : NSObject {
+}
+extension MemberToMember_SameContainer_Typedef_Container {
+
+ public typealias PayloadFor4 = Foo
+}
+
+// 3: Namespace_Swift3.Payload
+// 4: Namespace_Swift4.Payload
+open class MemberToMember_SameName_Typedef_Swift3 : NSObject {
+}
+open class MemberToMember_SameName_Typedef_Swift4 : NSObject {
+}
+extension MemberToMember_SameName_Typedef_Swift4 {
+
+ public typealias Payload = Foo
+}
+
+[
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 0,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 7,
+ key.length: 10
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 20,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 25,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 31,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 37,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 50,
+ key.length: 80
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 130,
+ key.length: 17
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 147,
+ key.length: 80
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 228,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 242,
+ key.length: 24
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 266,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 271,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 277,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 310,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 323,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 333,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 371,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 376,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 382,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 392,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 412,
+ key.length: 24
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 436,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 450,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 455,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 461,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 494,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 507,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 512,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 518,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 549,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 563,
+ key.length: 35
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 598,
+ key.length: 35
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 633,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 638,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 644,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 674,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 687,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 692,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 698,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 728,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 741,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 751,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 786,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 791,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 797,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 811,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 831,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 859,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 887,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 892,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 898,
+ key.length: 44
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 945,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 958,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 968,
+ key.length: 44
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1020,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1025,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1031,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1045,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1065,
+ key.length: 31
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1096,
+ key.length: 31
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1127,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1132,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1138,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1177,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1190,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1195,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1201,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1240,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1253,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1263,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1307,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1312,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1318,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1328,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1348,
+ key.length: 80
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1428,
+ key.length: 21
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1449,
+ key.length: 80
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1530,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1544,
+ key.length: 24
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1568,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1573,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1579,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1614,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1627,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1637,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1677,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1684,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1694,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1704,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1711,
+ key.length: 24
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1735,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1749,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1754,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1760,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1795,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1808,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1815,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1825,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1858,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1863,
+ key.length: 35
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 1898,
+ key.length: 35
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1933,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1938,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1944,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1976,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 1989,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 1994,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2000,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2032,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2045,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2055,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2092,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2099,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2109,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2123,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 2130,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 2158,
+ key.length: 28
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2186,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2191,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2197,
+ key.length: 46
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2246,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2259,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2269,
+ key.length: 46
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2323,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2330,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2340,
+ key.length: 11
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2354,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 2361,
+ key.length: 31
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.comment,
+ key.offset: 2392,
+ key.length: 31
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2423,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2428,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2434,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2475,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2488,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2493,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2499,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2540,
+ key.length: 8
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2553,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2563,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.attribute.builtin,
+ key.offset: 2609,
+ key.length: 6
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 2616,
+ key.length: 9
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2626,
+ key.length: 7
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 2636,
+ key.length: 3
+ }
+]
+[
+ {
+ key.kind: source.lang.swift.ref.module,
+ key.offset: 7,
+ key.length: 10,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 37,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 310,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 333,
+ key.length: 30
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 392,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 494,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 549,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 674,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 728,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 751,
+ key.length: 27
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 811,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 945,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 968,
+ key.length: 44
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1045,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1177,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1240,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1263,
+ key.length: 36
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1328,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1614,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1637,
+ key.length: 32
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1704,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1795,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1858,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 1976,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2032,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2055,
+ key.length: 29
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2123,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2246,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2269,
+ key.length: 46
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2354,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2475,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2540,
+ key.length: 8,
+ key.is_system: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2563,
+ key.length: 38
+ },
+ {
+ key.kind: source.lang.swift.ref.class,
+ key.offset: 2636,
+ key.length: 3
+ }
+]
+[
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "Foo",
+ key.offset: 25,
+ key.length: 24,
+ key.runtime_name: "_TtC4main3Foo",
+ key.nameoffset: 31,
+ key.namelength: 3,
+ key.bodyoffset: 47,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 20,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 37,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "GlobalToMember_Class_Container",
+ key.offset: 271,
+ key.length: 51,
+ key.runtime_name: "_TtC4main30GlobalToMember_Class_Container",
+ key.nameoffset: 277,
+ key.namelength: 30,
+ key.bodyoffset: 320,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 266,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 310,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "GlobalToMember_Class_Container",
+ key.offset: 323,
+ key.length: 87,
+ key.nameoffset: 333,
+ key.namelength: 30,
+ key.bodyoffset: 365,
+ key.bodylength: 44,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "Payload",
+ key.offset: 376,
+ key.length: 32,
+ key.nameoffset: 382,
+ key.namelength: 7,
+ key.bodyoffset: 402,
+ key.bodylength: 5,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 371,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 392,
+ key.length: 8
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToGlobal_Class_Container",
+ key.offset: 455,
+ key.length: 51,
+ key.runtime_name: "_TtC4main30MemberToGlobal_Class_Container",
+ key.nameoffset: 461,
+ key.namelength: 30,
+ key.bodyoffset: 504,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 450,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 494,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToGlobal_Class_Payload",
+ key.offset: 512,
+ key.length: 49,
+ key.runtime_name: "_TtC4main28MemberToGlobal_Class_Payload",
+ key.nameoffset: 518,
+ key.namelength: 28,
+ key.bodyoffset: 559,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 507,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 549,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_Class_Swift3",
+ key.offset: 638,
+ key.length: 48,
+ key.runtime_name: "_TtC4main27MemberToMember_Class_Swift3",
+ key.nameoffset: 644,
+ key.namelength: 27,
+ key.bodyoffset: 684,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 633,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 674,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_Class_Swift4",
+ key.offset: 692,
+ key.length: 48,
+ key.runtime_name: "_TtC4main27MemberToMember_Class_Swift4",
+ key.nameoffset: 698,
+ key.namelength: 27,
+ key.bodyoffset: 738,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 687,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 728,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_Class_Swift4",
+ key.offset: 741,
+ key.length: 88,
+ key.nameoffset: 751,
+ key.namelength: 27,
+ key.bodyoffset: 780,
+ key.bodylength: 48,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "PayloadFor4",
+ key.offset: 791,
+ key.length: 36,
+ key.nameoffset: 797,
+ key.namelength: 11,
+ key.bodyoffset: 821,
+ key.bodylength: 5,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 786,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 811,
+ key.length: 8
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameContainer_Class_Container",
+ key.offset: 892,
+ key.length: 65,
+ key.runtime_name: "_TtC4main44MemberToMember_SameContainer_Class_Container",
+ key.nameoffset: 898,
+ key.namelength: 44,
+ key.bodyoffset: 955,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 887,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 945,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_SameContainer_Class_Container",
+ key.offset: 958,
+ key.length: 105,
+ key.nameoffset: 968,
+ key.namelength: 44,
+ key.bodyoffset: 1014,
+ key.bodylength: 48,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "PayloadFor4",
+ key.offset: 1025,
+ key.length: 36,
+ key.nameoffset: 1031,
+ key.namelength: 11,
+ key.bodyoffset: 1055,
+ key.bodylength: 5,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1020,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1045,
+ key.length: 8
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameName_Class_Swift3",
+ key.offset: 1132,
+ key.length: 57,
+ key.runtime_name: "_TtC4main36MemberToMember_SameName_Class_Swift3",
+ key.nameoffset: 1138,
+ key.namelength: 36,
+ key.bodyoffset: 1187,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1127,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1177,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameName_Class_Swift4",
+ key.offset: 1195,
+ key.length: 57,
+ key.runtime_name: "_TtC4main36MemberToMember_SameName_Class_Swift4",
+ key.nameoffset: 1201,
+ key.namelength: 36,
+ key.bodyoffset: 1250,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1190,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1240,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_SameName_Class_Swift4",
+ key.offset: 1253,
+ key.length: 93,
+ key.nameoffset: 1263,
+ key.namelength: 36,
+ key.bodyoffset: 1301,
+ key.bodylength: 44,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "Payload",
+ key.offset: 1312,
+ key.length: 32,
+ key.nameoffset: 1318,
+ key.namelength: 7,
+ key.bodyoffset: 1338,
+ key.bodylength: 5,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1307,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1328,
+ key.length: 8
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "GlobalToMember_Typedef_Container",
+ key.offset: 1573,
+ key.length: 53,
+ key.runtime_name: "_TtC4main32GlobalToMember_Typedef_Container",
+ key.nameoffset: 1579,
+ key.namelength: 32,
+ key.bodyoffset: 1624,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1568,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1614,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "GlobalToMember_Typedef_Container",
+ key.offset: 1627,
+ key.length: 82,
+ key.nameoffset: 1637,
+ key.namelength: 32,
+ key.bodyoffset: 1671,
+ key.bodylength: 37,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "Payload",
+ key.offset: 1684,
+ key.length: 23,
+ key.nameoffset: 1694,
+ key.namelength: 7,
+ key.attributes: [
+ {
+ key.offset: 1677,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToGlobal_Typedef_Container",
+ key.offset: 1754,
+ key.length: 53,
+ key.runtime_name: "_TtC4main32MemberToGlobal_Typedef_Container",
+ key.nameoffset: 1760,
+ key.namelength: 32,
+ key.bodyoffset: 1805,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1749,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1795,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "MemberToGlobal_Typedef_Payload",
+ key.offset: 1815,
+ key.length: 46,
+ key.nameoffset: 1825,
+ key.namelength: 30,
+ key.attributes: [
+ {
+ key.offset: 1808,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_Typedef_Swift3",
+ key.offset: 1938,
+ key.length: 50,
+ key.runtime_name: "_TtC4main29MemberToMember_Typedef_Swift3",
+ key.nameoffset: 1944,
+ key.namelength: 29,
+ key.bodyoffset: 1986,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1933,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 1976,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_Typedef_Swift4",
+ key.offset: 1994,
+ key.length: 50,
+ key.runtime_name: "_TtC4main29MemberToMember_Typedef_Swift4",
+ key.nameoffset: 2000,
+ key.namelength: 29,
+ key.bodyoffset: 2042,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 1989,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 2032,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_Typedef_Swift4",
+ key.offset: 2045,
+ key.length: 83,
+ key.nameoffset: 2055,
+ key.namelength: 29,
+ key.bodyoffset: 2086,
+ key.bodylength: 41,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "PayloadFor4",
+ key.offset: 2099,
+ key.length: 27,
+ key.nameoffset: 2109,
+ key.namelength: 11,
+ key.attributes: [
+ {
+ key.offset: 2092,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameContainer_Typedef_Container",
+ key.offset: 2191,
+ key.length: 67,
+ key.runtime_name: "_TtC4main46MemberToMember_SameContainer_Typedef_Container",
+ key.nameoffset: 2197,
+ key.namelength: 46,
+ key.bodyoffset: 2256,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 2186,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 2246,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_SameContainer_Typedef_Container",
+ key.offset: 2259,
+ key.length: 100,
+ key.nameoffset: 2269,
+ key.namelength: 46,
+ key.bodyoffset: 2317,
+ key.bodylength: 41,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "PayloadFor4",
+ key.offset: 2330,
+ key.length: 27,
+ key.nameoffset: 2340,
+ key.namelength: 11,
+ key.attributes: [
+ {
+ key.offset: 2323,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameName_Typedef_Swift3",
+ key.offset: 2428,
+ key.length: 59,
+ key.runtime_name: "_TtC4main38MemberToMember_SameName_Typedef_Swift3",
+ key.nameoffset: 2434,
+ key.namelength: 38,
+ key.bodyoffset: 2485,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 2423,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 2475,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.class,
+ key.accessibility: source.lang.swift.accessibility.open,
+ key.name: "MemberToMember_SameName_Typedef_Swift4",
+ key.offset: 2493,
+ key.length: 59,
+ key.runtime_name: "_TtC4main38MemberToMember_SameName_Typedef_Swift4",
+ key.nameoffset: 2499,
+ key.namelength: 38,
+ key.bodyoffset: 2550,
+ key.bodylength: 1,
+ key.inheritedtypes: [
+ {
+ key.name: "NSObject"
+ }
+ ],
+ key.attributes: [
+ {
+ key.offset: 2488,
+ key.length: 4,
+ key.attribute: source.decl.attribute.open
+ }
+ ],
+ key.elements: [
+ {
+ key.kind: source.lang.swift.structure.elem.typeref,
+ key.offset: 2540,
+ key.length: 8
+ }
+ ]
+ },
+ {
+ key.kind: source.lang.swift.decl.extension,
+ key.name: "MemberToMember_SameName_Typedef_Swift4",
+ key.offset: 2553,
+ key.length: 88,
+ key.nameoffset: 2563,
+ key.namelength: 38,
+ key.bodyoffset: 2603,
+ key.bodylength: 37,
+ key.substructure: [
+ {
+ key.kind: source.lang.swift.decl.typealias,
+ key.accessibility: source.lang.swift.accessibility.public,
+ key.name: "Payload",
+ key.offset: 2616,
+ key.length: 23,
+ key.nameoffset: 2626,
+ key.namelength: 7,
+ key.attributes: [
+ {
+ key.offset: 2609,
+ key.length: 6,
+ key.attribute: source.decl.attribute.public
+ }
+ ]
+ }
+ ]
+ }
+]
diff --git a/test/SourceKit/Misc/ignored-flags-sanitizers.swift b/test/SourceKit/Misc/ignored-flags-sanitizers.swift
new file mode 100644
index 0000000..e2b78d6
--- /dev/null
+++ b/test/SourceKit/Misc/ignored-flags-sanitizers.swift
@@ -0,0 +1,9 @@
+var s = 10
+s.
+
+// CHECK: littleEndian
+
+// REQUIRES: asan_runtime
+// REQUIRES: fuzzer_runtime
+
+// RUN: %sourcekitd-test -req=complete -pos=2:3 %s -- -sanitize=address,fuzzer -sanitize-coverage=func %s | %FileCheck %s
diff --git a/test/SourceKit/Misc/ignored-flags.swift b/test/SourceKit/Misc/ignored-flags.swift
index ea00ff6..7636d3d 100644
--- a/test/SourceKit/Misc/ignored-flags.swift
+++ b/test/SourceKit/Misc/ignored-flags.swift
@@ -15,7 +15,6 @@
// RUN: %sourcekitd-test -req=complete -pos=2:3 %s -- -use-ld=blah %s | %FileCheck %s
// RUN: %sourcekitd-test -req=complete -pos=2:3 %s -- -incremental %s | %FileCheck %s
// RUN: %sourcekitd-test -req=complete -pos=2:3 %s -- -driver-time-compilation %s | %FileCheck %s
-// RUN: %sourcekitd-test -req=complete -pos=2:3 %s -- -sanitize=address,fuzzer -sanitize-coverage=func %s | %FileCheck %s
// Mode flags
diff --git a/test/SwiftSyntax/Inputs/nested-blocks.swift b/test/SwiftSyntax/Inputs/nested-blocks.swift
new file mode 100644
index 0000000..d1b947b
--- /dev/null
+++ b/test/SwiftSyntax/Inputs/nested-blocks.swift
@@ -0,0 +1,8 @@
+struct Foo {
+ func foo() {
+ print("hello")
+ func bar() {
+ print("goodbye")
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/SwiftSyntax/VisitorTest.swift b/test/SwiftSyntax/VisitorTest.swift
index bd381eb..e24ba6b 100644
--- a/test/SwiftSyntax/VisitorTest.swift
+++ b/test/SwiftSyntax/VisitorTest.swift
@@ -77,4 +77,24 @@
})
}
+VisitorTests.test("SyntaxRewriter.visitCollection") {
+ class VisitCollections: SyntaxVisitor {
+ var numberOfCodeBlockItems = 0
+
+ override func visit(_ items: CodeBlockItemListSyntax) {
+ numberOfCodeBlockItems += items.count
+ super.visit(items)
+ }
+ }
+
+ expectDoesNotThrow({
+ let parsed = try SourceFileSyntax.decodeSourceFileSyntax(
+ try SwiftLang.parse(getInput("nested-blocks.swift"))
+ )
+ let visitor = VisitCollections()
+ visitor.visit(parsed)
+ expectEqual(4, visitor.numberOfCodeBlockItems)
+ })
+}
+
runAllTests()
diff --git a/test/TBD/Inputs/subclass_super.swift b/test/TBD/Inputs/subclass_super.swift
new file mode 100644
index 0000000..3dffca2
--- /dev/null
+++ b/test/TBD/Inputs/subclass_super.swift
@@ -0,0 +1,9 @@
+open class Super {
+ open func function() {}
+
+ open var getter: Int { return 0 }
+ open var getterSetter: Int {
+ get { return 0 }
+ set {}
+ }
+}
diff --git a/test/TBD/enum.swift b/test/TBD/enum.swift
index 9774395..548f91c 100644
--- a/test/TBD/enum.swift
+++ b/test/TBD/enum.swift
@@ -1,17 +1,50 @@
// RUN: %target-swift-frontend -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %s
// RUN: %target-swift-frontend -enable-resilience -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %s
+// Swift 4:
+// RUN: %target-swift-frontend -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -swift-version 4
+// RUN: %target-swift-frontend -enable-resilience -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -swift-version 4
-class C {
+public protocol P {}
+
+public class C {
}
-enum SinglePayload {
+public enum SinglePayload: P {
case A
case B(C)
case D
}
-enum MultiPayload {
+public enum MultiPayload {
case A
case B(C)
case D(C)
+
+ public func method() {}
+}
+
+public enum AutomaticEquatableHashable {
+ case a, b
+}
+
+public enum Synthesized: Equatable, Hashable {
+ case a(AutomaticEquatableHashable), b
+}
+public enum ConditionalSynthesized<T> {
+ case a(T), b
+}
+
+#if swift(>=4)
+extension ConditionalSynthesized: Equatable where T: Equatable {}
+extension ConditionalSynthesized: Hashable where T: Hashable {}
+#endif
+
+public enum ZeroCases {}
+
+public enum OneCase {
+ case a
+}
+
+public enum OneCasePayload {
+ case a(C)
}
diff --git a/test/TBD/function.swift b/test/TBD/function.swift
index f2974ae..9e7cc5d 100644
--- a/test/TBD/function.swift
+++ b/test/TBD/function.swift
@@ -12,3 +12,11 @@
private func privateNoArgs() {}
private func privateSomeArgs(_: Int, x: Int) {}
private func privateWithDefault(_: Int = 0) {}
+
+@_cdecl("c_publicNoArgs") public func publicNoArgsCDecl() {}
+@_cdecl("c_publicSomeArgs") public func publicSomeArgsCDecl(_: Int, x: Int) {}
+@_cdecl("c_publicWithDefault") public func publicWithDefaultCDecl(_: Int = 0) {}
+
+@_cdecl("c_internalNoArgs") internal func internalNoArgsCDecl() {}
+@_cdecl("c_internalSomeArgs") internal func internalSomeArgsCDecl(_: Int, x: Int) {}
+@_cdecl("c_internalWithDefault") internal func internalWithDefaultCDecl(_: Int = 0) {}
diff --git a/test/TBD/subclass.swift.gyb b/test/TBD/subclass.swift.gyb
new file mode 100644
index 0000000..7510c08
--- /dev/null
+++ b/test/TBD/subclass.swift.gyb
@@ -0,0 +1,55 @@
+// RUN: %empty-directory(%t)
+// RUN: %gyb %s > %t/main.swift
+
+// Same-module superclass, both resilient and not:
+// RUN: %target-swift-frontend -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %t/main.swift -DSAME_MODULE
+// RUN: %target-swift-frontend -enable-resilience -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %t/main.swift -DSAME_MODULE
+
+
+// Other-module superclass is not resilient:
+// RUN: %empty-directory(%t/super)
+// RUN: %target-build-swift %S/Inputs/subclass_super.swift -emit-library -emit-module -o %t/super/subclass_super.%target-dylib-extension
+// RUN: %target-swift-frontend -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %t/main.swift -I %t/super
+// RUN: %target-swift-frontend -enable-resilience -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %t/main.swift -I %t/super
+
+// Other-module superclass is resilient:
+// RUN: %empty-directory(%t/super)
+// RUN: %target-build-swift %S/Inputs/subclass_super.swift -emit-library -emit-module -o %t/super/subclass_super.%target-dylib-extension -Xfrontend -enable-resilience
+// RUN: %target-swift-frontend -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %t/main.swift -I %t/super
+// RUN: %target-swift-frontend -enable-resilience -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %t/main.swift -I %t/super
+
+#if SAME_MODULE
+open class Super {
+ open func function() {}
+
+ open var getter: Int { return 0 }
+ open var getterSetter: Int {
+ get { return 0 }
+ set {}
+ }
+}
+#else
+import subclass_super
+#endif
+
+// Create a variety of variations like `open class ... { open override
+// func function() }` and `public class ... { public final override
+// func function() }`.
+% for access in ["open", "public", "internal", "fileprivate"]:
+% for class_final in [""] if access == "open" else ["", "final"]:
+% for member_final in [""] if access == "open" else ["", "final"]:
+% class_mod = "%s %s" % (access, class_final)
+% name = "Sub_%s_%s_%s" % (access, class_final, member_final)
+% member_mod = "%s %s" % (access, member_final)
+${class_mod} class ${name} : Super {
+ ${member_mod} override func function() {}
+
+ ${member_mod} override var getter: Int { return 0 }
+
+ ${member_mod} override var getterSetter: Int {
+ get { return 0 }
+ set {}
+ }
+}
+% end
+% end
diff --git a/test/decl/protocol/special/coding/class_codable_inheritance.swift b/test/decl/protocol/special/coding/class_codable_inheritance.swift
index baa2173..8d071b2 100644
--- a/test/decl/protocol/special/coding/class_codable_inheritance.swift
+++ b/test/decl/protocol/special/coding/class_codable_inheritance.swift
@@ -29,7 +29,7 @@
let _ = SimpleChildClass.CodingKeys.self // expected-error {{'CodingKeys' is inaccessible due to 'private' protection level}}
// The enum should have a case for each of the vars.
- // NOTE: This expectedxerror will need to be removed in the future.
+ // NOTE: This expected error will need to be removed in the future.
let _ = SimpleChildClass.CodingKeys.w // expected-error {{'CodingKeys' is inaccessible due to 'private' protection level}}
// Inherited vars should not be part of the CodingKeys enum.
diff --git a/test/stdlib/ErrorBridgedStatic.swift b/test/stdlib/ErrorBridgedStatic.swift
index 6a500ed..7638c15 100644
--- a/test/stdlib/ErrorBridgedStatic.swift
+++ b/test/stdlib/ErrorBridgedStatic.swift
@@ -14,10 +14,6 @@
override func foo(_ x: Int32) throws {
try super.foo(5)
}
-
- override func foothrows(_ x: Int32) throws {
- try super.foothrows(5)
- }
}
var ErrorBridgingStaticTests = TestSuite("ErrorBridging with static libs")
@@ -28,14 +24,4 @@
} catch { }
}
-ErrorBridgingStaticTests.test("round-trip Swift override of throwing ObjC method") {
- do {
- try (Bar() as Foo).foothrows(5)
- } catch {
- print(error)
- expectEqual(error._domain, "abcd")
- expectEqual(error._code, 1234)
- }
-}
-
runAllTests()
diff --git a/test/stdlib/Inputs/ErrorBridgedStaticImpl.h b/test/stdlib/Inputs/ErrorBridgedStaticImpl.h
index fc9cb15..207fc66 100644
--- a/test/stdlib/Inputs/ErrorBridgedStaticImpl.h
+++ b/test/stdlib/Inputs/ErrorBridgedStaticImpl.h
@@ -3,6 +3,5 @@
@interface Foo: NSObject
- (BOOL)foo:(int)x error:(NSError**)error;
-- (BOOL)foothrows:(int)x error:(NSError**)error;
@end
diff --git a/test/stdlib/Inputs/ErrorBridgedStaticImpl.m b/test/stdlib/Inputs/ErrorBridgedStaticImpl.m
index 95615e1..2edc640 100644
--- a/test/stdlib/Inputs/ErrorBridgedStaticImpl.m
+++ b/test/stdlib/Inputs/ErrorBridgedStaticImpl.m
@@ -7,10 +7,5 @@
return NO;
}
-- (BOOL)foothrows:(int)x error:(NSError**)error {
- *error = [NSError errorWithDomain: @"abcd" code: 1234 userInfo: nil];
- return NO;
-}
-
@end
diff --git a/test/stdlib/Inputs/RuntimeRetroactiveConformance/A.swift b/test/stdlib/Inputs/RuntimeRetroactiveConformance/A.swift
new file mode 100644
index 0000000..d1e95f5
--- /dev/null
+++ b/test/stdlib/Inputs/RuntimeRetroactiveConformance/A.swift
@@ -0,0 +1 @@
+public struct AType {}
diff --git a/test/stdlib/Inputs/RuntimeRetroactiveConformance/B.swift b/test/stdlib/Inputs/RuntimeRetroactiveConformance/B.swift
new file mode 100644
index 0000000..182996b
--- /dev/null
+++ b/test/stdlib/Inputs/RuntimeRetroactiveConformance/B.swift
@@ -0,0 +1 @@
+public protocol BProto {}
diff --git a/test/stdlib/NewStringAppending.swift b/test/stdlib/NewStringAppending.swift
index 3a2beb1..85929de 100644
--- a/test/stdlib/NewStringAppending.swift
+++ b/test/stdlib/NewStringAppending.swift
@@ -69,27 +69,25 @@
// To make this test independent of the memory allocator implementation,
// explicitly request initial capacity.
-s.reserveCapacity(8)
+s.reserveCapacity(16)
-// CHECK-NEXT: String(Native(owner: @[[storage0:[x0-9a-f]+]], count: 1, capacity: 8)) = "⓪"
+// CHECK-NEXT: String(Native(owner: @[[storage0:[x0-9a-f]+]], count: 1, capacity: 16)) = "⓪"
print("\(repr(s))")
-// CHECK-NEXT: String(Native(owner: @[[storage0]], count: 2, capacity: 8)) = "⓪1"
+// CHECK-NEXT: String(Native(owner: @[[storage0]], count: 2, capacity: 16)) = "⓪1"
s += "1"
print("\(repr(s))")
-// CHECK-NEXT: String(Native(owner: @[[storage0]], count: 8, capacity: 8)) = "⓪1234567"
+// CHECK-NEXT: String(Native(owner: @[[storage0]], count: 8, capacity: 16)) = "⓪1234567"
s += "234567"
print("\(repr(s))")
-// -- expect a reallocation here
-
-// CHECK-NEXT: String(Native(owner: @[[storage1:[x0-9a-f]+]], count: 9, capacity: 16)) = "⓪12345678"
+// CHECK-NEXT: String(Native(owner: @[[storage0:[x0-9a-f]+]], count: 9, capacity: 16)) = "⓪12345678"
// CHECK-NOT: @[[storage0]],
s += "8"
print("\(repr(s))")
-// CHECK-NEXT: String(Native(owner: @[[storage1]], count: 16, capacity: 16)) = "⓪123456789012345"
+// CHECK-NEXT: String(Native(owner: @[[storage0]], count: 16, capacity: 16)) = "⓪123456789012345"
s += "9012345"
print("\(repr(s))")
diff --git a/test/stdlib/RuntimeRetroactiveConformance.swift b/test/stdlib/RuntimeRetroactiveConformance.swift
new file mode 100644
index 0000000..aa91c9f
--- /dev/null
+++ b/test/stdlib/RuntimeRetroactiveConformance.swift
@@ -0,0 +1,24 @@
+// RUN: %empty-directory(%t)
+// RUN: %target-build-swift -c -force-single-frontend-invocation -parse-as-library -emit-module -emit-module-path %t/A.swiftmodule -o %t/A.o -module-name A %S/Inputs/RuntimeRetroactiveConformance/A.swift
+// RUN: %target-build-swift -c -force-single-frontend-invocation -parse-as-library -emit-module -emit-module-path %t/B.swiftmodule -o %t/B.o -module-name B %S/Inputs/RuntimeRetroactiveConformance/B.swift
+// RUN: %target-build-swift %s %t/A.o %t/B.o -I %t -o %t/a.out
+// RUN: %target-run %t/a.out
+
+// REQUIRES: executable_test
+
+import A
+import B
+
+extension AType: BProto {}
+
+struct Foo<T: BProto> {}
+
+struct Bar {
+ var foo: Foo<AType> = Foo()
+}
+
+let mirror = Mirror(reflecting: Bar())
+
+_ = mirror.children.first!
+
+print("I survived") // CHECK: I survived
diff --git a/utils/WindowsSDKVFSOverlay.yaml.in b/utils/WindowsSDKVFSOverlay.yaml.in
index 4004cd7..d44c2f9 100644
--- a/utils/WindowsSDKVFSOverlay.yaml.in
+++ b/utils/WindowsSDKVFSOverlay.yaml.in
@@ -5,6 +5,9 @@
- name: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/shared"
type: directory
contents:
+ - name: Bcrypt.h
+ type: file
+ external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/shared/bcrypt.h"
- name: DriverSpecs.h
type: file
external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/shared/driverspecs.h"
diff --git a/utils/gyb_syntax_support/Node.py b/utils/gyb_syntax_support/Node.py
index 07307f7..7ce55b3 100644
--- a/utils/gyb_syntax_support/Node.py
+++ b/utils/gyb_syntax_support/Node.py
@@ -27,7 +27,10 @@
self.traits = traits or []
self.children = children or []
self.base_kind = kind
- self.base_type = kind_to_type(self.base_kind)
+ if self.base_kind == 'SyntaxCollection':
+ self.base_type = 'Syntax'
+ else:
+ self.base_type = kind_to_type(self.base_kind)
if self.base_kind not in SYNTAX_BASE_KINDS:
error("unknown base kind '%s' for node '%s'" %
diff --git a/utils/gyb_syntax_support/__init__.py b/utils/gyb_syntax_support/__init__.py
index b8f582b..9aba6ef 100644
--- a/utils/gyb_syntax_support/__init__.py
+++ b/utils/gyb_syntax_support/__init__.py
@@ -92,7 +92,7 @@
def is_visitable(node):
- return not node.is_base() and not node.collection_element
+ return not node.is_base()
def dedented_lines(description):
diff --git a/utils/update-checkout-config.json b/utils/update-checkout-config.json
index 56d52ba..2a7a033 100644
--- a/utils/update-checkout-config.json
+++ b/utils/update-checkout-config.json
@@ -195,9 +195,9 @@
"clang": "swift-4.2-branch",
"swift": "swift-4.2-branch",
"lldb": "swift-4.2-branch",
- "cmark": "master",
- "llbuild": "master",
- "swiftpm": "master",
+ "cmark": "swift-4.2-branch",
+ "llbuild": "swift-4.2-branch",
+ "swiftpm": "swift-4.2-branch",
"compiler-rt": "swift-4.2-branch",
"swift-corelibs-xctest": "swift-4.2-branch",
"swift-corelibs-foundation": "swift-4.2-branch",
@@ -248,19 +248,19 @@
"swift-4.2-branch-04-30-2018" : {
"aliases": ["swift-4.2-branch-04-30-2018"],
"repos": {
- "llvm": "swift-4.2-branch-04-30-2018",
- "clang": "swift-4.2-branch-04-30-2018",
+ "llvm": "swift-4.2-branch",
+ "clang": "swift-4.2-branch",
"swift": "swift-4.2-branch-04-30-2018",
- "lldb": "swift-4.2-branch-04-30-2018",
- "cmark": "master",
- "llbuild": "master",
- "swiftpm": "master",
- "compiler-rt": "swift-4.2-branch-04-30-2018",
- "swift-corelibs-xctest": "swift-4.2-branch-04-30-2018",
- "swift-corelibs-foundation": "swift-4.2-branch-04-30-2018",
- "swift-corelibs-libdispatch": "swift-4.2-branch-04-30-2018",
- "swift-integration-tests": "swift-4.2-branch-04-30-2018",
- "swift-xcode-playground-support": "swift-4.2-branch-04-30-2018",
+ "lldb": "swift-4.2-branch",
+ "cmark": "swift-4.2-branch",
+ "llbuild": "swift-4.2-branch",
+ "swiftpm": "swift-4.2-branch",
+ "compiler-rt": "swift-4.2-branch",
+ "swift-corelibs-xctest": "swift-4.2-branch",
+ "swift-corelibs-foundation": "swift-4.2-branch",
+ "swift-corelibs-libdispatch": "swift-4.2-branch",
+ "swift-integration-tests": "swift-4.2-branch",
+ "swift-xcode-playground-support": "swift-4.2-branch",
"ninja": "release"
}
},
diff --git a/validation-test/stdlib/String.swift b/validation-test/stdlib/String.swift
index 0b62a95..fd0a840 100644
--- a/validation-test/stdlib/String.swift
+++ b/validation-test/stdlib/String.swift
@@ -948,7 +948,7 @@
base._guts._objectIdentifier != nil &&
isUnique
- base.reserveCapacity(0)
+ base.reserveCapacity(16)
// Now it's unique
// If it was already native and unique, no reallocation
@@ -1065,11 +1065,11 @@
expectNotEqual(id0, s.bufferID)
s = ""
print("empty capacity \(s.capacity)")
- s.reserveCapacity(oldCap + 2)
- print("reserving \(oldCap + 2) -> \(s.capacity), width = \(s._guts.byteWidth)")
+ s.reserveCapacity(oldCap + 18)
+ print("reserving \(oldCap + 18) -> \(s.capacity), width = \(s._guts.byteWidth)")
let id1 = s.bufferID
- s.insert(contentsOf: repeatElement(x, count: oldCap + 2), at: s.endIndex)
- print("extending by \(oldCap + 2) -> \(s.capacity), width = \(s._guts.byteWidth)")
+ s.insert(contentsOf: repeatElement(x, count: oldCap + 18), at: s.endIndex)
+ print("extending by \(oldCap + 18) -> \(s.capacity), width = \(s._guts.byteWidth)")
expectEqual(id1, s.bufferID)
s.insert(contentsOf: repeatElement(x, count: s.capacity + 100), at: s.endIndex)
expectNotEqual(id1, s.bufferID)