aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorJay Foad <jay.foad@amd.com>2024-10-24 10:23:40 +0100
committerGitHub <noreply@github.com>2024-10-24 10:23:40 +0100
commit4dd55c567aaed30c6842812e0798a70fee324c98 (patch)
tree832c5f53b744938b73f6484e3acde01bb1972677 /clang/lib/Sema/SemaInit.cpp
parente37d736def5b95a2710f92881b5fc8b0494d8a05 (diff)
downloadllvm-4dd55c567aaed30c6842812e0798a70fee324c98.zip
llvm-4dd55c567aaed30c6842812e0798a70fee324c98.tar.gz
llvm-4dd55c567aaed30c6842812e0798a70fee324c98.tar.bz2
[clang] Use {} instead of std::nullopt to initialize empty ArrayRef (#109399)
Follow up to #109133.
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index f560865..573e90a 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -569,7 +569,7 @@ ExprResult InitListChecker::PerformEmptyInit(SourceLocation Loc,
true);
MultiExprArg SubInit;
Expr *InitExpr;
- InitListExpr DummyInitList(SemaRef.Context, Loc, std::nullopt, Loc);
+ InitListExpr DummyInitList(SemaRef.Context, Loc, {}, Loc);
// C++ [dcl.init.aggr]p7:
// If there are fewer initializer-clauses in the list than there are
@@ -588,10 +588,9 @@ ExprResult InitListChecker::PerformEmptyInit(SourceLocation Loc,
//
// Only do this if we're initializing a class type, to avoid filling in
// the initializer list where possible.
- InitExpr = VerifyOnly
- ? &DummyInitList
- : new (SemaRef.Context)
- InitListExpr(SemaRef.Context, Loc, std::nullopt, Loc);
+ InitExpr = VerifyOnly ? &DummyInitList
+ : new (SemaRef.Context)
+ InitListExpr(SemaRef.Context, Loc, {}, Loc);
InitExpr->setType(SemaRef.Context.VoidTy);
SubInit = InitExpr;
Kind = InitializationKind::CreateCopy(Loc, Loc);
@@ -3403,7 +3402,7 @@ InitListChecker::createInitListExpr(QualType CurrentObjectType,
SourceRange InitRange,
unsigned ExpectedNumInits) {
InitListExpr *Result = new (SemaRef.Context) InitListExpr(
- SemaRef.Context, InitRange.getBegin(), std::nullopt, InitRange.getEnd());
+ SemaRef.Context, InitRange.getBegin(), {}, InitRange.getEnd());
QualType ResultType = CurrentObjectType;
if (!ResultType->isArrayType())
@@ -5650,7 +5649,7 @@ static void TryDefaultInitialization(Sema &S,
// constructor for T is called (and the initialization is ill-formed if
// T has no accessible default constructor);
if (DestType->isRecordType() && S.getLangOpts().CPlusPlus) {
- TryConstructorInitialization(S, Entity, Kind, std::nullopt, DestType,
+ TryConstructorInitialization(S, Entity, Kind, {}, DestType,
Entity.getType(), Sequence);
return;
}
@@ -5687,11 +5686,13 @@ static void TryOrBuildParenListInitialization(
const InitializationKind &SubKind,
Expr *Arg, Expr **InitExpr = nullptr) {
InitializationSequence IS = InitializationSequence(
- S, SubEntity, SubKind, Arg ? MultiExprArg(Arg) : std::nullopt);
+ S, SubEntity, SubKind,
+ Arg ? MultiExprArg(Arg) : MutableArrayRef<Expr *>());
if (IS.Failed()) {
if (!VerifyOnly) {
- IS.Diagnose(S, SubEntity, SubKind, Arg ? ArrayRef(Arg) : std::nullopt);
+ IS.Diagnose(S, SubEntity, SubKind,
+ Arg ? ArrayRef(Arg) : ArrayRef<Expr *>());
} else {
Sequence.SetFailed(
InitializationSequence::FK_ParenthesizedListInitFailed);
@@ -5702,7 +5703,7 @@ static void TryOrBuildParenListInitialization(
if (!VerifyOnly) {
ExprResult ER;
ER = IS.Perform(S, SubEntity, SubKind,
- Arg ? MultiExprArg(Arg) : std::nullopt);
+ Arg ? MultiExprArg(Arg) : MutableArrayRef<Expr *>());
if (ER.isInvalid())
return false;