Skip to content

Commit 87a9245

Browse files
committed
[clang] Use {} instead of std::nullopt to initialize empty ArrayRef
Follow up to llvm#109133.
1 parent 9e73159 commit 87a9245

File tree

115 files changed

+289
-289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+289
-289
lines changed

clang/include/clang/AST/CommentSema.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Sema {
8080
ArrayRef<T> copyArray(ArrayRef<T> Source) {
8181
if (!Source.empty())
8282
return Source.copy(Allocator);
83-
return std::nullopt;
83+
return {};
8484
}
8585

8686
ParagraphComment *actOnParagraphComment(

clang/include/clang/AST/DeclFriend.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class FriendDecl final
115115
static FriendDecl *
116116
Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_,
117117
SourceLocation FriendL, SourceLocation EllipsisLoc = {},
118-
ArrayRef<TemplateParameterList *> FriendTypeTPLists = std::nullopt);
118+
ArrayRef<TemplateParameterList *> FriendTypeTPLists = {});
119119
static FriendDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID,
120120
unsigned FriendTypeNumTPLists);
121121

clang/include/clang/AST/DeclObjC.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ class ObjCMethodDecl : public NamedDecl, public DeclContext {
386386
/// If the method is implicit (not coming from source) \p SelLocs is
387387
/// ignored.
388388
void setMethodParams(ASTContext &C, ArrayRef<ParmVarDecl *> Params,
389-
ArrayRef<SourceLocation> SelLocs = std::nullopt);
389+
ArrayRef<SourceLocation> SelLocs = {});
390390

391391
// Iterator access to parameter types.
392392
struct GetTypeFn {

clang/include/clang/AST/DeclOpenMP.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ template <typename U> class OMPDeclarativeDirective : public U {
3434
/// Get the clauses storage.
3535
MutableArrayRef<OMPClause *> getClauses() {
3636
if (!Data)
37-
return std::nullopt;
37+
return {};
3838
return Data->getClauses();
3939
}
4040

@@ -90,7 +90,7 @@ template <typename U> class OMPDeclarativeDirective : public U {
9090

9191
ArrayRef<OMPClause *> clauses() const {
9292
if (!Data)
93-
return std::nullopt;
93+
return {};
9494
return Data->getClauses();
9595
}
9696
};

clang/include/clang/AST/ExprCXX.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4310,7 +4310,7 @@ class SizeOfPackExpr final
43104310
Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack,
43114311
SourceLocation PackLoc, SourceLocation RParenLoc,
43124312
std::optional<unsigned> Length = std::nullopt,
4313-
ArrayRef<TemplateArgument> PartialArgs = std::nullopt);
4313+
ArrayRef<TemplateArgument> PartialArgs = {});
43144314
static SizeOfPackExpr *CreateDeserialized(ASTContext &Context,
43154315
unsigned NumPartialArgs);
43164316

