Skip to content

Commit c4e466d

Browse files
committed
Sema: Remove needless indirection
1 parent 19350d9 commit c4e466d

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,7 +2339,7 @@ class ConstraintSystem {
23392339
ConstraintList InactiveConstraints;
23402340

23412341
/// The constraint graph.
2342-
ConstraintGraph &CG;
2342+
ConstraintGraph CG;
23432343

23442344
/// A mapping from constraint locators to the set of opened types associated
23452345
/// with that locator.
@@ -2707,7 +2707,7 @@ class ConstraintSystem {
27072707
~ConstraintSystem();
27082708

27092709
/// Retrieve the constraint graph associated with this constraint system.
2710-
ConstraintGraph &getConstraintGraph() const { return CG; }
2710+
ConstraintGraph &getConstraintGraph() { return CG; }
27112711

27122712
/// Retrieve the AST context.
27132713
ASTContext &getASTContext() const { return Context; }

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ ConstraintSystem::ConstraintSystem(DeclContext *dc,
117117
: Context(dc->getASTContext()), DC(dc), Options(options),
118118
diagnosticTransaction(diagnosticTransaction),
119119
Arena(dc->getASTContext(), Allocator),
120-
CG(*new ConstraintGraph(*this))
120+
CG(*this)
121121
{
122122
assert(DC && "context required");
123123
// Respect the global debugging flag, but turn off debugging while
@@ -130,9 +130,7 @@ ConstraintSystem::ConstraintSystem(DeclContext *dc,
130130
Options |= ConstraintSystemFlags::UseClangFunctionTypes;
131131
}
132132

133-
ConstraintSystem::~ConstraintSystem() {
134-
delete &CG;
135-
}
133+
ConstraintSystem::~ConstraintSystem() {}
136134

137135
void ConstraintSystem::startExpressionTimer(ExpressionTimer::AnchorType anchor) {
138136
ASSERT(!Timer);
@@ -1102,7 +1100,7 @@ TypeVariableType *ConstraintSystem::isRepresentativeFor(
11021100
if (getRepresentative(typeVar) != typeVar)
11031101
return nullptr;
11041102

1105-
auto &CG = getConstraintGraph();
1103+
auto &CG = const_cast<ConstraintSystem *>(this)->getConstraintGraph();
11061104
auto &result = CG[typeVar];
11071105
auto equivalence = result.getEquivalenceClass();
11081106
auto member = llvm::find_if(equivalence, [=](TypeVariableType *eq) {

0 commit comments

Comments
 (0)