Skip to content

Commit 2920ea8

Browse files
committed
Address llvm::(Mutable)ArrayRef ctor deprecations
See: - llvm/llvm-project#146113 - llvm/llvm-project#146011
1 parent f40d3b4 commit 2920ea8

File tree

17 files changed

+78
-71
lines changed

17 files changed

+78
-71
lines changed

include/swift/AST/ExtInfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,15 +549,15 @@ class ASTExtInfoBuilder {
549549
: ASTExtInfoBuilder(Representation::Swift, false, false, Type(),
550550
DifferentiabilityKind::NonDifferentiable, nullptr,
551551
FunctionTypeIsolation::forNonIsolated(),
552-
std::nullopt /* LifetimeDependenceInfo */,
552+
{} /* LifetimeDependenceInfo */,
553553
false /*sendingResult*/) {}
554554

555555
// Constructor for polymorphic type.
556556
ASTExtInfoBuilder(Representation rep, bool throws, Type thrownError)
557557
: ASTExtInfoBuilder(rep, false, throws, thrownError,
558558
DifferentiabilityKind::NonDifferentiable, nullptr,
559559
FunctionTypeIsolation::forNonIsolated(),
560-
std::nullopt /* LifetimeDependenceInfo */,
560+
{} /* LifetimeDependenceInfo */,
561561
false /*sendingResult*/) {}
562562

563563
// Constructor with no defaults.
@@ -1047,7 +1047,7 @@ class SILExtInfoBuilder {
10471047
makeBits(SILFunctionTypeRepresentation::Thick, false, false, false,
10481048
false, false, SILFunctionTypeIsolation::forUnknown(),
10491049
DifferentiabilityKind::NonDifferentiable),
1050-
ClangTypeInfo(nullptr), /*LifetimeDependenceInfo*/ std::nullopt) {}
1050+
ClangTypeInfo(nullptr), /*LifetimeDependenceInfo*/ {}) {}
10511051

10521052
SILExtInfoBuilder(Representation rep, bool isPseudogeneric, bool isNoEscape,
10531053
bool isSendable, bool isAsync, bool isUnimplementable,

include/swift/AST/Types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,7 +4018,7 @@ class FunctionType final
40184018

40194019
ArrayRef<LifetimeDependenceInfo> getLifetimeDependencies() const {
40204020
if (!hasLifetimeDependencies())
4021-
return std::nullopt;
4021+
return {};
40224022
return {getTrailingObjects<LifetimeDependenceInfo>(),
40234023
getNumLifetimeDependencies()};
40244024
}
@@ -4188,7 +4188,7 @@ class GenericFunctionType final
41884188

41894189
ArrayRef<LifetimeDependenceInfo> getLifetimeDependencies() const {
41904190
if (!hasLifetimeDependencies())
4191-
return std::nullopt;
4191+
return {};
41924192
return {getTrailingObjects<LifetimeDependenceInfo>(),
41934193
getNumLifetimeDependencies()};
41944194
}
@@ -5680,7 +5680,7 @@ class SILFunctionType final
56805680
// relative to the original FunctionType.
56815681
ArrayRef<LifetimeDependenceInfo> getLifetimeDependencies() const {
56825682
if (!hasLifetimeDependencies())
5683-
return std::nullopt;
5683+
return {};
56845684
return {getTrailingObjects<LifetimeDependenceInfo>(),
56855685
NumLifetimeDependencies};
56865686
}

include/swift/Basic/TaskQueue.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ class TaskQueue {
205205
/// \param Context an optional context which will be associated with the task
206206
/// \param SeparateErrors Controls whether error output is reported separately
207207
virtual void addTask(const char *ExecPath, ArrayRef<const char *> Args,
208-
ArrayRef<const char *> Env = std::nullopt,
209-
void *Context = nullptr, bool SeparateErrors = false);
208+
ArrayRef<const char *> Env = {}, void *Context = nullptr,
209+
bool SeparateErrors = false);
210210

211211
/// Synchronously executes the tasks in the TaskQueue.
212212
///
@@ -240,8 +240,8 @@ class DummyTaskQueue : public TaskQueue {
240240
bool SeparateErrors;
241241

242242
DummyTask(const char *ExecPath, ArrayRef<const char *> Args,
243-
ArrayRef<const char *> Env = std::nullopt,
244-
void *Context = nullptr, bool SeparateErrors = false)
243+
ArrayRef<const char *> Env = {}, void *Context = nullptr,
244+
bool SeparateErrors = false)
245245
: ExecPath(ExecPath), Args(Args), Env(Env), Context(Context),
246246
SeparateErrors(SeparateErrors) {}
247247
};
@@ -254,8 +254,8 @@ class DummyTaskQueue : public TaskQueue {
254254
virtual ~DummyTaskQueue();
255255

256256
void addTask(const char *ExecPath, ArrayRef<const char *> Args,
257-
ArrayRef<const char *> Env = std::nullopt,
258-
void *Context = nullptr, bool SeparateErrors = false) override;
257+
ArrayRef<const char *> Env = {}, void *Context = nullptr,
258+
bool SeparateErrors = false) override;
259259

