[flang-commits] [flang] [flang] Visit "source" member in all AST nodes (PR #175211)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Fri Jan 9 09:34:42 PST 2026
https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/175211
Some AST nodes had their "source" member visited by the parse tree visitor, while others, in particular those that were handled by the trait-based visitors, did not.
Make sure that we call the Walk function on the "source" member for all classes that have it.
>From 9ef06e86161fbc4c84a68ea419d1a4ebd83ebe36 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Fri, 9 Jan 2026 11:23:35 -0600
Subject: [PATCH] [flang] Visit "source" member in all AST nodes
Some AST nodes had their "source" member visited by the parse tree
visitor, while others, in particular those that were handled by the
trait-based visitors, did not.
Make sure that we call the Walk function on the "source" member for
all classes that have it.
---
.../include/flang/Parser/parse-tree-visitor.h | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/flang/include/flang/Parser/parse-tree-visitor.h b/flang/include/flang/Parser/parse-tree-visitor.h
index 67f5481144c52..fd30edff06cbe 100644
--- a/flang/include/flang/Parser/parse-tree-visitor.h
+++ b/flang/include/flang/Parser/parse-tree-visitor.h
@@ -10,6 +10,7 @@
#define FORTRAN_PARSER_PARSE_TREE_VISITOR_H_
#include "parse-tree.h"
+#include "tools.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/visit.h"
#include <cstddef>
@@ -168,12 +169,18 @@ struct ParseTreeVisitorLookupScope {
template <typename A, typename V>
static std::enable_if_t<EmptyTrait<A>> Walk(const A &x, V &visitor) {
if (visitor.Pre(x)) {
+ if constexpr (HasSource<A>::value) {
+ Walk(x.source, visitor);
+ }
visitor.Post(x);
}
}
template <typename A, typename M>
static std::enable_if_t<EmptyTrait<A>> Walk(A &x, M &mutator) {
if (mutator.Pre(x)) {
+ if constexpr (HasSource<A>::value) {
+ Walk(x.source, mutator);
+ }
mutator.Post(x);
}
}
@@ -182,6 +189,9 @@ struct ParseTreeVisitorLookupScope {
static std::enable_if_t<TupleTrait<A>> Walk(const A &x, V &visitor) {
if (visitor.Pre(x)) {
Walk(x.t, visitor);
+ if constexpr (HasSource<A>::value) {
+ Walk(x.source, visitor);
+ }
visitor.Post(x);
}
}
@@ -189,6 +199,9 @@ struct ParseTreeVisitorLookupScope {
static std::enable_if_t<TupleTrait<A>> Walk(A &x, M &mutator) {
if (mutator.Pre(x)) {
Walk(x.t, mutator);
+ if constexpr (HasSource<A>::value) {
+ Walk(x.source, mutator);
+ }
mutator.Post(x);
}
}
@@ -197,6 +210,9 @@ struct ParseTreeVisitorLookupScope {
static std::enable_if_t<UnionTrait<A>> Walk(const A &x, V &visitor) {
if (visitor.Pre(x)) {
Walk(x.u, visitor);
+ if constexpr (HasSource<A>::value) {
+ Walk(x.source, visitor);
+ }
visitor.Post(x);
}
}
@@ -204,6 +220,9 @@ struct ParseTreeVisitorLookupScope {
static std::enable_if_t<UnionTrait<A>> Walk(A &x, M &mutator) {
if (mutator.Pre(x)) {
Walk(x.u, mutator);
+ if constexpr (HasSource<A>::value) {
+ Walk(x.source, mutator);
+ }
mutator.Post(x);
}
}
@@ -212,6 +231,9 @@ struct ParseTreeVisitorLookupScope {
static std::enable_if_t<WrapperTrait<A>> Walk(const A &x, V &visitor) {
if (visitor.Pre(x)) {
Walk(x.v, visitor);
+ if constexpr (HasSource<A>::value) {
+ Walk(x.source, visitor);
+ }
visitor.Post(x);
}
}
@@ -219,6 +241,9 @@ struct ParseTreeVisitorLookupScope {
static std::enable_if_t<WrapperTrait<A>> Walk(A &x, M &mutator) {
if (mutator.Pre(x)) {
Walk(x.v, mutator);
+ if constexpr (HasSource<A>::value) {
+ Walk(x.source, mutator);
+ }
mutator.Post(x);
}
}
@@ -227,6 +252,9 @@ struct ParseTreeVisitorLookupScope {
static std::enable_if_t<ConstraintTrait<A>> Walk(const A &x, V &visitor) {
if (visitor.Pre(x)) {
Walk(x.thing, visitor);
+ if constexpr (HasSource<A>::value) {
+ Walk(x.source, visitor);
+ }
visitor.Post(x);
}
}
@@ -234,6 +262,9 @@ struct ParseTreeVisitorLookupScope {
static std::enable_if_t<ConstraintTrait<A>> Walk(A &x, M &mutator) {
if (mutator.Pre(x)) {
Walk(x.thing, mutator);
+ if constexpr (HasSource<A>::value) {
+ Walk(x.source, mutator);
+ }
mutator.Post(x);
}
}
More information about the flang-commits
mailing list