[PATCH] D53372: [clang-tidy] Resolve readability-else-after-return false positive for constexpr if.
Marek Kurdej via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 18 02:01:48 PDT 2018
curdeius added a comment.
In https://reviews.llvm.org/D53372#1267728, @lebedev.ri wrote:
> I think it would be good to add some more explanation as to *why* that `else` has to be kept.
Do you mean add a comment in the code or just an explanation for the review?
For the latter, e.g.:
// unrelated types:
struct type_a {};
struct type_b {};
auto f()
{
if constexpr(condition)
{
return type_a{};
}
else
{
return type_b{};
}
}
In this case removing else will just provoke a compilation error. There may be some cases where you may remove else though.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D53372
More information about the cfe-commits
mailing list