[clang-tools-extra] [clang-tidy][C++20] Add support for Initialization Forwarding in Nested Objects (PR #131969)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 28 03:14:37 PDT 2025
================
@@ -332,19 +380,44 @@ void UseEmplaceCheck::check(const MatchFinder::MatchResult &Result) {
}();
assert(Call && "No call matched");
- assert((CtorCall || MakeCall) && "No push_back parameter matched");
+ assert((CtorCall || MakeCall || AggInitCall) &&
+ "No push_back parameter matched");
if (IgnoreImplicitConstructors && CtorCall && CtorCall->getNumArgs() >= 1 &&
CtorCall->getArg(0)->getSourceRange() == CtorCall->getSourceRange())
return;
+ if (IgnoreImplicitConstructors && AggInitCall &&
+ AggInitCall->getNumInits() >= 1 &&
+ AggInitCall->getInit(0)->getSourceRange() ==
+ AggInitCall->getSourceRange())
+ return;
+
+ if (getLangOpts().LangStd >= LangStandard::lang_cxx20 && AggInitCall) {
+ for (const auto *Init : AggInitCall->inits()) {
+ if (const auto *InnermostInit = unwrapInnerExpression(Init)) {
----------------
vbvictor wrote:
As far as I understand, `unwrapInnerExpression` is only used to determine if `Expr` could unwrap to `CXXCtor`.
So there is maybe redundant `llvm::dyn_cast<CXXConstructExpr>(InnermostInit)`.
I could suggest renaming `unwrapInnerExpression` to `unwrapToConstructExpr` that will return either `nullptr` or `CXXConstructExpr*` so you don't have to `dyn_cast` one more time.
https://github.com/llvm/llvm-project/pull/131969
More information about the cfe-commits
mailing list