Skip to content

Commit c825ed8

Browse files
authored
Merge pull request swiftlang#30262 from xedin/remove-basecs
ConstraintSystem] Remove `baseCS` since CSDiag has been removed
2 parents 9cabe07 + e4d3eaa commit c825ed8

File tree

4 files changed

+4
-35
lines changed

4 files changed

+4
-35
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3685,12 +3685,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
36853685
}
36863686

36873687
// Determine the contextual type of the expression
3688-
Type contextualType;
3689-
for (auto iterateCS = &cs; contextualType.isNull() && iterateCS;
3690-
iterateCS = iterateCS->baseCS) {
3691-
contextualType = iterateCS->getContextualType(getRawAnchor());
3692-
}
3693-
3688+
Type contextualType = cs.getContextualType(getRawAnchor());
36943689
// Try to provide a fix-it that only contains a '.'
36953690
if (contextualType && baseTy->isEqual(contextualType)) {
36963691
Diag->fixItInsert(loc, ".");
@@ -3700,11 +3695,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
37003695
// Check if the expression is the matching operator ~=, most often used in
37013696
// case statements. If so, try to provide a single dot fix-it
37023697
const Expr *contextualTypeNode = getRootExpr(getAnchor());
3703-
ConstraintSystem *lastCS = nullptr;
3704-
for (auto iterateCS = &cs; iterateCS; iterateCS = iterateCS->baseCS) {
3705-
lastCS = iterateCS;
3706-
}
3707-
3698+
37083699
// The '~=' operator is an overloaded decl ref inside a binaryExpr
37093700
if (auto binaryExpr = dyn_cast<BinaryExpr>(contextualTypeNode)) {
37103701
if (auto overloadedFn
@@ -3719,7 +3710,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
37193710
// If the rhs of '~=' is the enum type, a single dot suffixes
37203711
// since the type can be inferred
37213712
Type secondArgType =
3722-
lastCS->getType(binaryExpr->getArg()->getElement(1));
3713+
cs.getType(binaryExpr->getArg()->getElement(1));
37233714
if (secondArgType->isEqual(baseTy)) {
37243715
Diag->fixItInsert(loc, ".");
37253716
return true;

lib/Sema/CSSolver.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ bool ConstraintSystem::Candidate::solve(
619619

620620
// Allocate new constraint system for sub-expression.
621621
ConstraintSystem cs(DC, None);
622-
cs.baseCS = &BaseCS;
623622

624623
// Set up expression type checker timer for the candidate.
625624
cs.Timer.emplace(E, cs);

lib/Sema/ConstraintSystem.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,6 @@ ExpressionTimer::ExpressionTimer(Expr *E, ConstraintSystem &CS)
4141
StartTime(llvm::TimeRecord::getCurrentTime()),
4242
PrintDebugTiming(CS.getASTContext().TypeCheckerOpts.DebugTimeExpressions),
4343
PrintWarning(true) {
44-
if (auto *baseCS = CS.baseCS) {
45-
// If we already have a timer in the base constraint
46-
// system, let's seed its start time to the child.
47-
if (baseCS->Timer) {
48-
StartTime = baseCS->Timer->startedAt();
49-
PrintWarning = false;
50-
PrintDebugTiming = false;
51-
}
52-
}
5344
}
5445

5546
ExpressionTimer::~ExpressionTimer() {
@@ -598,12 +589,6 @@ static void extendDepthMap(
598589

599590
Optional<std::pair<unsigned, Expr *>> ConstraintSystem::getExprDepthAndParent(
600591
Expr *expr) {
601-
// Check whether the parent has this information.
602-
if (baseCS && baseCS != this) {
603-
if (auto known = baseCS->getExprDepthAndParent(expr))
604-
return *known;
605-
}
606-
607592
// Bring the set of expression weights up to date.
608593
while (NumInputExprsInWeights < InputExprs.size()) {
609594
extendDepthMap(InputExprs[NumInputExprsInWeights], ExprWeights);

lib/Sema/ConstraintSystem.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,9 +1516,6 @@ class ConstraintSystem {
15161516
/// Note: this is only used to support ObjCSelectorExpr at the moment.
15171517
llvm::SmallPtrSet<Expr *, 2> UnevaluatedRootExprs;
15181518

1519-
/// The original CS if this CS was created as a simplification of another CS
1520-
ConstraintSystem *baseCS = nullptr;
1521-
15221519
/// The total number of disjunctions created.
15231520
unsigned CountDisjunctions = 0;
15241521

@@ -1696,17 +1693,14 @@ class ConstraintSystem {
16961693
DeclContext *DC;
16971694
llvm::BumpPtrAllocator &Allocator;
16981695

1699-
ConstraintSystem &BaseCS;
1700-
17011696
// Contextual Information.
17021697
Type CT;
17031698
ContextualTypePurpose CTP;
17041699

17051700
public:
17061701
Candidate(ConstraintSystem &cs, Expr *expr, Type ct = Type(),
17071702
ContextualTypePurpose ctp = ContextualTypePurpose::CTP_Unused)
1708-
: E(expr), DC(cs.DC), Allocator(cs.Allocator), BaseCS(cs),
1709-
CT(ct), CTP(ctp) {}
1703+
: E(expr), DC(cs.DC), Allocator(cs.Allocator), CT(ct), CTP(ctp) {}
17101704

17111705
/// Return underlying expression.
17121706
Expr *getExpr() const { return E; }

0 commit comments

Comments
 (0)