[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'
Piotr Padlewski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 16 08:23:34 PST 2017
Prazek added a comment.
Thanks for the check. Have you run it on llvm?
================
Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:27-32
+ auto soughtConstructExpr =
+ cxxConstructExpr(unless(isListInitialization())).bind("ctor");
+
+ auto hasConstructExpr = has(ignoringImplicit(soughtConstructExpr));
+
+ auto ctorAsArgument = materializeTemporaryExpr(
----------------
Uppercase
================
Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:38
+ returns(recordType()), // We only care about record types.
+ hasDescendant(returnStmt(hasDescendant(ctorAsArgument))))
+ .bind("fn"),
----------------
Wouldn't
returnStmt(has(ctorAsArgument))
be sufficient?
or maybe
returnStmt(has(ignoringImplici(ctorAsArgument)))
hasDescendant is slow, and besides it probably match for cases like:
return fun(A(a, b, c));
where fun is call, and ctorAsArgument will match to A()
Repository:
rL LLVM
https://reviews.llvm.org/D28768
More information about the cfe-commits
mailing list