Skip to content

Commit fb55c03

Browse files
committed
diagnoseUnownedImmediateDeallocation doesn't need a TypeChecker
1 parent b57c86d commit fb55c03

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3722,7 +3722,7 @@ namespace {
37223722
// If we're performing an assignment to a weak or unowned variable from
37233723
// a constructor call, emit a warning that the instance will be
37243724
// immediately deallocated.
3725-
diagnoseUnownedImmediateDeallocation(cs.getTypeChecker(), expr);
3725+
diagnoseUnownedImmediateDeallocation(cs.getASTContext(), expr);
37263726
}
37273727
return expr;
37283728
}

lib/Sema/MiscDiagnostics.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,7 +1690,7 @@ static const Expr *lookThroughExprsToImmediateDeallocation(const Expr *E) {
16901690
}
16911691
}
16921692

1693-
static void diagnoseUnownedImmediateDeallocationImpl(TypeChecker &TC,
1693+
static void diagnoseUnownedImmediateDeallocationImpl(ASTContext &ctx,
16941694
const VarDecl *varDecl,
16951695
const Expr *initExpr,
16961696
SourceLoc diagLoc,
@@ -1741,17 +1741,18 @@ static void diagnoseUnownedImmediateDeallocationImpl(TypeChecker &TC,
17411741
if (varDecl->getDeclContext()->isTypeContext())
17421742
storageKind = SK_Property;
17431743

1744-
TC.diagnose(diagLoc, diag::unowned_assignment_immediate_deallocation,
1745-
varDecl->getName(), ownershipAttr->get(), unsigned(storageKind))
1744+
ctx.Diags.diagnose(diagLoc, diag::unowned_assignment_immediate_deallocation,
1745+
varDecl->getName(), ownershipAttr->get(),
1746+
unsigned(storageKind))
17461747
.highlight(diagRange);
17471748

1748-
TC.diagnose(diagLoc, diag::unowned_assignment_requires_strong)
1749+
ctx.Diags.diagnose(diagLoc, diag::unowned_assignment_requires_strong)
17491750
.highlight(diagRange);
17501751

1751-
TC.diagnose(varDecl, diag::decl_declared_here, varDecl->getFullName());
1752+
ctx.Diags.diagnose(varDecl, diag::decl_declared_here, varDecl->getFullName());
17521753
}
17531754

1754-
void swift::diagnoseUnownedImmediateDeallocation(TypeChecker &TC,
1755+
void swift::diagnoseUnownedImmediateDeallocation(ASTContext &ctx,
17551756
const AssignExpr *assignExpr) {
17561757
auto *destExpr = assignExpr->getDest()->getValueProvidingExpr();
17571758
auto *initExpr = assignExpr->getSrc();
@@ -1765,12 +1766,12 @@ void swift::diagnoseUnownedImmediateDeallocation(TypeChecker &TC,
17651766
}
17661767

17671768
if (VD)
1768-
diagnoseUnownedImmediateDeallocationImpl(TC, VD, initExpr,
1769+
diagnoseUnownedImmediateDeallocationImpl(ctx, VD, initExpr,
17691770
assignExpr->getLoc(),
17701771
initExpr->getSourceRange());
17711772
}
17721773

1773-
void swift::diagnoseUnownedImmediateDeallocation(TypeChecker &TC,
1774+
void swift::diagnoseUnownedImmediateDeallocation(ASTContext &ctx,
17741775
const Pattern *pattern,
17751776
SourceLoc equalLoc,
17761777
const Expr *initExpr) {
@@ -1788,12 +1789,12 @@ void swift::diagnoseUnownedImmediateDeallocation(TypeChecker &TC,
17881789
const Pattern *subPattern = elt.getPattern();
17891790
Expr *subInitExpr = TE->getElement(i);
17901791

1791-
diagnoseUnownedImmediateDeallocation(TC, subPattern, equalLoc,
1792+
diagnoseUnownedImmediateDeallocation(ctx, subPattern, equalLoc,
17921793
subInitExpr);
17931794
}
17941795
}
17951796
} else if (auto *NP = dyn_cast<NamedPattern>(pattern)) {
1796-
diagnoseUnownedImmediateDeallocationImpl(TC, NP->getDecl(), initExpr,
1797+
diagnoseUnownedImmediateDeallocationImpl(ctx, NP->getDecl(), initExpr,
17971798
equalLoc,
17981799
initExpr->getSourceRange());
17991800
}

lib/Sema/MiscDiagnostics.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ bool diagnoseArgumentLabelError(ASTContext &ctx,
7575
/// with a non-owning attribute, such as 'weak' or 'unowned' and the initializer
7676
/// expression refers to a class constructor, emit a warning that the assigned
7777
/// instance will be immediately deallocated.
78-
void diagnoseUnownedImmediateDeallocation(TypeChecker &TC,
78+
void diagnoseUnownedImmediateDeallocation(ASTContext &ctx,
7979
const AssignExpr *assignExpr);
8080

8181
/// If \p pattern binds to a declaration with a non-owning attribute, such as
8282
/// 'weak' or 'unowned' and \p initializer refers to a class constructor,
8383
/// emit a warning that the bound instance will be immediately deallocated.
84-
void diagnoseUnownedImmediateDeallocation(TypeChecker &TC,
84+
void diagnoseUnownedImmediateDeallocation(ASTContext &ctx,
8585
const Pattern *pattern,
8686
SourceLoc equalLoc,
8787
const Expr *initializer);

lib/Sema/TypeCheckDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,9 +2600,9 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
26002600
// If we're performing an binding to a weak or unowned variable from a
26012601
// constructor call, emit a warning that the instance will be immediately
26022602
// deallocated.
2603-
diagnoseUnownedImmediateDeallocation(TC, PBD->getPattern(i),
2604-
PBD->getEqualLoc(i),
2605-
init);
2603+
diagnoseUnownedImmediateDeallocation(Ctx, PBD->getPattern(i),
2604+
PBD->getEqualLoc(i),
2605+
init);
26062606

26072607
// If we entered an initializer context, contextualize any
26082608
// auto-closures we might have created.

0 commit comments

Comments
 (0)