Skip to content

Commit de36c3f

Browse files
committed
[NFC] Sema: Remove some redundant getASTContext calls in the isolation checker
1 parent 90340a0 commit de36c3f

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,7 +2677,6 @@ namespace {
26772677
});
26782678

26792679
if (!nonSendableTypes.empty()) {
2680-
auto &ctx = dc->getASTContext();
26812680
{
26822681
auto diag = ctx.Diags.diagnose(
26832682
funcConv->getLoc(),
@@ -2710,8 +2709,7 @@ namespace {
27102709
if (!safeToDropGlobalActor(dc, fromActor, toType,
27112710
getImmediateApply())) {
27122711
// otherwise, it's not a safe cast.
2713-
dc->getASTContext()
2714-
.Diags
2712+
ctx.Diags
27152713
.diagnose(funcConv->getLoc(),
27162714
diag::converting_func_loses_global_actor, fromType,
27172715
toType, fromActor)
@@ -2879,10 +2877,9 @@ namespace {
28792877
isolation->second == ActorIsolation::Nonisolated) {
28802878
requiredIsolation[dc] = refinedIsolation;
28812879
} else if (isolation->second != refinedIsolation) {
2882-
dc->getASTContext().Diags.diagnose(
2883-
requiredIsolationLoc,
2884-
diag::conflicting_default_argument_isolation,
2885-
isolation->second, refinedIsolation);
2880+
ctx.Diags.diagnose(requiredIsolationLoc,
2881+
diag::conflicting_default_argument_isolation,
2882+
isolation->second, refinedIsolation);
28862883
requiredIsolation.clear();
28872884
return true;
28882885
}
@@ -2930,7 +2927,6 @@ namespace {
29302927
/// Check closure captures for Sendable violations.
29312928
void checkLocalCaptures(AnyFunctionRef localFunc) {
29322929
auto *dc = getDeclContext();
2933-
ASTContext &ctx = dc->getASTContext();
29342930

29352931
auto *closure = localFunc.getAbstractClosureExpr();
29362932
auto *explicitClosure = dyn_cast_or_null<ClosureExpr>(closure);
@@ -3081,8 +3077,6 @@ namespace {
30813077
}
30823078

30833079
ActorIsolation computeRequiredIsolation(Expr *expr) {
3084-
auto &ctx = getDeclContext()->getASTContext();
3085-
30863080
if (ctx.LangOpts.hasFeature(Feature::IsolatedDefaultValues))
30873081
requiredIsolationLoc = expr->getLoc();
30883082

@@ -3581,7 +3575,6 @@ namespace {
35813575
///
35823576
/// \returns true if we diagnosed the entity, \c false otherwise.
35833577
bool diagnoseReferenceToUnsafeGlobal(ValueDecl *value, SourceLoc loc) {
3584-
auto &ctx = value->getASTContext();
35853578
switch (ctx.LangOpts.StrictConcurrencyLevel) {
35863579
case StrictConcurrency::Minimal:
35873580
case StrictConcurrency::Targeted:
@@ -4124,10 +4117,9 @@ namespace {
41244117

41254118
/// Check whether there are _unsafeInheritExecutor_ workarounds in the
41264119
/// given _Concurrency module.
4127-
static bool hasUnsafeInheritExecutorWorkarounds(
4128-
DeclContext *dc, SourceLoc loc
4129-
) {
4130-
ASTContext &ctx = dc->getASTContext();
4120+
static bool hasUnsafeInheritExecutorWorkarounds(ASTContext &ctx,
4121+
DeclContext *dc,
4122+
SourceLoc loc) {
41314123
Identifier name =
41324124
ctx.getIdentifier("_unsafeInheritExecutor_withUnsafeContinuation");
41334125
NameLookupOptions lookupOptions = defaultUnqualifiedLookupOptions;
@@ -4158,7 +4150,7 @@ namespace {
41584150
diag.limitBehaviorIf(inConcurrencyModule, DiagnosticBehavior::Warning);
41594151

41604152
if (!inConcurrencyModule &&
4161-
!hasUnsafeInheritExecutorWorkarounds(func, func->getLoc())) {
4153+
!hasUnsafeInheritExecutorWorkarounds(ctx, func, func->getLoc())) {
41624154
diag.limitBehavior(DiagnosticBehavior::Warning);
41634155
}
41644156

@@ -4777,7 +4769,6 @@ bool ActorIsolationChecker::mayExecuteConcurrentlyWith(
47774769
if (useIsolation == defIsolation)
47784770
return false;
47794771

4780-
auto &ctx = useContext->getASTContext();
47814772
bool regionIsolationEnabled =
47824773
ctx.LangOpts.hasFeature(Feature::RegionBasedIsolation);
47834774

0 commit comments

Comments
 (0)