@@ -149,9 +149,22 @@ class ASTWalker {
149
149
// / A namespace for ASTWalker actions that may be returned from pre-walk and
150
150
// / post-walk functions.
151
151
// /
152
- // / Each action returns a separate underscored type, which is then consumed
153
- // / by PreWalkAction/PreWalkResult/PostWalkAction/PostWalkAction. It is
154
- // / designed this way to achieve a pseudo form of return type overloading,
152
+ // / Only certain AST nodes support being replaced during a walk. The
153
+ // / visitation methods for such nodes use the PreWalkResult/PostWalkResult
154
+ // / types, which store both the action to take, along with the AST node to
155
+ // / splice into the tree in place of the old node. The node must be provided
156
+ // / to \c Action::<action> function, e.g \c Action::Continue(E) or
157
+ // / \c Action::SkipChildren(E). The only exception is \c Action::Stop(),
158
+ // / which never accepts a node.
159
+ // /
160
+ // / AST nodes that do not support being replaced during a walk use visitation
161
+ // / methods that return PreWalkAction/PostWalkAction. These just store the
162
+ // / walking action to perform, and you return e.g \c Action::Continue() or
163
+ // / \c Action::SkipChildren().
164
+ // /
165
+ // / Each function here returns a separate underscored type, which is then
166
+ // / consumed by PreWalkAction/PreWalkResult/PostWalkAction/PostWalkAction. It
167
+ // / is designed this way to achieve a pseudo form of return type overloading,
155
168
// / where e.g \c Action::Continue() can become either a pre-walk action or a
156
169
// / post-walk action, but \c Action::SkipChildren() can only become a pre-walk
157
170
// / action.
@@ -225,6 +238,9 @@ class ASTWalker {
225
238
};
226
239
227
240
// / Do not construct directly, use \c Action::<action> instead.
241
+ // /
242
+ // / A pre-visitation action for AST nodes that do not support being replaced
243
+ // / while walking.
228
244
struct PreWalkAction {
229
245
enum Kind { Stop, SkipChildren, Continue };
230
246
Kind Action;
@@ -242,6 +258,9 @@ class ASTWalker {
242
258
};
243
259
244
260
// / Do not construct directly, use \c Action::<action> instead.
261
+ // /
262
+ // / A post-visitation action for AST nodes that do not support being replaced
263
+ // / while walking.
245
264
struct PostWalkAction {
246
265
enum Kind { Stop, Continue };
247
266
Kind Action;
@@ -256,6 +275,10 @@ class ASTWalker {
256
275
};
257
276
258
277
// / Do not construct directly, use \c Action::<action> instead.
278
+ // /
279
+ // / A pre-visitation result for AST nodes that support being replaced while
280
+ // / walking. Stores both the walking action to take, along with the node to
281
+ // / splice into the AST in place of the old node.
259
282
template <typename T>
260
283
struct PreWalkResult {
261
284
PreWalkAction Action;
@@ -297,6 +320,10 @@ class ASTWalker {
297
320
};
298
321
299
322
// / Do not construct directly, use \c Action::<action> instead.
323
+ // /
324
+ // / A post-visitation result for AST nodes that support being replaced while
325
+ // / walking. Stores both the walking action to take, along with the node to
326
+ // / splice into the AST in place of the old node.
300
327
template <typename T>
301
328
struct PostWalkResult {
302
329
PostWalkAction Action;
0 commit comments