[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 16 10:28:18 PST 2017
aaron.ballman added inline comments.
================
Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:60
+ auto Diag =
+ diag(Loc, "use braced initializer list for constructing return types");
+
----------------
This diagnostic doesn't really tell the user what's wrong with the code. Why is a braced init list better than another kind of initialization expression? Perhaps: "to avoid repeating the return type from the declaration, use a braced initializer list instead" or something along those lines?
================
Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:62
+
+ auto CallParensRange = MatchedConstructExpr->getParenOrBraceRange();
+
----------------
Please do not use `auto` here, the type is not explicitly spelled out in the initialization.
================
Comment at: test/clang-tidy/modernize-return-braced-init-list.cpp:38
+ return Foo(b);
+}
----------------
We should probably have a test that ensures this code
```
[]() { return std::vector<int>({1, 2}); }();
```
does not get converted into this code
```
[]() { return {1, 2}; }();
```
Repository:
rL LLVM
https://reviews.llvm.org/D28768
More information about the cfe-commits
mailing list