Merge pull request #16741 from davezarzycki/nfc_create_abstract_LookupExpr
[AST] NFC: Create abstract class for MemberRefExpr/SubscriptExpr
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/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/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/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/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/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 c019106..75d7819 100644
--- a/lib/SIL/SILFunctionType.cpp
+++ b/lib/SIL/SILFunctionType.cpp
@@ -2460,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));
@@ -2471,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/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 accfac4..039fd16 100644
--- a/lib/SILGen/SILGenApply.cpp
+++ b/lib/SILGen/SILGenApply.cpp
@@ -4523,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 2d8c6fe..b40c3f2 100644
--- a/lib/SILGen/SILGenExpr.cpp
+++ b/lib/SILGen/SILGenExpr.cpp
@@ -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;
});
}
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 deda8d5..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);
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 913a434..9ea1d18 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));
@@ -1830,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;
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..3977d6c 100644
--- a/lib/Sema/TypeCheckDecl.cpp
+++ b/lib/Sema/TypeCheckDecl.cpp
@@ -8297,8 +8297,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/TypeCheckType.cpp b/lib/Sema/TypeCheckType.cpp
index ef28745..3047a30 100644
--- a/lib/Sema/TypeCheckType.cpp
+++ b/lib/Sema/TypeCheckType.cpp
@@ -2310,14 +2310,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..281b32d 100644
--- a/lib/Sema/TypeChecker.h
+++ b/lib/Sema/TypeChecker.h
@@ -2084,7 +2084,7 @@
Optional<ProtocolConformanceRef>
operator()(CanType dependentType,
Type conformingReplacementType,
- ProtocolType *conformedProtocol) const;
+ ProtocolDecl *conformedProtocol) const;
};
/// Completely check the given conformance.
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/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/runtime/ErrorObject.mm b/stdlib/public/runtime/ErrorObject.mm
index c5026c9..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;
@@ -521,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/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/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/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)