Adds a check to the Fuchsia module to warn if a function has a trailing return.
See https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md for reference.
Differential D42116
[clang-tidy] Adding Fuchsia checker for trailing returns juliehockett on Jan 16 2018, 10:41 AM. Authored by
Details Adds a check to the Fuchsia module to warn if a function has a trailing return. See https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md for reference.
Diff Detail
Event TimelineComment Actions Can you give some background on what problem the coding standard is trying to avoid by banning this? For instance, if trailing return types are bad, are deduced return types similarly bad, or are those fine?
Comment Actions The main concern is that of readability. Deduced return types can help readability, so those are okay (within reason). Comment Actions Thanks for the explanation. I'm a bit worried that this is going to diagnose reasonable C++11 code: template <typename T1, typename T2> auto fn(const T1 &lhs, const T2 &rhs) -> decltype(lhs + rhs) { return lhs + rhs; } Would it be a reasonable exception to the rule to allow a trailing return type so long as it's a decltype type specifier? Comment Actions Good point -- updating checker to allow trailing returns if the decltype specifier is used.
Comment Actions LGTM! If you felt so inclined, I would say those two AST matchers would both be reasonable candidates to add to ASTMatchers.h if you wanted to do that in a follow-up patch. |
s/which/that