Skip to content

[CSStep] Allocate component scopes only if siblings didn't fail #19422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2018
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
3 changes: 3 additions & 0 deletions lib/Sema/CSStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ StepResult ComponentStep::take(bool prevFailed) {
if (prevFailed || CS.getExpressionTooComplex(Solutions))
return done(/*isSuccess=*/false);

// Setup active scope, only if previous component didn't fail.
setupScope();

/// Try to figure out what this step is going to be,
/// after the scope has been established.
auto *disjunction = CS.selectDisjunction();
Expand Down
23 changes: 12 additions & 11 deletions lib/Sema/CSStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,18 @@ class ComponentStep final : public SolverStep {
OrphanedConstraint = constraint;
}

void setup() override {
StepResult take(bool prevFailed) override;
StepResult resume(bool prevFailed) override;

// The number of disjunction constraints associated with this component.
unsigned disjunctionCount() const { return NumDisjunctions; }

void print(llvm::raw_ostream &Out) override {
Out << "ComponentStep with at #" << Index << '\n';
}

private:
void setupScope() {
// If this is a single component, there is no need
// to preliminary modify constraint system or log anything.
if (IsSingle)
Expand All @@ -387,16 +398,6 @@ class ComponentStep final : public SolverStep {
// let's return it ot the graph.
CS.CG.setOrphanedConstraint(OrphanedConstraint);
}

StepResult take(bool prevFailed) override;
StepResult resume(bool prevFailed) override;

// The number of disjunction constraints associated with this component.
unsigned disjunctionCount() const { return NumDisjunctions; }

void print(llvm::raw_ostream &Out) override {
Out << "ComponentStep with at #" << Index << '\n';
}
};

template <typename P> class BindingStep : public SolverStep {
Expand Down