clang/include/clang/AST/OpenMPClause.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -6009,14 +6009,14 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
60096009
return const_component_lists_iterator(
60106010
getUniqueDeclsRef(), getDeclNumListsRef(), getComponentListSizesRef(),
60116011
getComponentsRef(), SupportsMapper,
6012-
SupportsMapper ? getUDMapperRefs() : std::nullopt);
6012+
SupportsMapper ? getUDMapperRefs() : ArrayRef<Expr *>());
60136013
}
60146014
const_component_lists_iterator component_lists_end() const {
60156015
return const_component_lists_iterator(
60166016
ArrayRef<ValueDecl *>(), ArrayRef<unsigned>(), ArrayRef<unsigned>(),
60176017
MappableExprComponentListRef(getComponentsRef().end(),
60186018
getComponentsRef().end()),
6019-
SupportsMapper, std::nullopt);
6019+
SupportsMapper, {});
60206020
}
60216021
const_component_lists_range component_lists() const {
60226022
return {component_lists_begin(), component_lists_end()};
@@ -6029,7 +6029,7 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
60296029
return const_component_lists_iterator(
60306030
VD, getUniqueDeclsRef(), getDeclNumListsRef(),
60316031
getComponentListSizesRef(), getComponentsRef(), SupportsMapper,
6032-
SupportsMapper ? getUDMapperRefs() : std::nullopt);
6032+
SupportsMapper ? getUDMapperRefs() : ArrayRef<Expr *>());
60336033
}
60346034
const_component_lists_iterator decl_component_lists_end() const {
60356035
return component_lists_end();

clang/include/clang/AST/StmtOpenMP.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class OMPExecutableDirective : public Stmt {
277277
/// Get the clauses storage.
278278
MutableArrayRef<OMPClause *> getClauses() {
279279
if (!Data)
280-
return std::nullopt;
280+
return {};
281281
return Data->getClauses();
282282
}
283283

@@ -572,7 +572,7 @@ class OMPExecutableDirective : public Stmt {
572572

573573
ArrayRef<OMPClause *> clauses() const {
574574
if (!Data)
575-
return std::nullopt;
575+
return {};
576576
return Data->getClauses();
577577
}
578578

clang/include/clang/AST/TemplateBase.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ class TemplateArgument {
283283
}
284284

285285
static TemplateArgument getEmptyPack() {
286-
return TemplateArgument(std::nullopt);
286+
return TemplateArgument(ArrayRef<TemplateArgument>());
287287
}
288288

289289
/// Create a new template argument pack by copying the given set of

clang/include/clang/ASTMatchers/ASTMatchersInternal.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ template <typename T> struct TypeListContainsSuperOf<EmptyTypeList, T> {
121121
template <typename ResultT, typename ArgT,
122122
ResultT (*Func)(ArrayRef<const ArgT *>)>
123123
struct VariadicFunction {
124-
ResultT operator()() const { return Func(std::nullopt); }
124+
ResultT operator()() const { return Func({}); }
125125

126126
template <typename... ArgsT>
127127
ResultT operator()(const ArgT &Arg1, const ArgsT &... Args) const {
@@ -1949,35 +1949,35 @@ inline ArrayRef<TemplateArgument>
19491949
getTemplateSpecializationArgs(const FunctionDecl &FD) {
19501950
if (const auto* TemplateArgs = FD.getTemplateSpecializationArgs())
19511951
return TemplateArgs->asArray();
1952-
return std::nullopt;
1952+
return {};
19531953
}
19541954

19551955
inline ArrayRef<TemplateArgumentLoc>
19561956
getTemplateArgsWritten(const ClassTemplateSpecializationDecl &D) {
19571957
if (const ASTTemplateArgumentListInfo *Args = D.getTemplateArgsAsWritten())
19581958
return Args->arguments();
1959-
return std::nullopt;
1959+
return {};
19601960
}
19611961

19621962
inline ArrayRef<TemplateArgumentLoc>
19631963
getTemplateArgsWritten(const VarTemplateSpecializationDecl &D) {
19641964
if (const ASTTemplateArgumentListInfo *Args = D.getTemplateArgsAsWritten())
19651965
return Args->arguments();
1966-
return std::nullopt;
1966+
return {};
19671967
}
19681968

19691969
inline ArrayRef<TemplateArgumentLoc>
19701970
getTemplateArgsWritten(const FunctionDecl &FD) {
19711971
if (const auto *Args = FD.getTemplateSpecializationArgsAsWritten())
19721972
return Args->arguments();
1973-
return std::nullopt;
1973+
return {};
19741974
}
19751975

19761976
inline ArrayRef<TemplateArgumentLoc>
19771977
getTemplateArgsWritten(const DeclRefExpr &DRE) {
19781978
if (const auto *Args = DRE.getTemplateArgs())
19791979
return {Args, DRE.getNumTemplateArgs()};
1980-
return std::nullopt;
1980+
return {};
19811981
}
19821982

19831983
inline SmallVector<TemplateArgumentLoc>

clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ class Return : public Terminator {
14701470
static bool classof(const SExpr *E) { return E->opcode() == COP_Return; }
14711471

14721472
/// Return an empty list.
1473-
ArrayRef<BasicBlock *> successors() { return std::nullopt; }
1473+
ArrayRef<BasicBlock *> successors() { return {}; }
14741474

14751475
SExpr *returnValue() { return Retval; }
14761476
const SExpr *returnValue() const { return Retval; }
@@ -1496,7 +1496,7 @@ inline ArrayRef<BasicBlock*> Terminator::successors() {
14961496
case COP_Branch: return cast<Branch>(this)->successors();
14971497
case COP_Return: return cast<Return>(this)->successors();
14981498
default:
1499-
return std::nullopt;
1499+
return {};
15001500
}
15011501
}
15021502

clang/include/clang/Analysis/AnyCall.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class AnyCall {
143143
/// \returns formal parameters for direct calls (including virtual calls)
144144
ArrayRef<ParmVarDecl *> parameters() const {
145145
if (!D)
146-
return std::nullopt;
146+
return {};
147147

148148
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
149149
return FD->parameters();
@@ -152,7 +152,7 @@ class AnyCall {
152152
} else if (const auto *BD = dyn_cast<BlockDecl>(D)) {
153153
return BD->parameters();
154154
} else {
155-
return std::nullopt;
155+
return {};
156156
}
157157
}
158158

clang/include/clang/Basic/TargetInfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,7 @@ class TargetInfo : public TransferrableTargetInfo,
18531853
virtual ArrayRef<const char *> getGCCRegNames() const = 0;
18541854
virtual ArrayRef<GCCRegAlias> getGCCRegAliases() const = 0;
18551855
virtual ArrayRef<AddlRegName> getGCCAddlRegNames() const {
1856-
return std::nullopt;
1856+
return {};
18571857
}
18581858

18591859
private:

clang/include/clang/Driver/Job.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class Command {
172172
Command(const Action &Source, const Tool &Creator,
173173
ResponseFileSupport ResponseSupport, const char *Executable,
174174
const llvm::opt::ArgStringList &Arguments, ArrayRef<InputInfo> Inputs,
175-
ArrayRef<InputInfo> Outputs = std::nullopt,
175+
ArrayRef<InputInfo> Outputs = {},
176176
const char *PrependArg = nullptr);
177177
// FIXME: This really shouldn't be copyable, but is currently copied in some
178178
// error handling in Driver::generateCompilationDiagnostics.
@@ -246,7 +246,7 @@ class CC1Command : public Command {
246246
ResponseFileSupport ResponseSupport, const char *Executable,
247247
const llvm::opt::ArgStringList &Arguments,
248248
ArrayRef<InputInfo> Inputs,
249-
ArrayRef<InputInfo> Outputs = std::nullopt,
249+
ArrayRef<InputInfo> Outputs = {},
250250
const char *PrependArg = nullptr);
251251

252252
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,

clang/include/clang/Frontend/ASTUnit.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ class ASTUnit {
836836
bool StorePreamblesInMemory = false,
837837
StringRef PreambleStoragePath = StringRef(), bool OnlyLocalDecls = false,
838838
CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
839-
ArrayRef<RemappedFile> RemappedFiles = std::nullopt,
839+
ArrayRef<RemappedFile> RemappedFiles = {},
840840
bool RemappedFilesKeepOriginalName = true,
841841
unsigned PrecompilePreambleAfterNParses = 0,
842842
TranslationUnitKind TUKind = TU_Complete,
@@ -864,7 +864,7 @@ class ASTUnit {
864864
/// \returns True if a failure occurred that causes the ASTUnit not to
865865
/// contain any translation-unit information, false otherwise.
866866
bool Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
867-
ArrayRef<RemappedFile> RemappedFiles = std::nullopt,
867+
ArrayRef<RemappedFile> RemappedFiles = {},
868868
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
869869

870870
/// Free data that will be re-generated on the next parse.

clang/include/clang/Lex/Preprocessor.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ class Preprocessor {
910910
getActiveModuleMacros(Preprocessor &PP, const IdentifierInfo *II) const {
911911
if (auto *Info = getModuleInfo(PP, II))
912912
return Info->ActiveModuleMacros;
913-
return std::nullopt;
913+
return {};
914914
}
915915

916916
MacroDirective::DefInfo findDirectiveAtLoc(SourceLocation Loc,
@@ -934,7 +934,7 @@ class Preprocessor {
934934
ArrayRef<ModuleMacro*> getOverriddenMacros() const {
935935
if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
936936
return Info->OverriddenMacros;
937-
return std::nullopt;
937+
return {};
938938
}
939939

940940
void setOverriddenMacros(Preprocessor &PP,
@@ -1443,7 +1443,7 @@ class Preprocessor {
14431443
auto I = LeafModuleMacros.find(II);
14441444
if (I != LeafModuleMacros.end())
14451445
return I->second;
1446-
return std::nullopt;
1446+
return {};
14471447
}
14481448

14491449
/// Get the list of submodules that we're currently building.

clang/include/clang/Sema/CodeCompleteConsumer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,12 @@ class CodeCompletionContext {
375375
public:
376376
/// Construct a new code-completion context of the given kind.
377377
CodeCompletionContext(Kind CCKind)
378-
: CCKind(CCKind), IsUsingDeclaration(false), SelIdents(std::nullopt) {}
378+
: CCKind(CCKind), IsUsingDeclaration(false), SelIdents() {}
379379

380380
/// Construct a new code-completion context of the given kind.
381381
CodeCompletionContext(
382382
Kind CCKind, QualType T,
383-
ArrayRef<const IdentifierInfo *> SelIdents = std::nullopt)
383+
ArrayRef<const IdentifierInfo *> SelIdents = {})
384384
: CCKind(CCKind), IsUsingDeclaration(false), SelIdents(SelIdents) {
385385
if (CCKind == CCC_DotMemberAccess || CCKind == CCC_ArrowMemberAccess ||
386386
CCKind == CCC_ObjCPropertyAccess || CCKind == CCC_ObjCClassMessage ||

clang/include/clang/Sema/Overload.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ class Sema;
12081208
/// to the overload set.
12091209
OverloadCandidate &
12101210
addCandidate(unsigned NumConversions = 0,
1211-
ConversionSequenceList Conversions = std::nullopt) {
1211+
ConversionSequenceList Conversions = {}) {
12121212
assert((Conversions.empty() || Conversions.size() == NumConversions) &&
12131213
"preallocated conversion sequence has wrong length");
12141214

clang/include/clang/Sema/Sema.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -3549,7 +3549,7 @@ class Sema final : public SemaBase {
35493549
NamedDecl *ActOnVariableDeclarator(
35503550
Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo,
35513551
LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists,
3552-
bool &AddToScope, ArrayRef<BindingDecl *> Bindings = std::nullopt);
3552+
bool &AddToScope, ArrayRef<BindingDecl *> Bindings = {});
35533553

35543554
/// Perform semantic checking on a newly-created variable
35553555
/// declaration.
@@ -5393,7 +5393,7 @@ class Sema final : public SemaBase {
53935393

53945394
bool SetCtorInitializers(
53955395
CXXConstructorDecl *Constructor, bool AnyErrors,
5396-
ArrayRef<CXXCtorInitializer *> Initializers = std::nullopt);
5396+
ArrayRef<CXXCtorInitializer *> Initializers = {});
53975397

53985398
/// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
53995399
/// mark all the non-trivial destructors of its members and bases as
@@ -6691,7 +6691,7 @@ class Sema final : public SemaBase {
66916691
/// \param StopAt Subexpressions that we shouldn't recurse into.
66926692
void MarkDeclarationsReferencedInExpr(
66936693
Expr *E, bool SkipLocalVariables = false,
6694-
ArrayRef<const Expr *> StopAt = std::nullopt);
6694+
ArrayRef<const Expr *> StopAt = {});
66956695

66966696
/// Try to convert an expression \p E to type \p Ty. Returns the result of the
66976697
/// conversion.
@@ -6762,7 +6762,7 @@ class Sema final : public SemaBase {
67626762
DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
67636763
CorrectionCandidateCallback &CCC,
67646764
TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
6765-
ArrayRef<Expr *> Args = std::nullopt,
6765+
ArrayRef<Expr *> Args = {},
67666766
DeclContext *LookupCtx = nullptr,
67676767
TypoExpr **Out = nullptr);
67686768

@@ -10195,7 +10195,7 @@ class Sema final : public SemaBase {
1019510195
bool PartialOverloading = false, bool AllowExplicit = true,
1019610196
bool AllowExplicitConversion = false,
1019710197
ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10198-
ConversionSequenceList EarlyConversions = std::nullopt,
10198+
ConversionSequenceList EarlyConversions = {},
1019910199
OverloadCandidateParamOrder PO = {},
1020010200
bool AggregateCandidateDeduction = false);
1020110201

@@ -10231,7 +10231,7 @@ class Sema final : public SemaBase {
1023110231
ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
1023210232
bool SuppressUserConversions = false,
1023310233
bool PartialOverloading = false,
10234-
ConversionSequenceList EarlyConversions = std::nullopt,
10234+
ConversionSequenceList EarlyConversions = {},
1023510235
OverloadCandidateParamOrder PO = {});
1023610236

1023710237
/// Add a C++ member function template as a candidate to the candidate
@@ -13035,7 +13035,7 @@ class Sema final : public SemaBase {
1303513035
Sema &SemaRef, CodeSynthesisContext::SynthesisKind Kind,
1303613036
SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
1303713037
Decl *Entity, NamedDecl *Template = nullptr,
13038-
ArrayRef<TemplateArgument> TemplateArgs = std::nullopt,
13038+
ArrayRef<TemplateArgument> TemplateArgs = {},
1303913039
sema::TemplateDeductionInfo *DeductionInfo = nullptr);
1304013040

1304113041
InstantiatingTemplate(const InstantiatingTemplate &) = delete;

clang/include/clang/Sema/SemaObjC.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ class SemaObjC : public SemaBase {
350350
ObjCInterfaceDecl *ID);
351351

352352
Decl *ActOnAtEnd(Scope *S, SourceRange AtEnd,
353-
ArrayRef<Decl *> allMethods = std::nullopt,
354-
ArrayRef<DeclGroupPtrTy> allTUVars = std::nullopt);
353+
ArrayRef<Decl *> allMethods = {},
354+
ArrayRef<DeclGroupPtrTy> allTUVars = {});
355355

356356
struct ObjCArgInfo {
357357
IdentifierInfo *Name;

clang/include/clang/Sema/SemaOpenACC.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class SemaOpenACC : public SemaBase {
172172
"Parsed clause kind does not have a queue id expr list");
173173

174174
if (std::holds_alternative<std::monostate>(Details))
175-
return ArrayRef<Expr *>{std::nullopt};
175+
return ArrayRef<Expr *>();
176176

177177
return std::get<WaitDetails>(Details).QueueIdExprs;
178178
}

0 commit comments

Comments
 (0)