260260
bool
261261
execute(TaskBeganCallback Began = TaskBeganCallback(),

include/swift/Driver/Action.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class CompileJobAction : public JobAction {
134134

135135
public:
136136
CompileJobAction(file_types::ID OutputType)
137-
: JobAction(Action::Kind::CompileJob, std::nullopt, OutputType) {}
137+
: JobAction(Action::Kind::CompileJob, {}, OutputType) {}
138138
CompileJobAction(Action *Input, file_types::ID OutputType)
139139
: JobAction(Action::Kind::CompileJob, Input, OutputType) {}
140140

@@ -169,8 +169,7 @@ class InterpretJobAction : public JobAction {
169169

170170
public:
171171
explicit InterpretJobAction()
172-
: JobAction(Action::Kind::InterpretJob, std::nullopt,
173-
file_types::TY_Nothing) {}
172+
: JobAction(Action::Kind::InterpretJob, {}, file_types::TY_Nothing) {}
174173

175174
static bool classof(const Action *A) {
176175
return A->getKind() == Action::Kind::InterpretJob;
@@ -209,7 +208,7 @@ class REPLJobAction : public JobAction {
209208
Mode RequestedMode;
210209
public:
211210
REPLJobAction(Mode mode)
212-
: JobAction(Action::Kind::REPLJob, std::nullopt, file_types::TY_Nothing),
211+
: JobAction(Action::Kind::REPLJob, {}, file_types::TY_Nothing),
213212
RequestedMode(mode) {}
214213

215214
Mode getRequestedMode() const { return RequestedMode; }

lib/AST/ASTDemangler.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,13 @@ Type ASTBuilder::createFunctionType(
474474
representation);
475475

476476
// TODO: Handle LifetimeDependenceInfo here.
477-
auto einfo =
478-
FunctionType::ExtInfoBuilder(
479-
representation, noescape, flags.isThrowing(), thrownError,
480-
resultDiffKind, clangFunctionType, isolation,
481-
/*LifetimeDependenceInfo*/ std::nullopt, extFlags.hasSendingResult())
482-
.withAsync(flags.isAsync())
483-
.withSendable(flags.isSendable())
484-
.build();
477+
auto einfo = FunctionType::ExtInfoBuilder(
478+
representation, noescape, flags.isThrowing(), thrownError,
479+
resultDiffKind, clangFunctionType, isolation,
480+
/*LifetimeDependenceInfo*/ {}, extFlags.hasSendingResult())
481+
.withAsync(flags.isAsync())
482+
.withSendable(flags.isSendable())
483+
.build();
485484

486485
return FunctionType::get(funcParams, output, einfo);
487486
}
@@ -714,7 +713,7 @@ Type ASTBuilder::createImplFunctionType(
714713
SILFunctionType::ExtInfoBuilder(
715714
representation, flags.isPseudogeneric(), !flags.isEscaping(),
716715
flags.isSendable(), flags.isAsync(), unimplementable, isolation,
717-
diffKind, clangFnType, /*LifetimeDependenceInfo*/ std::nullopt)
716+
diffKind, clangFnType, /*LifetimeDependenceInfo*/ {})
718717
.build();
719718

720719
return SILFunctionType::get(genericSig, einfo, funcCoroutineKind,

lib/AST/ASTMangler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,7 +3018,7 @@ void ASTMangler::appendContextualInverses(const GenericTypeDecl *contextDecl,
30183018
// that we're extending.
30193019

30203020
// There are no generic parameters in this extension itself.
3021-
parts.params = std::nullopt;
3021+
parts.params = {};
30223022

30233023
// The depth of parameters for this extension is +1 of the extended signature.
30243024
parts.initialParamDepth = sig.getNextDepth();
@@ -3616,7 +3616,7 @@ bool ASTMangler::GenericSignatureParts::hasRequirements() const {
36163616
}
36173617

36183618
void ASTMangler::GenericSignatureParts::clear() {
3619-
params = std::nullopt;
3619+
params = {};
36203620
requirements.clear();
36213621
inverses.clear();
36223622
initialParamDepth = 0;

lib/AST/Decl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7383,8 +7383,7 @@ ArrayRef<ProtocolDecl *>
73837383
ProtocolDecl::getProtocolDependencies() const {
73847384
return evaluateOrDefault(
73857385
getASTContext().evaluator,
7386-
ProtocolDependenciesRequest{const_cast<ProtocolDecl *>(this)},
7387-
std::nullopt);
7386+
ProtocolDependenciesRequest{const_cast<ProtocolDecl *>(this)}, {});
73887387
}
73897388

73907389
RequirementSignature ProtocolDecl::getRequirementSignature() const {

lib/ClangImporter/ImportDecl.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,8 @@ namespace {
11711171
auto *enumDecl = Impl.createDeclWithClangNode<EnumDecl>(
11721172
decl, AccessLevel::Public, Impl.importSourceLoc(decl->getBeginLoc()),
11731173
importedName.getBaseIdentifier(Impl.SwiftContext),
1174-
Impl.importSourceLoc(decl->getLocation()), std::nullopt, nullptr, dc);
1174+
Impl.importSourceLoc(decl->getLocation()), ArrayRef<InheritedEntry>(),
1175+
nullptr, dc);
11751176
// TODO: we only have this for the sid effect of calling
11761177
// "FirstDeclAndLazyMembers.setInt(true)".
11771178
// This should never actually try to use Impl as the member loader,
@@ -1595,7 +1596,8 @@ namespace {
15951596
auto access = importer::convertClangAccess(decl->getAccess());
15961597
auto Loc = Impl.importSourceLoc(decl->getLocation());
15971598
auto structDecl = Impl.createDeclWithClangNode<StructDecl>(
1598-
decl, access, Loc, name, Loc, std::nullopt, nullptr, dc);
1599+
decl, access, Loc, name, Loc, ArrayRef<InheritedEntry>(), nullptr,
1600+
dc);
15991601

16001602
auto options = getDefaultMakeStructRawValuedOptions();
16011603
options |= MakeStructRawValuedFlags::MakeUnlabeledValueInit;
@@ -1649,7 +1651,7 @@ namespace {
16491651
"NSError enums shouldn't be defined as non-public C++ members");
16501652
// Create the wrapper struct.
16511653
errorWrapper =
1652-
new (C) StructDecl(loc, name, loc, std::nullopt, nullptr, dc);
1654+
new (C) StructDecl(loc, name, loc, /*Inherited*/ {}, nullptr, dc);
16531655
SourceLoc end = Impl.importSourceLoc(decl->getEndLoc());
16541656
errorWrapper->setBraces(SourceRange(loc, end));
16551657
errorWrapper->setAccess(AccessLevel::Public);
@@ -1719,8 +1721,8 @@ namespace {
17191721
// Create the enumeration.
17201722
auto enumDecl = Impl.createDeclWithClangNode<EnumDecl>(
17211723
decl, importer::convertClangAccess(decl->getAccess()), loc,
1722-
enumName, Impl.importSourceLoc(decl->getLocation()), std::nullopt,
1723-
nullptr, enumDC);
1724+
enumName, Impl.importSourceLoc(decl->getLocation()),
1725+
ArrayRef<InheritedEntry>(), nullptr, enumDC);
17241726
enumDecl->setHasFixedRawValues();
17251727

17261728
// Annotate as 'frozen' if appropriate.
@@ -2223,7 +2225,7 @@ namespace {
22232225
else
22242226
result = Impl.createDeclWithClangNode<StructDecl>(
22252227
decl, importer::convertClangAccess(decl->getAccess()), loc, name,
2226-
loc, std::nullopt, nullptr, dc);
2228+
loc, ArrayRef<InheritedEntry>(), nullptr, dc);
22272229
Impl.ImportedDecls[{decl->getCanonicalDecl(), getVersion()}] = result;
22282230

22292231
if (recordHasMoveOnlySemantics(decl)) {
@@ -4789,7 +4791,7 @@ namespace {
47894791

47904792
auto structDecl = Impl.createDeclWithClangNode<StructDecl>(
47914793
decl, importer::convertClangAccess(decl->getAccess()), loc, name, loc,
4792-
std::nullopt, genericParamList, dc);
4794+
ArrayRef<InheritedEntry>(), genericParamList, dc);
47934795

47944796
auto attr = AvailableAttr::createUniversallyUnavailable(
47954797
Impl.SwiftContext, "Un-specialized class templates are not currently "
@@ -5801,7 +5803,8 @@ namespace {
58015803
/*allowForwardDeclaration=*/true),
58025804
Impl.importSourceLoc(decl->getBeginLoc()),
58035805
Impl.importSourceLoc(decl->getLocation()), name,
5804-
ArrayRef<PrimaryAssociatedTypeName>(), std::nullopt,
5806+
ArrayRef<PrimaryAssociatedTypeName>(),
5807+
ArrayRef<InheritedEntry>(),
58055808
/*TrailingWhere=*/nullptr);
58065809

58075810
Impl.ImportedDecls[{decl->getCanonicalDecl(), getVersion()}] = result;
@@ -5841,7 +5844,7 @@ namespace {
58415844
decl, AccessLevel::Public, dc,
58425845
Impl.importSourceLoc(decl->getBeginLoc()),
58435846
Impl.importSourceLoc(decl->getLocation()), name,
5844-
ArrayRef<PrimaryAssociatedTypeName>(), std::nullopt,
5847+
ArrayRef<PrimaryAssociatedTypeName>(), ArrayRef<InheritedEntry>(),
58455848
/*TrailingWhere=*/nullptr);
58465849

58475850
addObjCAttribute(result, Impl.importIdentifier(decl->getIdentifier()));
@@ -5884,7 +5887,7 @@ namespace {
58845887

58855888
auto result = Impl.createDeclWithClangNode<ClassDecl>(
58865889
decl, AccessLevel::Public, SourceLoc(), name, SourceLoc(),
5887-
std::nullopt, nullptr, dc,
5890+
ArrayRef<InheritedEntry>(), nullptr, dc,
58885891
/*isActor*/ false);
58895892
if (cacheResult)
58905893
Impl.ImportedDecls[{decl->getCanonicalDecl(), getVersion()}] = result;
@@ -5998,7 +6001,8 @@ namespace {
59986001
// Create the class declaration and record it.
59996002
auto result = Impl.createDeclWithClangNode<ClassDecl>(
60006003
decl, access, Impl.importSourceLoc(decl->getBeginLoc()), name,
6001-
Impl.importSourceLoc(decl->getLocation()), std::nullopt, nullptr, dc,
6004+
Impl.importSourceLoc(decl->getLocation()), ArrayRef<InheritedEntry>(),
6005+
nullptr, dc,
60026006
/*isActor*/ false);
60036007

60046008
// Import generic arguments, if any.
@@ -6472,7 +6476,7 @@ SwiftDeclConverter::importCFClassType(const clang::TypedefNameDecl *decl,
64726476

64736477
auto theClass = Impl.createDeclWithClangNode<ClassDecl>(
64746478
decl, AccessLevel::Public, SourceLoc(), className, SourceLoc(),
6475-
std::nullopt, nullptr, dc, /*isActor*/ false);
6479+
ArrayRef<InheritedEntry>(), nullptr, dc, /*isActor*/ false);
64766480
theClass->setSuperclass(superclass);
64776481
theClass->setAddedImplicitInitializers(); // suppress all initializers
64786482
theClass->setHasMissingVTableEntries(false);
@@ -6638,7 +6642,7 @@ SwiftDeclConverter::importSwiftNewtype(const clang::TypedefNameDecl *decl,
66386642

66396643
auto structDecl = Impl.createDeclWithClangNode<StructDecl>(
66406644
decl, importer::convertClangAccess(decl->getAccess()), Loc, name, Loc,
6641-
std::nullopt, nullptr, dc);
6645+
ArrayRef<InheritedEntry>(), nullptr, dc);
66426646

66436647
// Import the type of the underlying storage
66446648
ImportDiagnosticAdder addImportDiag(Impl, decl, decl->getLocation());
@@ -6946,7 +6950,7 @@ SwiftDeclConverter::importAsOptionSetType(DeclContext *dc, Identifier name,
69466950
// Create a struct with the underlying type as a field.
69476951
auto structDecl = Impl.createDeclWithClangNode<StructDecl>(
69486952
decl, importer::convertClangAccess(decl->getAccess()), Loc, name, Loc,
6949-
std::nullopt, nullptr, dc);
6953+
ArrayRef<InheritedEntry>(), nullptr, dc);
69506954
Impl.ImportedDecls[{decl->getCanonicalDecl(), getVersion()}] = structDecl;
69516955

69526956
// Compute the underlying type.

lib/Driver/Compilation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ namespace driver {
282282
"not implemented for compilations with multiple jobs");
283283
if (Comp.getShowJobLifecycle())
284284
llvm::outs() << "Added to TaskQueue: " << LogJob(Cmd) << "\n";
285-
TQ->addTask(Cmd->getExecutable(), Cmd->getArgumentsForTaskExecution(),
286-
std::nullopt, (void *)Cmd);
285+
TQ->addTask(Cmd->getExecutable(), Cmd->getArgumentsForTaskExecution(), {},
286+
(void *)Cmd);
287287
}
288288

289289
/// When a task finishes, check other Jobs that may be blocked.

lib/Driver/DarwinToolChains.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static bool findXcodeClangPath(llvm::SmallVectorImpl<char> &path) {
186186
// included with an open-source toolchain.
187187
const char *args[] = {"-toolchain", "default", "-f", "clang", nullptr};
188188
sys::TaskQueue queue;
189-
queue.addTask(xcrunPath->c_str(), args, /*Env=*/std::nullopt,
189+
queue.addTask(xcrunPath->c_str(), args, /*Env=*/{},
190190
/*Context=*/nullptr,
191191
/*SeparateErrors=*/true);
192192
queue.execute(nullptr,

0 commit comments

Comments
 (0)