[clang] [clang-tools-extra] [clang][NFC] Refactor `CXXNewExpr::InitializationStyle` (PR #71322)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 6 05:00:30 PST 2023
================
@@ -2034,18 +2035,19 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
// - If the new-initializer is omitted, the object is default-
// initialized (8.5); if no initialization is performed,
// the object has indeterminate value
- = initStyle == CXXNewExpr::NoInit
+ = initStyle == CXXNewInitializationStyle::None ||
+ initStyle == CXXNewInitializationStyle::Implicit
? InitializationKind::CreateDefault(TypeRange.getBegin())
- // - Otherwise, the new-initializer is interpreted according to
- // the
- // initialization rules of 8.5 for direct-initialization.
- : initStyle == CXXNewExpr::ListInit
- ? InitializationKind::CreateDirectList(
- TypeRange.getBegin(), Initializer->getBeginLoc(),
- Initializer->getEndLoc())
- : InitializationKind::CreateDirect(TypeRange.getBegin(),
- DirectInitRange.getBegin(),
- DirectInitRange.getEnd());
+ // - Otherwise, the new-initializer is interpreted according to
+ // the
+ // initialization rules of 8.5 for direct-initialization.
+ : initStyle == CXXNewInitializationStyle::List
+ ? InitializationKind::CreateDirectList(TypeRange.getBegin(),
+ Initializer->getBeginLoc(),
+ Initializer->getEndLoc())
+ : InitializationKind::CreateDirect(TypeRange.getBegin(),
+ DirectInitRange.getBegin(),
+ DirectInitRange.getEnd());
----------------
Endilll wrote:
Because `InitializationKind` doesn't have default constructor, I had to resort to immediately invoked lambda expression (IILE). I think it is an improvement, but I haven't seen IILE in Clang code base before, so I'm not sure.
https://github.com/llvm/llvm-project/pull/71322
More information about the cfe-commits
mailing list