Skip to content

Commit

Permalink
[Sema] NFC. Simplify code in a few places of TryOrBuildParenListIniti…
Browse files Browse the repository at this point in the history
…alization
  • Loading branch information
ilya-biryukov committed Dec 22, 2023
1 parent ffabf73 commit 95b423e
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions clang/lib/Sema/SemaInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Ownership.h"
#include "clang/Sema/SemaInternal.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/FoldingSet.h"
Expand Down Expand Up @@ -5429,18 +5430,12 @@ static void TryOrBuildParenListInitialization(
auto HandleInitializedEntity = [&](const InitializedEntity &SubEntity,
const InitializationKind &SubKind,
Expr *Arg, Expr **InitExpr = nullptr) {
InitializationSequence IS = [&]() {
if (Arg)
return InitializationSequence(S, SubEntity, SubKind, Arg);
return InitializationSequence(S, SubEntity, SubKind, std::nullopt);
}();
InitializationSequence IS = InitializationSequence(
S, SubEntity, SubKind, Arg ? MultiExprArg(Arg) : std::nullopt);

if (IS.Failed()) {
if (!VerifyOnly) {
if (Arg)
IS.Diagnose(S, SubEntity, SubKind, Arg);
else
IS.Diagnose(S, SubEntity, SubKind, std::nullopt);
IS.Diagnose(S, SubEntity, SubKind, Arg ? ArrayRef(Arg) : std::nullopt);
} else {
Sequence.SetFailed(
InitializationSequence::FK_ParenthesizedListInitFailed);
Expand All @@ -5450,10 +5445,8 @@ static void TryOrBuildParenListInitialization(
}
if (!VerifyOnly) {
ExprResult ER;
if (Arg)
ER = IS.Perform(S, SubEntity, SubKind, Arg);
else
ER = IS.Perform(S, SubEntity, SubKind, std::nullopt);
ER = IS.Perform(S, SubEntity, SubKind,
Arg ? MultiExprArg(Arg) : std::nullopt);
if (InitExpr)
*InitExpr = ER.get();
else
Expand Down

0 comments on commit 95b423e

Please sign in to comment.