Skip to content

Commit b1115af

Browse files
committed
Switch a pile of VarDecl::Specifier::Owneds to ::Default.
A lot of these probably should be Owned, but deciding that is work for another time.
1 parent 38029ba commit b1115af

9 files changed

+48
-60
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ makeEnumRawValueConstructor(ClangImporter::Implementation &Impl,
434434
auto selfDecl = ParamDecl::createSelf(SourceLoc(), enumDecl,
435435
/*static*/false, /*inout*/true);
436436

437-
auto param = new (C) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(),
437+
auto param = new (C) ParamDecl(VarDecl::Specifier::Default, SourceLoc(),
438438
SourceLoc(), C.Id_rawValue,
439439
SourceLoc(), C.Id_rawValue,
440440
rawTy,
@@ -708,7 +708,7 @@ static AccessorDecl *makeFieldSetterDecl(ClangImporter::Implementation &Impl,
708708
auto &C = Impl.SwiftContext;
709709
auto selfDecl = ParamDecl::createSelf(SourceLoc(), importedDecl,
710710
/*isStatic*/false, /*isInOut*/true);
711-
auto newValueDecl = new (C) ParamDecl(VarDecl::Specifier::Owned,
711+
auto newValueDecl = new (C) ParamDecl(VarDecl::Specifier::Default,
712712
SourceLoc(), SourceLoc(),
713713
Identifier(), SourceLoc(), C.Id_value,
714714
importedFieldDecl->getType(),
@@ -1267,7 +1267,7 @@ createValueConstructor(ClangImporter::Implementation &Impl,
12671267

12681268
Identifier argName = generateParamName ? var->getName() : Identifier();
12691269
auto param = new (context)
1270-
ParamDecl(VarDecl::Specifier::Owned, SourceLoc(), SourceLoc(), argName,
1270+
ParamDecl(VarDecl::Specifier::Default, SourceLoc(), SourceLoc(), argName,
12711271
SourceLoc(), var->getName(), var->getType(), structDecl);
12721272
param->setInterfaceType(var->getInterfaceType());
12731273
param->setValidationStarted();
@@ -1689,7 +1689,7 @@ buildSubscriptSetterDecl(ClangImporter::Implementation &Impl,
16891689
auto elementTy = dc->mapTypeIntoContext(elementInterfaceTy);
16901690

16911691
auto paramVarDecl =
1692-
new (C) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(), SourceLoc(),
1692+
new (C) ParamDecl(VarDecl::Specifier::Default, SourceLoc(), SourceLoc(),
16931693
Identifier(), loc, valueIndex->get(0)->getName(),
16941694
elementTy, dc);
16951695
paramVarDecl->setInterfaceType(elementInterfaceTy);

lib/ClangImporter/ImportType.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
16611661
// imported header unit.
16621662
auto paramInfo = createDeclWithClangNode<ParamDecl>(
16631663
param, AccessLevel::Private,
1664-
VarDecl::Specifier::Owned, SourceLoc(), SourceLoc(), name,
1664+
VarDecl::Specifier::Default, SourceLoc(), SourceLoc(), name,
16651665
importSourceLoc(param->getLocation()), bodyName,
16661666
dc->mapTypeIntoContext(swiftParamTy),
16671667
ImportedHeaderUnit);
@@ -1679,7 +1679,7 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
16791679
BoundGenericType::get(SwiftContext.getArrayDecl(), Type(),
16801680
{SwiftContext.TheAnyType});
16811681
auto name = SwiftContext.getIdentifier("varargs");
1682-
auto param = new (SwiftContext) ParamDecl(VarDecl::Specifier::Owned,
1682+
auto param = new (SwiftContext) ParamDecl(VarDecl::Specifier::Default,
16831683
SourceLoc(), SourceLoc(),
16841684
Identifier(), SourceLoc(),
16851685
name, paramTy,
@@ -1980,7 +1980,7 @@ ImportedType ClangImporter::Implementation::importMethodType(
19801980
// It doesn't actually matter which DeclContext we use, so just
19811981
// use the imported header unit.
19821982
auto type = TupleType::getEmpty(SwiftContext);
1983-
auto var = new (SwiftContext) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(),
1983+
auto var = new (SwiftContext) ParamDecl(VarDecl::Specifier::Default, SourceLoc(),
19841984
SourceLoc(), argName,
19851985
SourceLoc(), argName, type,
19861986
ImportedHeaderUnit);
@@ -2106,7 +2106,7 @@ ImportedType ClangImporter::Implementation::importMethodType(
21062106
// Set up the parameter info.
21072107
auto paramInfo
21082108
= createDeclWithClangNode<ParamDecl>(param, AccessLevel::Private,
2109-
VarDecl::Specifier::Owned,
2109+
VarDecl::Specifier::Default,
21102110
SourceLoc(), SourceLoc(), name,
21112111
importSourceLoc(param->getLocation()),
21122112
bodyName,
@@ -2226,7 +2226,7 @@ ImportedType ClangImporter::Implementation::importAccessorMethodType(
22262226
Identifier argLabel = functionName.getDeclName().getArgumentNames().front();
22272227
auto paramInfo
22282228
= createDeclWithClangNode<ParamDecl>(param, AccessLevel::Private,
2229-
VarDecl::Specifier::Owned,
2229+
VarDecl::Specifier::Default,
22302230
/*let loc*/SourceLoc(),
22312231
/*label loc*/SourceLoc(),
22322232
argLabel, nameLoc, bodyName,

lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3676,10 +3676,9 @@ static ParamDecl *createSetterAccessorArgument(SourceLoc nameLoc,
36763676
name = P.Context.getIdentifier(implName);
36773677
}
36783678

3679-
auto result = new (P.Context) ParamDecl(VarDecl::Specifier::Owned,
3680-
SourceLoc(),SourceLoc(),
3681-
Identifier(), nameLoc, name,
3682-
Type(), P.CurDeclContext);
3679+
auto result = new (P.Context)
3680+
ParamDecl(VarDecl::Specifier::Default, SourceLoc(), SourceLoc(),
3681+
Identifier(), nameLoc, name, Type(), P.CurDeclContext);
36833682
if (isNameImplicit)
36843683
result->setImplicit();
36853684

lib/SILGen/SILGenConstructor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ static SILValue emitConstructorMetatypeArg(SILGenFunction &SGF,
3434
Type metatype = ctor->getInterfaceType()->castTo<AnyFunctionType>()->getInput();
3535
auto *DC = ctor->getInnermostDeclContext();
3636
auto &AC = SGF.getASTContext();
37-
auto VD = new (AC) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(), SourceLoc(),
38-
AC.getIdentifier("$metatype"), SourceLoc(),
39-
AC.getIdentifier("$metatype"), Type(),
40-
DC);
37+
auto VD =
38+
new (AC) ParamDecl(VarDecl::Specifier::Default, SourceLoc(), SourceLoc(),
39+
AC.getIdentifier("$metatype"), SourceLoc(),
40+
AC.getIdentifier("$metatype"), Type(), DC);
4141
VD->setInterfaceType(metatype);
4242

4343
SGF.AllocatorMetatype = SGF.F.begin()->createFunctionArgument(
@@ -61,7 +61,7 @@ static RValue emitImplicitValueConstructorArg(SILGenFunction &SGF,
6161
}
6262

6363
auto &AC = SGF.getASTContext();
64-
auto VD = new (AC) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(), SourceLoc(),
64+
auto VD = new (AC) ParamDecl(VarDecl::Specifier::Default, SourceLoc(), SourceLoc(),
6565
AC.getIdentifier("$implicit_value"),
6666
SourceLoc(),
6767
AC.getIdentifier("$implicit_value"), Type(),

lib/Sema/CodeSynthesis.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,9 @@ static AccessorDecl *createSetterPrototype(AbstractStorageDecl *storage,
203203
// Add a "(value : T, indices...)" argument list.
204204
auto storageType = getTypeOfStorage(storage, false);
205205
auto storageInterfaceType = getTypeOfStorage(storage, true);
206-
valueDecl = buildArgument(storage->getLoc(),
207-
storage->getDeclContext(), "value",
208-
storageType,
209-
storageInterfaceType,
210-
VarDecl::Specifier::Owned);
206+
valueDecl = buildArgument(storage->getLoc(), storage->getDeclContext(),
207+
"value", storageType, storageInterfaceType,
208+
VarDecl::Specifier::Default);
211209
params.push_back(buildIndexForwardingParamList(storage, valueDecl));
212210

213211
Type setterRetTy = TupleType::getEmpty(TC.Context);
@@ -314,15 +312,10 @@ createMaterializeForSetPrototype(AbstractStorageDecl *storage,
314312
// inout storage: Builtin.UnsafeValueBuffer,
315313
// indices...).
316314
ParamDecl *bufferElements[] = {
317-
buildArgument(loc, DC, "buffer",
318-
ctx.TheRawPointerType,
319-
ctx.TheRawPointerType,
320-
VarDecl::Specifier::Owned),
321-
buildArgument(loc, DC, "callbackStorage",
322-
ctx.TheUnsafeValueBufferType,
323-
ctx.TheUnsafeValueBufferType,
324-
VarDecl::Specifier::InOut)
325-
};
315+
buildArgument(loc, DC, "buffer", ctx.TheRawPointerType,
316+
ctx.TheRawPointerType, VarDecl::Specifier::Default),
317+
buildArgument(loc, DC, "callbackStorage", ctx.TheUnsafeValueBufferType,
318+
ctx.TheUnsafeValueBufferType, VarDecl::Specifier::InOut)};
326319
params.push_back(buildIndexForwardingParamList(storage, bufferElements));
327320

328321
// The accessor returns (temporary: Builtin.RawPointer,
@@ -1934,9 +1927,9 @@ ConstructorDecl *swift::createImplicitConstructor(TypeChecker &tc,
19341927
}
19351928

19361929
// Create the parameter.
1937-
auto *arg = new (context) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(),
1938-
Loc, var->getName(),
1939-
Loc, var->getName(), varType, decl);
1930+
auto *arg = new (context)
1931+
ParamDecl(VarDecl::Specifier::Default, SourceLoc(), Loc,
1932+
var->getName(), Loc, var->getName(), varType, decl);
19401933
arg->setInterfaceType(varInterfaceType);
19411934
arg->setImplicit();
19421935

lib/Sema/DerivedConformanceCodable.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,9 @@ static CallExpr *createContainerKeyedByCall(ASTContext &C, DeclContext *DC,
484484
Expr *base, Type returnType,
485485
NominalTypeDecl *param) {
486486
// (keyedBy:)
487-
auto *keyedByDecl = new (C) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(),
488-
SourceLoc(), C.Id_keyedBy, SourceLoc(),
489-
C.Id_keyedBy, returnType, DC);
487+
auto *keyedByDecl = new (C)
488+
ParamDecl(VarDecl::Specifier::Default, SourceLoc(), SourceLoc(),
489+
C.Id_keyedBy, SourceLoc(), C.Id_keyedBy, returnType, DC);
490490
keyedByDecl->setImplicit();
491491
keyedByDecl->setInterfaceType(returnType);
492492

@@ -727,9 +727,9 @@ static FuncDecl *deriveEncodable_encode(TypeChecker &tc, Decl *parentDecl,
727727

728728
// Params: (self [implicit], Encoder)
729729
auto *selfDecl = ParamDecl::createSelf(SourceLoc(), target);
730-
auto *encoderParam = new (C) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(),
731-
SourceLoc(), C.Id_to, SourceLoc(),
732-
C.Id_encoder, encoderType, target);
730+
auto *encoderParam = new (C)
731+
ParamDecl(VarDecl::Specifier::Default, SourceLoc(), SourceLoc(), C.Id_to,
732+
SourceLoc(), C.Id_encoder, encoderType, target);
733733
encoderParam->setInterfaceType(encoderType);
734734

735735
ParameterList *params[] = {ParameterList::createWithoutLoc(selfDecl),
@@ -1065,11 +1065,9 @@ static ValueDecl *deriveDecodable_init(TypeChecker &tc, Decl *parentDecl,
10651065
auto *selfDecl = ParamDecl::createSelf(SourceLoc(), target,
10661066
/*isStatic=*/false,
10671067
/*isInOut=*/inOut);
1068-
auto *decoderParamDecl = new (C) ParamDecl(VarDecl::Specifier::Owned,
1069-
SourceLoc(),
1070-
SourceLoc(), C.Id_from,
1071-
SourceLoc(), C.Id_decoder,
1072-
decoderType, target);
1068+
auto *decoderParamDecl = new (C)
1069+
ParamDecl(VarDecl::Specifier::Default, SourceLoc(), SourceLoc(),
1070+
C.Id_from, SourceLoc(), C.Id_decoder, decoderType, target);
10731071
decoderParamDecl->setImplicit();
10741072
decoderParamDecl->setInterfaceType(decoderType);
10751073

lib/Sema/DerivedConformanceCodingKey.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ static void deriveRawValueInit(AbstractFunctionDecl *initDecl) {
7474
DeclNameLoc(), /*Implicit=*/true);
7575

7676
// rawValue param to init(rawValue:)
77-
auto *rawValueDecl = new (C) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(),
78-
SourceLoc(), C.Id_rawValue,
79-
SourceLoc(), C.Id_rawValue,
80-
valueParam->getType(), parentDC);
77+
auto *rawValueDecl = new (C) ParamDecl(
78+
VarDecl::Specifier::Default, SourceLoc(), SourceLoc(), C.Id_rawValue,
79+
SourceLoc(), C.Id_rawValue, valueParam->getType(), parentDC);
8180
rawValueDecl->setInterfaceType(C.getIntDecl()->getDeclaredType());
8281
rawValueDecl->setImplicit();
8382
auto *paramList = ParameterList::createWithoutLoc(rawValueDecl);
@@ -124,9 +123,9 @@ static ValueDecl *deriveInitDecl(TypeChecker &tc, Decl *parentDecl,
124123
auto *parentDC = cast<DeclContext>(parentDecl);
125124

126125
// rawValue
127-
auto *rawDecl = new (C) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(), SourceLoc(),
128-
paramName, SourceLoc(), paramName,
129-
paramType, parentDC);
126+
auto *rawDecl =
127+
new (C) ParamDecl(VarDecl::Specifier::Default, SourceLoc(), SourceLoc(),
128+
paramName, SourceLoc(), paramName, paramType, parentDC);
130129
rawDecl->setInterfaceType(paramType);
131130
rawDecl->setImplicit();
132131

lib/Sema/DerivedConformanceRawRepresentable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ static ConstructorDecl *deriveRawRepresentable_init(TypeChecker &tc,
292292
auto *selfDecl = ParamDecl::createSelf(SourceLoc(), parentDC,
293293
/*static*/false, /*inout*/true);
294294

295-
auto *rawDecl = new (C) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(), SourceLoc(),
296-
C.Id_rawValue, SourceLoc(),
297-
C.Id_rawValue, rawType, parentDC);
295+
auto *rawDecl = new (C)
296+
ParamDecl(VarDecl::Specifier::Default, SourceLoc(), SourceLoc(),
297+
C.Id_rawValue, SourceLoc(), C.Id_rawValue, rawType, parentDC);
298298
rawDecl->setInterfaceType(rawInterfaceType);
299299
rawDecl->setImplicit();
300300
auto paramList = ParameterList::createWithoutLoc(rawDecl);

lib/Sema/TypeCheckREPL.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,9 @@ void REPLChecker::generatePrintOfExpression(StringRef NameStr, Expr *E) {
229229
TopLevelCodeDecl *newTopLevel = new (Context) TopLevelCodeDecl(&SF);
230230

231231
// Build function of type T->() which prints the operand.
232-
auto *Arg = new (Context) ParamDecl(VarDecl::Specifier::Owned, SourceLoc(),
233-
SourceLoc(), Identifier(),
234-
Loc, Context.getIdentifier("arg"),
235-
E->getType(), /*DC*/ newTopLevel);
232+
auto *Arg = new (Context) ParamDecl(
233+
VarDecl::Specifier::Default, SourceLoc(), SourceLoc(), Identifier(), Loc,
234+
Context.getIdentifier("arg"), E->getType(), /*DC*/ newTopLevel);
236235
Arg->setInterfaceType(E->getType());
237236
auto params = ParameterList::createWithoutLoc(Arg);
238237

0 commit comments

Comments
 (0)