Skip to content

Commit 632bf41

Browse files
committed
[CS] Make ArgumentLists a private member
Move associateArgumentList onto ConstraintSystem and make ArgumentLists private in preparation for having it roll back at the end of solver scopes.
1 parent 8e0cddd commit 632bf41

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,6 +2406,11 @@ class ConstraintSystem {
24062406
/// Cache of the effects any closures visited.
24072407
llvm::SmallDenseMap<ClosureExpr *, FunctionType::ExtInfo, 4> closureEffectsCache;
24082408

2409+
/// A mapping from the constraint locators for references to various
2410+
/// names (e.g., member references, normal name references, possible
2411+
/// constructions) to the argument lists for the call to that locator.
2412+
llvm::DenseMap<ConstraintLocator *, ArgumentList *> ArgumentLists;
2413+
24092414
public:
24102415
/// A map from argument expressions to their applied property wrapper expressions.
24112416
llvm::SmallMapVector<ASTNode, SmallVector<AppliedPropertyWrapper, 2>, 4> appliedPropertyWrappers;
@@ -2784,20 +2789,18 @@ class ConstraintSystem {
27842789
/// we're exploring.
27852790
SolverState *solverState = nullptr;
27862791

2787-
/// A mapping from the constraint locators for references to various
2788-
/// names (e.g., member references, normal name references, possible
2789-
/// constructions) to the argument lists for the call to that locator.
2790-
llvm::DenseMap<ConstraintLocator *, ArgumentList *> ArgumentLists;
2791-
27922792
/// Form a locator that can be used to retrieve argument information cached in
27932793
/// the constraint system for the callee described by the anchor of the
27942794
/// passed locator.
27952795
ConstraintLocator *getArgumentInfoLocator(ConstraintLocator *locator);
27962796

2797-
/// Retrieve the argument list that is associated with a member
2798-
/// reference at the given locator.
2797+
/// Retrieve the argument list that is associated with a call at the given
2798+
/// locator.
27992799
ArgumentList *getArgumentList(ConstraintLocator *locator);
28002800

2801+
/// Associate an argument list with a call at a given locator.
2802+
void associateArgumentList(ConstraintLocator *locator, ArgumentList *args);
2803+
28012804
Optional<SelectedOverload>
28022805
findSelectedOverloadFor(ConstraintLocator *locator) const {
28032806
auto result = ResolvedOverloads.find(locator);

lib/Sema/CSGen.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ namespace {
917917
CS.getConstraintLocator(locator,
918918
ConstraintLocator::FunctionResult);
919919

920-
associateArgumentList(memberLocator, argList);
920+
CS.associateArgumentList(memberLocator, argList);
921921

922922
Type outputTy;
923923

@@ -1174,7 +1174,7 @@ namespace {
11741174

11751175
Type visitObjectLiteralExpr(ObjectLiteralExpr *expr) {
11761176
auto *exprLoc = CS.getConstraintLocator(expr);
1177-
associateArgumentList(exprLoc, expr->getArgs());
1177+
CS.associateArgumentList(exprLoc, expr->getArgs());
11781178

11791179
// If the expression has already been assigned a type; just use that type.
11801180
if (expr->getType())
@@ -2671,7 +2671,7 @@ namespace {
26712671
Type visitApplyExpr(ApplyExpr *expr) {
26722672
auto fnExpr = expr->getFn();
26732673

2674-
associateArgumentList(CS.getConstraintLocator(expr), expr->getArgs());
2674+
CS.associateArgumentList(CS.getConstraintLocator(expr), expr->getArgs());
26752675

26762676
if (auto *UDE = dyn_cast<UnresolvedDotExpr>(fnExpr)) {
26772677
auto typeOperation = getTypeOperation(UDE, CS.getASTContext());
@@ -3426,11 +3426,6 @@ namespace {
34263426
}
34273427
llvm_unreachable("unhandled operation");
34283428
}
3429-
3430-
void associateArgumentList(ConstraintLocator *locator, ArgumentList *args) {
3431-
assert(locator && locator->getAnchor());
3432-
CS.ArgumentLists[CS.getArgumentInfoLocator(locator)] = args;
3433-
}
34343429
};
34353430

34363431
class ConstraintWalker : public ASTWalker {

lib/Sema/ConstraintSystem.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4662,6 +4662,15 @@ ArgumentList *ConstraintSystem::getArgumentList(ConstraintLocator *locator) {
46624662
return nullptr;
46634663
}
46644664

4665+
void ConstraintSystem::associateArgumentList(ConstraintLocator *locator,
4666+
ArgumentList *args) {
4667+
assert(locator && locator->getAnchor());
4668+
auto *argInfoLoc = getArgumentInfoLocator(locator);
4669+
auto inserted = ArgumentLists.insert({argInfoLoc, args}).second;
4670+
assert(inserted && "Multiple argument lists at locator?");
4671+
(void)inserted;
4672+
}
4673+
46654674
/// Given an apply expr, returns true if it is expected to have a direct callee
46664675
/// overload, resolvable using `getChoiceFor`. Otherwise, returns false.
46674676
static bool shouldHaveDirectCalleeOverload(const CallExpr *callExpr) {

0 commit comments

Comments
 (0)