@@ -546,11 +546,21 @@ void CodeGenerator::InsertArg(const WhileStmt* stmt)
546546
547547// / Get the name of a \c FieldDecl in case this \c FieldDecl is part of a lambda. The name has to be retrieved from the
548548// / capture fields or can be \c __this.
549- static Optional<std::string> GetFieldDeclNameForLambda (const FieldDecl& fieldDecl, const CXXRecordDecl& cxxRecordDecl)
549+ static std::optional<std::string> GetFieldDeclNameForLambda (const FieldDecl& fieldDecl,
550+ const CXXRecordDecl& cxxRecordDecl)
550551{
551552 if (cxxRecordDecl.isLambda ()) {
552- llvm::DenseMap<const VarDecl*, FieldDecl*> captures{};
553- FieldDecl* thisCapture{};
553+ llvm::DenseMap<const
554+ #if IS_CLANG_NEWER_THAN(15)
555+ ValueDecl*
556+ #else
557+ VarDecl*
558+ #endif
559+ ,
560+ FieldDecl*>
561+ captures{};
562+
563+ FieldDecl* thisCapture{};
554564
555565 cxxRecordDecl.getCaptureFields (captures, thisCapture);
556566
@@ -608,7 +618,7 @@ void CodeGenerator::InsertArg(const MemberExpr* stmt)
608618 else if (const auto * fd = dyn_cast_or_null<FieldDecl>(meDecl)) {
609619 if (const auto * cxxRecordDecl = dyn_cast_or_null<CXXRecordDecl>(fd->getParent ())) {
610620 if (const auto & fieldName = GetFieldDeclNameForLambda (*fd, *cxxRecordDecl)) {
611- return fieldName.getValue ();
621+ return fieldName.value ();
612622 }
613623 }
614624 }
@@ -2105,7 +2115,7 @@ void CodeGenerator::InsertArg(const CXXNewExpr* stmt)
21052115 CodeGenerator codeGenerator{ofm};
21062116
21072117 ofm.Append (" [" sv);
2108- codeGenerator.InsertArg (stmt->getArraySize ().getValue ());
2118+ codeGenerator.InsertArg (stmt->getArraySize ().value ());
21092119 ofm.Append (' ]' );
21102120
21112121 // In case of multi dimension the first dimension is the getArraySize() while the others are part of the
@@ -2761,7 +2771,7 @@ void CodeGenerator::InsertArg(const FieldDecl* stmt)
27612771 std::string name{GetName (*stmt)};
27622772
27632773 if (const auto fieldName = GetFieldDeclNameForLambda (*stmt, *cxxRecordDecl)) {
2764- name = std::move (fieldName.getValue ());
2774+ name = std::move (fieldName.value ());
27652775 }
27662776
27672777 mOutputFormatHelper .Append (GetTypeNameAsParameter (stmt->getType (), name));
@@ -3228,11 +3238,11 @@ void CodeGenerator::InsertArg(const CXXRecordDecl* stmt)
32283238
32293239 mCurrentFieldPos = mOutputFormatHelper .CurrentPos ();
32303240
3231- OnceTrue firstRecordDecl{};
3232- OnceTrue firstDecl{};
3233- Decl::Kind formerKind{};
3234- llvm::Optional <size_t > insertPosBeforeCtor{};
3235- AccessSpecifier lastAccess{stmt->isClass () ? AS_private : AS_public};
3241+ OnceTrue firstRecordDecl{};
3242+ OnceTrue firstDecl{};
3243+ Decl::Kind formerKind{};
3244+ std::optional <size_t > insertPosBeforeCtor{};
3245+ AccessSpecifier lastAccess{stmt->isClass () ? AS_private : AS_public};
32363246 for (const auto * d : stmt->decls ()) {
32373247 if (isa<CXXRecordDecl>(d) and firstRecordDecl) {
32383248 continue ;
@@ -3261,7 +3271,7 @@ void CodeGenerator::InsertArg(const CXXRecordDecl* stmt)
32613271
32623272 InsertArg (d);
32633273
3264- if (lastAccess == AS_public and not insertPosBeforeCtor.hasValue ()) {
3274+ if (lastAccess == AS_public and not insertPosBeforeCtor.has_value ()) {
32653275 insertPosBeforeCtor = mOutputFormatHelper .CurrentPos ();
32663276 }
32673277
@@ -3409,14 +3419,7 @@ void CodeGenerator::InsertArg(const CXXRecordDecl* stmt)
34093419 CodeGenerator codeGenerator{ofm, LambdaInInitCapture::Yes};
34103420 codeGenerator.InsertArg (expr);
34113421
3412- mOutputFormatHelper .InsertAt (insertPosBeforeCtor.
3413- #if IS_CLANG_NEWER_THAN(14)
3414- value_or
3415- #else
3416- getValueOr
3417- #endif
3418- (-1 ),
3419- ofm);
3422+ mOutputFormatHelper .InsertAt (insertPosBeforeCtor.value_or (-1 ), ofm);
34203423 }
34213424 } else {
34223425 if (isThis and not fieldDeclType->isPointerType ()) {
@@ -3429,8 +3432,16 @@ void CodeGenerator::InsertArg(const CXXRecordDecl* stmt)
34293432 mOutputFormatHelper .Append (GetTypeNameAsParameter (fieldDeclType, StrCat (" _" sv, name)));
34303433 };
34313434
3432- llvm::DenseMap<const VarDecl*, FieldDecl*> captures{};
3433- FieldDecl* thisCapture{};
3435+ llvm::DenseMap<const
3436+ #if IS_CLANG_NEWER_THAN(15)
3437+ ValueDecl*
3438+ #else
3439+ VarDecl*
3440+ #endif
3441+ ,
3442+ FieldDecl*>
3443+ captures{};
3444+ FieldDecl* thisCapture{};
34343445
34353446 stmt->getCaptureFields (captures, thisCapture);
34363447
@@ -3451,8 +3462,15 @@ void CodeGenerator::InsertArg(const CXXRecordDecl* stmt)
34513462
34523463 const auto * capturedVar = c.getCapturedVar ();
34533464 if (const auto * value = captures[capturedVar]) {
3454- addToInits (
3455- GetName (*capturedVar), value, false , cinit, VarDecl::ListInit == capturedVar->getInitStyle ());
3465+ addToInits (GetName (*capturedVar),
3466+ value,
3467+ false ,
3468+ cinit,
3469+ #if IS_CLANG_NEWER_THAN(15)
3470+ VarDecl::ListInit == dyn_cast_or_null<VarDecl>(capturedVar)->getInitStyle ());
3471+ #else
3472+ VarDecl::ListInit == capturedVar->getInitStyle ());
3473+ #endif
34563474 }
34573475 }
34583476
@@ -3630,7 +3648,11 @@ void CodeGenerator::InsertArg(const RequiresExpr* stmt)
36303648 } else if (const auto * nestedRequirement = dyn_cast_or_null<concepts::NestedRequirement>(requirement)) {
36313649 mOutputFormatHelper .Append (kwRequiresSpace);
36323650
3651+ #if IS_CLANG_NEWER_THAN(15)
3652+ if (nestedRequirement->hasInvalidConstraint ()) {
3653+ #else
36333654 if (nestedRequirement->isSubstitutionFailure ()) {
3655+ #endif
36343656 // The requirement failed. We need some way to express that. Using a nested
36353657 // requirement with false seems to be the simplest solution.
36363658 mOutputFormatHelper .Append (" false" );
@@ -3655,34 +3677,17 @@ void CodeGenerator::InsertArg(const CXXDefaultArgExpr* stmt)
36553677void CodeGenerator::InsertArg (const CXXStdInitializerListExpr* stmt)
36563678{
36573679 if (GetInsightsOptions ().UseShowInitializerList ) {
3658- RETURN_IF (not mCurrentPos .hasValue () and not mCurrentFieldPos .hasValue () and not mCurrentReturnPos .hasValue ());
3680+ RETURN_IF (not mCurrentPos .has_value () and not mCurrentFieldPos .has_value () and
3681+ not mCurrentReturnPos .has_value ());
36593682
36603683 std::string modifiers{};
3661- size_t variableInsertPos = mCurrentReturnPos .
3662- #if IS_CLANG_NEWER_THAN(14)
3663- value_or
3664- #else
3665- getValueOr
3666- #endif
3667- (mCurrentPos .
3668- #if IS_CLANG_NEWER_THAN(14)
3669- value_or
3670- #else
3671- getValueOr
3672- #endif
3673- (0 ));
3684+ size_t variableInsertPos = mCurrentReturnPos .value_or (mCurrentPos .value_or (0 ));
36743685
36753686 auto & ofmToInsert = [&]() -> decltype (auto ) {
3676- if (not mCurrentPos .hasValue () and not mCurrentReturnPos .hasValue ()) {
3677- variableInsertPos = mCurrentFieldPos .
3678- #if IS_CLANG_NEWER_THAN(14)
3679- value_or
3680- #else
3681- getValueOr
3682- #endif
3683- (0 );
3684- mCurrentPos = variableInsertPos;
3685- modifiers = StrCat (kwStaticSpace, kwInlineSpace);
3687+ if (not mCurrentPos .has_value () and not mCurrentReturnPos .has_value ()) {
3688+ variableInsertPos = mCurrentFieldPos .value_or (0 );
3689+ mCurrentPos = variableInsertPos;
3690+ modifiers = StrCat (kwStaticSpace, kwInlineSpace);
36863691 return (*mOutputFormatHelperOutside );
36873692 }
36883693
@@ -3716,10 +3721,10 @@ void CodeGenerator::InsertArg(const CXXStdInitializerListExpr* stmt)
37163721 mOutputFormatHelper .Append (
37173722 GetName (stmt->getType (), Unqualified::Yes), " {" sv, internalListName, " , " sv, size, " }" sv);
37183723
3719- if (mCurrentReturnPos .hasValue ()) {
3720- mCurrentReturnPos = mCurrentReturnPos .getValue () + ofm.size ();
3724+ if (mCurrentReturnPos .has_value ()) {
3725+ mCurrentReturnPos = mCurrentReturnPos .value () + ofm.size ();
37213726 } else {
3722- mCurrentPos = mCurrentPos .getValue () + ofm.size ();
3727+ mCurrentPos = mCurrentPos .value () + ofm.size ();
37233728 }
37243729
37253730 } else {
0 commit comments