[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 12 06:13:43 PST 2017
aaron.ballman added a comment.
I found a few more small nits, but basically LGTM.
================
Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:70
+
+ for (int I = 0, NumParams = MatchedFunctionDecl->getNumParams();
+ I < NumParams; ++I) {
----------------
`I` should be `unsigned` rather than `int`.
================
Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:80-85
+ const SourceRange CallParensRange =
+ MatchedConstructExpr->getParenOrBraceRange();
+
+ // Return if there is no explicit constructor call.
+ if (CallParensRange.isInvalid())
+ return;
----------------
This could be hoisted above the `for` loop to early return while doing less work.
================
Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:88
+ // Range for constructor name and opening brace.
+ auto CtorCallSourceRange = CharSourceRange::getTokenRange(
+ Loc, CallParensRange.getBegin().getLocWithOffset(-1));
----------------
Not keen on this use of `auto`, as the type is not spelled out in the initialization.
Repository:
rL LLVM
https://reviews.llvm.org/D28768
More information about the cfe-commits
mailing list