Skip to content

Commit 5200478

Browse files
committed
Sema: Remove needless indirection
1 parent 475ead5 commit 5200478

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
@@ -2335,7 +2335,7 @@ class ConstraintSystem {
23352335
ConstraintList InactiveConstraints;
23362336

23372337
/// The constraint graph.
2338-
ConstraintGraph &CG;
2338+
ConstraintGraph CG;
23392339

23402340
/// A mapping from constraint locators to the set of opened types associated
23412341
/// with that locator.
@@ -2772,7 +2772,7 @@ class ConstraintSystem {
27722772
~ConstraintSystem();
27732773

27742774
/// Retrieve the constraint graph associated with this constraint system.
2775-
ConstraintGraph &getConstraintGraph() const { return CG; }
2775+
ConstraintGraph &getConstraintGraph() { return CG; }
27762776

27772777
/// Retrieve the AST context.
27782778
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)