[flang-commits] [flang] [flang] Add traits to more AST nodes (PR #175566)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Fri Jan 16 12:30:32 PST 2026
================
@@ -433,38 +433,6 @@ struct ParseTreeVisitorLookupScope {
x, mutator);
}
- template <typename V> static void Walk(const CallStmt &x, V &visitor) {
----------------
kparzysz wrote:
The parse tree defines certain traits which then impose certain properties on AST classes with these traits. For example a class with a "TupleTrait" is expected to have a member named `t`, which is `std::tuple`. The parse-tree-visitor uses these traits to visit all members of a given AST node "generically", so for a class with a TupleTrait it will visit all members of `t`. This is completely generic and independent of the types contained in `t`.
Some AST classes don't follow that convention, and instead of using a tuple and getting a trait, they list members explicitly. For those classes there has to be a specific visitor which walks the members of that class.
This series of PRs converts the majority of the non-conforming classes to conform to the trait-based convention, so that the generic "Walk" functions can be used to visit them, instead of having the specialized ones.
For example
```
struct Foo {
A object;
B kind;
};
```
is converted to
```
struct Foo {
TUPLE_CLASS_BOILERPLATE(Foo); // adds the TupleTrait + other stuff
std::tuple<A, B> t;
};
```
https://github.com/llvm/llvm-project/pull/175566
More information about the flang-commits
mailing list