The checker removes consts that are superfluos and badly affect
readability. decltype(auto)/decltype(expr) are often const-qualified, but
have no effect on readability and usually can't stop being const-qualified
without significant code change.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I think we don't need to update the docs
(https://clang.llvm.org/extra/clang-tidy/checks/readability-const-return-type.html)
Because a user would expect this behaviour.
If this review is eventually approved, kindly please merge the commit on my behalf =) As I don't have merge access. My name is Evgeny Shulgin and email is izaronplatz@gmail.com. Sorry for inconvenience!
You've submitted some quality patches already, would you be interested in obtaining commit privileges (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access)?
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp | ||
---|---|---|
56–58 | I think we might as well hit all the local qualifiers instead of just const, WDYT? e.g., volatile et al via hasLocalQualifiers() | |
111 | We don't usually use top-level const qualification for locals. | |
112 | How about a TypeOfType? (The GCC typeof(foo) extension) |
You've submitted some quality patches already, would you be interested in obtaining commit privileges (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access)?
Thanks! I obtained the commit access =) Now I don't have to ask other peoples commit on my behalf.
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp | ||
---|---|---|
56–58 | In this case the checker will complain on this code: const int i = 1; volatile decltype(i) n() { return 12345; } warning: return type 'volatile decltype(i)' (aka 'const volatile int') is 'const'-qualified at the top level, which may reduce code readability without improving const correctness [readability-const-return-type] That wouldn't be the correct outcome. I added the test for the snippet above. | |
112 | Thanks! Didn't know about this extension. Now the checker filters this out. |
LGTM!
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp | ||
---|---|---|
56–58 | Great, thank you! |
I think we might as well hit all the local qualifiers instead of just const, WDYT? e.g., volatile et al via hasLocalQualifiers()