| 3213 | //----------------------------------------------------------------------------- |
| 3214 | |
| 3215 | void CodeGenerator::InsertCXXMethodHeader(const CXXMethodDecl* stmt, OutputFormatHelper& initOutputFormatHelper) |
| 3216 | { |
| 3217 | LAMBDA_SCOPE_HELPER(CXXMethodDecl); |
| 3218 | CXXConstructorDecl* cxxInheritedCtorDecl{nullptr}; |
| 3219 | |
| 3220 | // Traverse the ctor inline init statements first to find a potential CXXInheritedCtorInitExpr. This carries the |
| 3221 | // name and the type. The CXXMethodDecl above knows only the type. |
| 3222 | if(const auto* ctor = dyn_cast_or_null<CXXConstructorDecl>(stmt)) { |
| 3223 | CodeGeneratorVariant codeGenerator{initOutputFormatHelper, mLambdaStack, mProcessingPrimaryTemplate}; |
| 3224 | codeGenerator->mCurrentVarDeclPos = mCurrentVarDeclPos; |
| 3225 | codeGenerator->mCurrentFieldPos = mCurrentFieldPos; |
| 3226 | codeGenerator->mCurrentCallExprPos = mCurrentCallExprPos; |
| 3227 | codeGenerator->mOutputFormatHelperOutside = &mOutputFormatHelper; |
| 3228 | |
| 3229 | for(OnceTrue first{}; const auto* init : ctor->inits()) { |
| 3230 | initOutputFormatHelper.AppendNewLine(); |
| 3231 | if(first) { |
| 3232 | initOutputFormatHelper.Append(": "sv); |
| 3233 | } else { |
| 3234 | initOutputFormatHelper.Append(", "sv); |
| 3235 | } |
| 3236 | |
| 3237 | // in case of delegating or base initializer there is no member. |
| 3238 | #if 0 |
| 3239 | if(const auto* member = init->getMember()) { |
| 3240 | initOutputFormatHelper.Append(member->getName()); |
| 3241 | codeGenerator->InsertCurlysIfRequired(init->getInit()); |
| 3242 | } else { |
| 3243 | const auto* inlineInit = init->getInit(); |
| 3244 | bool useCurlies{false}; |
| 3245 | |
| 3246 | if(const auto* cxxInheritedCtorInitExpr = dyn_cast_or_null<CXXInheritedCtorInitExpr>(inlineInit)) { |
| 3247 | cxxInheritedCtorDecl = cxxInheritedCtorInitExpr->getConstructor(); |
| 3248 | |
| 3249 | // Insert the base class name only, if it is not a CXXContructorExpr and not a |
| 3250 | // CXXDependentScopeMemberExpr which already carry the type. |
| 3251 | } else if(init->isBaseInitializer() and not isa<CXXConstructExpr>(inlineInit)) { |
| 3252 | initOutputFormatHelper.Append(GetUnqualifiedScopelessName(init->getBaseClass())); |
| 3253 | useCurlies = true; |
| 3254 | } |
| 3255 | |
| 3256 | codeGenerator->WrapInCurliesIfNeeded(useCurlies, [&] { codeGenerator->InsertArg(inlineInit); }); |
| 3257 | } |
| 3258 | #else |
| 3259 | const auto* inlineInit = init->getInit(); |
| 3260 | |
| 3261 | // in case of delegating or base initializer there is no member. |
| 3262 | if(const auto* member = init->getMember()) { |
| 3263 | initOutputFormatHelper.Append(member->getName()); |
| 3264 | |
| 3265 | if(isa<ParenListExpr>(inlineInit)) { |
| 3266 | codeGenerator->WrapInParens([&] { codeGenerator->InsertArg(inlineInit); }); |
| 3267 | } else { |
| 3268 | codeGenerator->InsertCurlysIfRequired(inlineInit); |
| 3269 | } |
| 3270 | |
| 3271 | } else if(const auto* cxxInheritedCtorInitExpr = dyn_cast_or_null<CXXInheritedCtorInitExpr>(inlineInit)) { |
| 3272 | cxxInheritedCtorDecl = cxxInheritedCtorInitExpr->getConstructor(); |
nothing calls this directly
no test coverage detected