[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 9 08:08:05 PST 2017
alexfh added a comment.
Please mark all addressed comments "Done".
================
Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:60
+ // Make sure that the return type matches the constructed type.
+ const QualType returnType =
+ MatchedFunctionDecl->getReturnType().getCanonicalType();
----------------
Please follow LLVM naming conventions (variables should StartWithUpperCase).
================
Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:72
+ for (Decl *D :
+ MatchedConstructExpr->getConstructor()->getAsFunction()->decls()) {
+ if (const auto *VD = dyn_cast<VarDecl>(D)) {
----------------
1. `getAsFunction()` is not needed, `CXXConstructorDecl` derives from `FunctionDecl`
2. A simple loop from `0` to `getNumParams() ` would make it easier to see that the code is correct
3. s/i/I/
================
Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:93
+ << FixItHint::CreateReplacement(
+ CharSourceRange::getTokenRange(CallParensRange.getBegin(),
+ CallParensRange.getBegin()),
----------------
`SourceRange` is implicitly constructible from `SourceLocation`, so you need to supply the same location twice. Same below.
Repository:
rL LLVM
https://reviews.llvm.org/D28768
More information about the cfe-commits
mailing list