Skip to content

Commit ec64f2a

Browse files
committed
SILLocation: replace CleanupLocation::get(loc) with CleanupLocation(loc)
No need to have a static get function - the constructor can be used directly. NFC
1 parent 462e58d commit ec64f2a

25 files changed

+66
-70
lines changed

include/swift/SIL/SILLocation.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,6 @@ class CleanupLocation : public SILLocation {
570570
/// Returns a null location.
571571
static CleanupLocation invalid() { return CleanupLocation(); }
572572

573-
static CleanupLocation get(SILLocation L) {
574-
return CleanupLocation(L);
575-
}
576-
577573
/// Returns a location representing a cleanup on the module level.
578574
/// This is just a null location.
579575
static CleanupLocation getModuleCleanupLocation() {

lib/SILGen/ArgumentScope.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ArgumentScope {
3333

3434
public:
3535
ArgumentScope(SILGenFunction &SGF, SILLocation loc)
36-
: normalScope(SGF.Cleanups, CleanupLocation::get(loc)),
36+
: normalScope(SGF.Cleanups, CleanupLocation(loc)),
3737
formalEvalScope(SGF), loc(loc) {}
3838

3939
~ArgumentScope() {

lib/SILGen/Condition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ SGFContext ConditionalValue::enterBranch(SILBasicBlock *bb) {
7777

7878
assert(!scope.hasValue() && "already have a scope");
7979
// Start a scope for the current branch.
80-
scope.emplace(SGF.Cleanups, CleanupLocation::get(loc));
80+
scope.emplace(SGF.Cleanups, CleanupLocation(loc));
8181

8282
// Code emitted in the branch can emit into our buffer for address-only
8383
// conditionals.

lib/SILGen/FormalEvaluation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ void FormalAccess::verify(SILGenFunction &SGF) const {
4848
//===----------------------------------------------------------------------===//
4949

5050
void SharedBorrowFormalAccess::finishImpl(SILGenFunction &SGF) {
51-
SGF.B.createEndBorrow(CleanupLocation::get(loc), borrowedValue);
51+
SGF.B.createEndBorrow(CleanupLocation(loc), borrowedValue);
5252
}
5353

5454
//===----------------------------------------------------------------------===//
5555
// OwnedFormalAccess
5656
//===----------------------------------------------------------------------===//
5757

5858
void OwnedFormalAccess::finishImpl(SILGenFunction &SGF) {
59-
auto cleanupLoc = CleanupLocation::get(loc);
59+
auto cleanupLoc = CleanupLocation(loc);
6060
if (value->getType().isAddress())
6161
SGF.B.createDestroyAddr(cleanupLoc, value);
6262
else

lib/SILGen/JumpDest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class LLVM_LIBRARY_VISIBILITY JumpDest {
5454
Block = nullptr;
5555
Depth = CleanupsDepth::invalid();
5656
// Null location.
57-
CleanupLoc = CleanupLocation::get(ArtificialUnreachableLocation());
57+
CleanupLoc = CleanupLocation(ArtificialUnreachableLocation());
5858
return NewValue;
5959
}
6060

lib/SILGen/LValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ struct LLVM_LIBRARY_VISIBILITY ExclusiveBorrowFormalAccess : FormalAccess {
547547
SILGenFunction &SGF) const;
548548

549549
void performWriteback(SILGenFunction &SGF, bool isFinal) {
550-
Scope S(SGF.Cleanups, CleanupLocation::get(loc));
550+
Scope S(SGF.Cleanups, CleanupLocation(loc));
551551
component->writeback(SGF, loc, base, materialized, isFinal);
552552
}
553553

lib/SILGen/SILGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,7 @@ class SourceFileScope {
19191919
SGF.B.createEndLifetime(moduleLoc, error);
19201920

19211921
// Signal an abnormal exit by returning 1.
1922-
SGF.Cleanups.emitCleanupsForReturn(CleanupLocation::get(moduleLoc),
1922+
SGF.Cleanups.emitCleanupsForReturn(CleanupLocation(moduleLoc),
19231923
IsForUnwind);
19241924
SGF.B.createBranch(returnLoc, returnBB, emitTopLevelReturnValue(1));
19251925
}

lib/SILGen/SILGenApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4569,7 +4569,7 @@ SILValue SILGenFunction::emitApplyWithRethrow(SILLocation loc, SILValue fn,
45694569
fnConv.getSILErrorType(getTypeExpansionContext()),
45704570
OwnershipKind::Owned);
45714571

4572-
Cleanups.emitCleanupsForReturn(CleanupLocation::get(loc), IsForUnwind);
4572+
Cleanups.emitCleanupsForReturn(CleanupLocation(loc), IsForUnwind);
45734573
B.createThrow(loc, error);
45744574
}
45754575

lib/SILGen/SILGenBridging.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static void buildFuncToBlockInvokeBody(SILGenFunction &SGF,
370370
CanSILFunctionType blockTy,
371371
CanSILBlockStorageType blockStorageTy,
372372
bool isUnretainedClosureSafe) {
373-
Scope scope(SGF.Cleanups, CleanupLocation::get(loc));
373+
Scope scope(SGF.Cleanups, CleanupLocation(loc));
374374
SILBasicBlock *entry = &*SGF.F.begin();
375375
SILFunctionConventions blockConv(blockTy, SGF.SGM.M);
376376
SILFunctionConventions funcConv(funcTy, SGF.SGM.M);
@@ -835,7 +835,7 @@ static void buildBlockToFuncThunkBody(SILGenFunction &SGF,
835835
CanSILFunctionType blockTy,
836836
CanSILFunctionType funcTy) {
837837
// Collect the native arguments, which should all be +1.
838-
Scope scope(SGF.Cleanups, CleanupLocation::get(loc));
838+
Scope scope(SGF.Cleanups, CleanupLocation(loc));
839839

840840
// Make sure we lower the component types of the formal block type.
841841
formalBlockTy =
@@ -1260,7 +1260,7 @@ static SILValue emitBridgeReturnValue(SILGenFunction &SGF,
12601260
CanType formalNativeTy,
12611261
CanType formalBridgedTy,
12621262
SILType loweredBridgedTy) {
1263-
Scope scope(SGF.Cleanups, CleanupLocation::get(loc));
1263+
Scope scope(SGF.Cleanups, CleanupLocation(loc));
12641264

12651265
ManagedValue native = SGF.emitManagedRValueWithCleanup(result);
12661266
ManagedValue bridged =
@@ -1545,7 +1545,7 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) {
15451545

15461546
auto loc = thunk.getAsRegularLocation();
15471547
loc.markAutoGenerated();
1548-
Scope scope(Cleanups, CleanupLocation::get(loc));
1548+
Scope scope(Cleanups, CleanupLocation(loc));
15491549

15501550
// If we are bridging a Swift method with an Any return value, create a
15511551
// stack allocation to hold the result, since Any is address-only.
@@ -1597,7 +1597,7 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) {
15971597
// Now, enter a cleanup used for bridging the arguments. Note that if we
15981598
// have an indirect result, it must be outside of this scope, otherwise
15991599
// we will deallocate it too early.
1600-
Scope argScope(Cleanups, CleanupLocation::get(loc));
1600+
Scope argScope(Cleanups, CleanupLocation(loc));
16011601

16021602
// Bridge the arguments.
16031603
Optional<ForeignErrorConvention> foreignError;

lib/SILGen/SILGenConstructor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static void emitImplicitValueConstructor(SILGenFunction &SGF,
156156
Loc.markAutoGenerated();
157157

158158
AssertingManualScope functionLevelScope(SGF.Cleanups,
159-
CleanupLocation::get(Loc));
159+
CleanupLocation(Loc));
160160

161161
// FIXME: Handle 'self' along with the other arguments.
162162
auto *paramList = ctor->getParameters();
@@ -424,7 +424,7 @@ void SILGenFunction::emitValueConstructor(ConstructorDecl *ctor) {
424424
SILGenSavedInsertionPoint savedIP(*this, ReturnDest.getBlock());
425425
assert(B.getInsertionBB()->empty() && "Epilog already set up?");
426426

427-
auto cleanupLoc = CleanupLocation::get(ctor);
427+
auto cleanupLoc = CleanupLocation(ctor);
428428

429429
if (!F.getConventions().hasIndirectSILResults()) {
430430
// Otherwise, load and return the final 'self' value.
@@ -657,7 +657,7 @@ static void emitDefaultActorInitialization(SILGenFunction &SGF,
657657
getBuiltinName(BuiltinValueKind::InitializeDefaultActor));
658658
auto resultTy = SGF.SGM.Types.getEmptyTupleType();
659659

660-
FullExpr scope(SGF.Cleanups, CleanupLocation::get(loc));
660+
FullExpr scope(SGF.Cleanups, CleanupLocation(loc));
661661
SGF.B.createBuiltin(loc, builtinName, resultTy, /*subs*/{},
662662
{ self.borrow(SGF, loc).getValue() });
663663
}
@@ -760,7 +760,7 @@ void SILGenFunction::emitClassConstructorInitializer(ConstructorDecl *ctor) {
760760
// Create a basic block to jump to for the implicit 'self' return.
761761
// We won't emit the block until after we've emitted the body.
762762
prepareEpilog(false, ctor->hasThrows(),
763-
CleanupLocation::get(endOfInitLoc));
763+
CleanupLocation(endOfInitLoc));
764764

765765
auto resultType = ctor->mapTypeIntoContext(ctor->getResultInterfaceType());
766766

@@ -1136,7 +1136,7 @@ void SILGenFunction::emitIVarInitializer(SILDeclRef ivarInitializer) {
11361136
assert(selfTy.hasReferenceSemantics() && "can't emit a value type ctor here");
11371137
VarLocs[selfDecl] = VarLoc::get(selfArg);
11381138

1139-
auto cleanupLoc = CleanupLocation::get(loc);
1139+
auto cleanupLoc = CleanupLocation(loc);
11401140
prepareEpilog(false, false, cleanupLoc);
11411141

11421142
// Emit the initializers.

0 commit comments

Comments
 (0)