Skip to content

Commit d4fbca1

Browse files
committed
[Sema/CS] std::function -> llvm::function_ref for some non-escaping params.
1 parent 0516915 commit d4fbca1

File tree

7 files changed

+20
-21
lines changed

7 files changed

+20
-21
lines changed

lib/Sema/CSApply.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4782,14 +4782,13 @@ namespace {
47824782
///
47834783
/// \returns the decl to which the locator resolved.
47844784
///
4785-
static ConcreteDeclRef
4786-
resolveLocatorToDecl(ConstraintSystem &cs, ConstraintLocator *locator,
4787-
std::function<Optional<SelectedOverload>(ConstraintLocator *)> findOvlChoice,
4788-
std::function<ConcreteDeclRef (ValueDecl *decl,
4789-
Type openedType,
4790-
ConstraintLocator *declLocator)>
4791-
getConcreteDeclRef)
4792-
{
4785+
static ConcreteDeclRef resolveLocatorToDecl(
4786+
ConstraintSystem &cs, ConstraintLocator *locator,
4787+
llvm::function_ref<Optional<SelectedOverload>(ConstraintLocator *)>
4788+
findOvlChoice,
4789+
llvm::function_ref<ConcreteDeclRef(ValueDecl *decl, Type openedType,
4790+
ConstraintLocator *declLocator)>
4791+
getConcreteDeclRef) {
47934792
assert(locator && "Null locator");
47944793
if (!locator->getAnchor())
47954794
return ConcreteDeclRef();

lib/Sema/CSDiag.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,9 @@ class FailureDiagnosis :public ASTVisitor<FailureDiagnosis, /*exprresult*/bool>{
993993

994994
bool diagnoseTrailingClosureErrors(ApplyExpr *expr);
995995

996-
bool diagnoseClosureExpr(ClosureExpr *closureExpr, Type contextualType,
997-
std::function<bool(Type, Type)> resultTypeProcessor);
996+
bool
997+
diagnoseClosureExpr(ClosureExpr *closureExpr, Type contextualType,
998+
llvm::function_ref<bool(Type, Type)> resultTypeProcessor);
998999

9991000
bool diagnoseSubscriptErrors(SubscriptExpr *SE, bool performingSet);
10001001

@@ -6283,7 +6284,7 @@ bool FailureDiagnosis::visitClosureExpr(ClosureExpr *CE) {
62836284

62846285
bool FailureDiagnosis::diagnoseClosureExpr(
62856286
ClosureExpr *CE, Type contextualType,
6286-
std::function<bool(Type, Type)> resultTypeProcessor) {
6287+
llvm::function_ref<bool(Type, Type)> resultTypeProcessor) {
62876288
// Look through IUO because it doesn't influence
62886289
// neither parameter nor return type diagnostics itself,
62896290
// but if we have function type inside, that might

lib/Sema/CSGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ namespace {
562562
/// overloads which inhibit any overload from being favored.
563563
void favorCallOverloads(ApplyExpr *expr,
564564
ConstraintSystem &CS,
565-
std::function<bool(ValueDecl *)> isFavored,
565+
llvm::function_ref<bool(ValueDecl *)> isFavored,
566566
std::function<bool(ValueDecl *)>
567567
mustConsider = nullptr) {
568568
// Find the type variable associated with the function, if any.

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ ConstraintSystem::TypeMatchResult
14751475
ConstraintSystem::matchTypesBindTypeVar(
14761476
TypeVariableType *typeVar, Type type, ConstraintKind kind,
14771477
TypeMatchOptions flags, ConstraintLocatorBuilder locator,
1478-
std::function<TypeMatchResult()> formUnsolvedResult) {
1478+
llvm::function_ref<TypeMatchResult()> formUnsolvedResult) {
14791479
assert(typeVar->is<TypeVariableType>() && "Expected a type variable!");
14801480
// FIXME: Due to some SE-0110 related code farther up we can end
14811481
// up with type variables wrapped in parens that will trip this

lib/Sema/ConstraintGraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ ConstraintGraphNode::getAdjacency(TypeVariableType *typeVar) {
145145

146146
void ConstraintGraphNode::modifyAdjacency(
147147
TypeVariableType *typeVar,
148-
std::function<void(Adjacency& adj)> modify) {
148+
llvm::function_ref<void(Adjacency& adj)> modify) {
149149
// Find the adjacency information.
150150
auto pos = AdjacencyInfo.find(typeVar);
151151
assert(pos != AdjacencyInfo.end() && "Type variables not adjacent");

lib/Sema/ConstraintGraph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class ConstraintGraphNode {
104104
/// directly. If the adjacency becomes empty afterward, it will be
105105
/// removed.
106106
void modifyAdjacency(TypeVariableType *typeVar,
107-
std::function<void(Adjacency& adj)> modify);
107+
llvm::function_ref<void(Adjacency &adj)> modify);
108108

109109
/// Add an adjacency to the list of adjacencies.
110110
void addAdjacency(TypeVariableType *typeVar);

lib/Sema/ConstraintSystem.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ class ConstraintSystem {
11831183
///
11841184
/// \param processor The processor function to be applied to each of
11851185
/// the constraints retrieved.
1186-
void forEachRetired(std::function<void(Constraint &)> processor) {
1186+
void forEachRetired(llvm::function_ref<void(Constraint &)> processor) {
11871187
for (auto &constraint : retiredConstraints)
11881188
processor(constraint);
11891189
}
@@ -2347,11 +2347,10 @@ class ConstraintSystem {
23472347

23482348
/// \brief Subroutine of \c matchTypes(), used to bind a type to a
23492349
/// type variable.
2350-
TypeMatchResult
2351-
matchTypesBindTypeVar(TypeVariableType *typeVar, Type type,
2352-
ConstraintKind kind, TypeMatchOptions flags,
2353-
ConstraintLocatorBuilder locator,
2354-
std::function<TypeMatchResult()> formUnsolvedResult);
2350+
TypeMatchResult matchTypesBindTypeVar(
2351+
TypeVariableType *typeVar, Type type, ConstraintKind kind,
2352+
TypeMatchOptions flags, ConstraintLocatorBuilder locator,
2353+
llvm::function_ref<TypeMatchResult()> formUnsolvedResult);
23552354

23562355
public: // FIXME: public due to statics in CSSimplify.cpp
23572356
/// \brief Attempt to match up types \c type1 and \c type2, which in effect

0 commit comments

Comments
 (0)