Skip to content

Commit 95b423e

Browse files
committed
[Sema] NFC. Simplify code in a few places of TryOrBuildParenListInitialization
1 parent ffabf73 commit 95b423e

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

clang/lib/Sema/SemaInit.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "clang/Sema/EnterExpressionEvaluationContext.h"
2626
#include "clang/Sema/Initialization.h"
2727
#include "clang/Sema/Lookup.h"
28+
#include "clang/Sema/Ownership.h"
2829
#include "clang/Sema/SemaInternal.h"
2930
#include "llvm/ADT/APInt.h"
3031
#include "llvm/ADT/FoldingSet.h"
@@ -5429,18 +5430,12 @@ static void TryOrBuildParenListInitialization(
54295430
auto HandleInitializedEntity = [&](const InitializedEntity &SubEntity,
54305431
const InitializationKind &SubKind,
54315432
Expr *Arg, Expr **InitExpr = nullptr) {
5432-
InitializationSequence IS = [&]() {
5433-
if (Arg)
5434-
return InitializationSequence(S, SubEntity, SubKind, Arg);
5435-
return InitializationSequence(S, SubEntity, SubKind, std::nullopt);
5436-
}();
5433+
InitializationSequence IS = InitializationSequence(
5434+
S, SubEntity, SubKind, Arg ? MultiExprArg(Arg) : std::nullopt);
54375435

54385436
if (IS.Failed()) {
54395437
if (!VerifyOnly) {
5440-
if (Arg)
5441-
IS.Diagnose(S, SubEntity, SubKind, Arg);
5442-
else
5443-
IS.Diagnose(S, SubEntity, SubKind, std::nullopt);
5438+
IS.Diagnose(S, SubEntity, SubKind, Arg ? ArrayRef(Arg) : std::nullopt);
54445439
} else {
54455440
Sequence.SetFailed(
54465441
InitializationSequence::FK_ParenthesizedListInitFailed);
@@ -5450,10 +5445,8 @@ static void TryOrBuildParenListInitialization(
54505445
}
54515446
if (!VerifyOnly) {
54525447
ExprResult ER;
5453-
if (Arg)
5454-
ER = IS.Perform(S, SubEntity, SubKind, Arg);
5455-
else
5456-
ER = IS.Perform(S, SubEntity, SubKind, std::nullopt);
5448+
ER = IS.Perform(S, SubEntity, SubKind,
5449+
Arg ? MultiExprArg(Arg) : std::nullopt);
54575450
if (InitExpr)
54585451
*InitExpr = ER.get();
54595452
else

0 commit comments

Comments
 (0)