Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions lib/Sema/CSDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3685,12 +3685,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
}

// Determine the contextual type of the expression
Type contextualType;
for (auto iterateCS = &cs; contextualType.isNull() && iterateCS;
iterateCS = iterateCS->baseCS) {
contextualType = iterateCS->getContextualType(getRawAnchor());
}

Type contextualType = cs.getContextualType(getRawAnchor());
// Try to provide a fix-it that only contains a '.'
if (contextualType && baseTy->isEqual(contextualType)) {
Diag->fixItInsert(loc, ".");
Expand All @@ -3700,11 +3695,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
// Check if the expression is the matching operator ~=, most often used in
// case statements. If so, try to provide a single dot fix-it
const Expr *contextualTypeNode = getRootExpr(getAnchor());
ConstraintSystem *lastCS = nullptr;
for (auto iterateCS = &cs; iterateCS; iterateCS = iterateCS->baseCS) {
lastCS = iterateCS;
}


// The '~=' operator is an overloaded decl ref inside a binaryExpr
if (auto binaryExpr = dyn_cast<BinaryExpr>(contextualTypeNode)) {
if (auto overloadedFn
Expand All @@ -3719,7 +3710,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
// If the rhs of '~=' is the enum type, a single dot suffixes
// since the type can be inferred
Type secondArgType =
lastCS->getType(binaryExpr->getArg()->getElement(1));
cs.getType(binaryExpr->getArg()->getElement(1));
if (secondArgType->isEqual(baseTy)) {
Diag->fixItInsert(loc, ".");
return true;
Expand Down
1 change: 0 additions & 1 deletion lib/Sema/CSSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@ bool ConstraintSystem::Candidate::solve(

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

// Set up expression type checker timer for the candidate.
cs.Timer.emplace(E, cs);
Expand Down
15 changes: 0 additions & 15 deletions lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ ExpressionTimer::ExpressionTimer(Expr *E, ConstraintSystem &CS)
StartTime(llvm::TimeRecord::getCurrentTime()),
PrintDebugTiming(CS.getASTContext().TypeCheckerOpts.DebugTimeExpressions),
PrintWarning(true) {
if (auto *baseCS = CS.baseCS) {
// If we already have a timer in the base constraint
// system, let's seed its start time to the child.
if (baseCS->Timer) {
StartTime = baseCS->Timer->startedAt();
PrintWarning = false;
PrintDebugTiming = false;
}
}
}

ExpressionTimer::~ExpressionTimer() {
Expand Down Expand Up @@ -598,12 +589,6 @@ static void extendDepthMap(

Optional<std::pair<unsigned, Expr *>> ConstraintSystem::getExprDepthAndParent(
Expr *expr) {
// Check whether the parent has this information.
if (baseCS && baseCS != this) {
if (auto known = baseCS->getExprDepthAndParent(expr))
return *known;
}

// Bring the set of expression weights up to date.
while (NumInputExprsInWeights < InputExprs.size()) {
extendDepthMap(InputExprs[NumInputExprsInWeights], ExprWeights);
Expand Down
8 changes: 1 addition & 7 deletions lib/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -1516,9 +1516,6 @@ class ConstraintSystem {
/// Note: this is only used to support ObjCSelectorExpr at the moment.
llvm::SmallPtrSet<Expr *, 2> UnevaluatedRootExprs;

/// The original CS if this CS was created as a simplification of another CS
ConstraintSystem *baseCS = nullptr;

/// The total number of disjunctions created.
unsigned CountDisjunctions = 0;

Expand Down Expand Up @@ -1696,17 +1693,14 @@ class ConstraintSystem {
DeclContext *DC;
llvm::BumpPtrAllocator &Allocator;

ConstraintSystem &BaseCS;

// Contextual Information.
Type CT;
ContextualTypePurpose CTP;

public:
Candidate(ConstraintSystem &cs, Expr *expr, Type ct = Type(),
ContextualTypePurpose ctp = ContextualTypePurpose::CTP_Unused)
: E(expr), DC(cs.DC), Allocator(cs.Allocator), BaseCS(cs),
CT(ct), CTP(ctp) {}
: E(expr), DC(cs.DC), Allocator(cs.Allocator), CT(ct), CTP(ctp) {}

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