[flang] Improvements suggested by Tim.

Original-commit: flang-compiler/f18@c3d2e3e745
Reviewed-on: https://github.com/flang-compiler/f18/pull/20
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2018-02-28 14:51:45 -08:00
parent 07a028098f
commit 601e0acdeb
3 changed files with 18 additions and 2 deletions

View file

@ -77,6 +77,11 @@ the end of the line, not on the next line. Functions also put the opening
`{` after the formal arguments or new-style result type, not on the next
line. Use `{}` for empty inline constructors and destructors in classes.
If any branch of an `if`/`else if`/`else` cascade ends with a return statement,
they all should, with the understanding that the cases are all unexceptional.
When testing for an error case that should cause an early return, do so with
an `if` that doesn't have a following `else`.
Don't waste space on the screen with needless blank lines or elaborate block
commentary (lines of dashes, boxes of asterisks, &c.). Write code so as to be
easily read and understood with a minimum of scrolling.

View file

@ -131,6 +131,7 @@ std::ostream &formatTuple(std::ostream &o, const T &x) {
if constexpr (J < std::tuple_size_v<T>) {
return formatTuple<J + 1>(o << std::get<J>(x), x);
}
return o;
}
template<typename... As>

View file

@ -73,11 +73,21 @@ Walk(const A &x, V &visitor) {
template<typename A, typename V>
typename std::enable_if<TupleTrait<A>>::type
Walk(const A &x, V &visitor) { Walk(x.t, visitor); }
Walk(const A &x, V &visitor) {
if (visitor.Pre(x)) {
Walk(x.t, visitor);
visitor.Post(x);
}
}
template<typename A, typename V>
typename std::enable_if<UnionTrait<A>>::type
Walk(const A &x, V &visitor) { Walk(x.u, visitor); }
Walk(const A &x, V &visitor) {
if (visitor.Pre(x)) {
Walk(x.u, visitor);
visitor.Post(x);
}
}
template<typename A, typename V>
typename std::enable_if<WrapperTrait<A>>::type