Skip to content

Commit 5ff0bab

Browse files
authored
Merge pull request #19422 from xedin/create-scope-while-taking
[CSStep] Allocate component scopes only if siblings didn't fail
2 parents 1cf16ab + 091a757 commit 5ff0bab

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

lib/Sema/CSStep.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ StepResult ComponentStep::take(bool prevFailed) {
253253
if (prevFailed || CS.getExpressionTooComplex(Solutions))
254254
return done(/*isSuccess=*/false);
255255

256+
// Setup active scope, only if previous component didn't fail.
257+
setupScope();
258+
256259
/// Try to figure out what this step is going to be,
257260
/// after the scope has been established.
258261
auto *disjunction = CS.selectDisjunction();

lib/Sema/CSStep.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,18 @@ class ComponentStep final : public SolverStep {
373373
OrphanedConstraint = constraint;
374374
}
375375

376-
void setup() override {
376+
StepResult take(bool prevFailed) override;
377+
StepResult resume(bool prevFailed) override;
378+
379+
// The number of disjunction constraints associated with this component.
380+
unsigned disjunctionCount() const { return NumDisjunctions; }
381+
382+
void print(llvm::raw_ostream &Out) override {
383+
Out << "ComponentStep with at #" << Index << '\n';
384+
}
385+
386+
private:
387+
void setupScope() {
377388
// If this is a single component, there is no need
378389
// to preliminary modify constraint system or log anything.
379390
if (IsSingle)
@@ -387,16 +398,6 @@ class ComponentStep final : public SolverStep {
387398
// let's return it ot the graph.
388399
CS.CG.setOrphanedConstraint(OrphanedConstraint);
389400
}
390-
391-
StepResult take(bool prevFailed) override;
392-
StepResult resume(bool prevFailed) override;
393-
394-
// The number of disjunction constraints associated with this component.
395-
unsigned disjunctionCount() const { return NumDisjunctions; }
396-
397-
void print(llvm::raw_ostream &Out) override {
398-
Out << "ComponentStep with at #" << Index << '\n';
399-
}
400401
};
401402

402403
template <typename P> class BindingStep : public SolverStep {

0 commit comments

Comments
 (0)