================ @@ -0,0 +1,252 @@ +#ifndef LLVM_CLANG_AST_DYNAMIC_RECURSIVE_AST_VISITOR_H +#define LLVM_CLANG_AST_DYNAMIC_RECURSIVE_AST_VISITOR_H + +#include "clang/AST/Attr.h" +#include "clang/AST/ExprConcepts.h" +#include "clang/AST/TypeLoc.h" + +namespace clang { +class ASTContext; + +/// Recursive AST visitor that supports extension via dynamic dispatch. +/// +/// This only supports some of the more common visitation operations; in +/// particular, it does not support overriding WalkUpFromX or post-order +/// traversal. +/// +/// Features that are currently not supported: +/// +/// - Visiting attributes +/// - Post-order traversal +/// - Overriding WalkUpFromX +/// - Overriding getStmtChildren() +/// +/// \see RecursiveASTVisitor +class DynamicRecursiveASTVisitor { +public: + /// Whether this visitor should recurse into template instantiations. + bool ShouldVisitTemplateInstantiations = false; + + /// Whether this visitor should recurse into the types of TypeLocs. + bool ShouldWalkTypesOfTypeLocs = true; + + /// Whether this visitor should recurse into implicit code, e.g. + /// implicit constructors and destructors. + bool ShouldVisitImplicitCode = false; + + /// Whether this visitor should recurse into lambda body + bool ShouldVisitLambdaBody = true; + +protected: + DynamicRecursiveASTVisitor() = default; + +public: + virtual void anchor(); + + // Copying/moving a polymorphic type is a bad idea. + DynamicRecursiveASTVisitor(DynamicRecursiveASTVisitor &&) = delete; + DynamicRecursiveASTVisitor(const DynamicRecursiveASTVisitor &) = delete; + DynamicRecursiveASTVisitor &operator=(DynamicRecursiveASTVisitor &&) = delete; + DynamicRecursiveASTVisitor & + operator=(const DynamicRecursiveASTVisitor &) = delete; ---------------- zyn0217 wrote:
Sorry for being dense, but can you explain why this is a bad idea? We allow copying/moving an RAV, right? (I might be wrong, because I hardly remember I've copied/moved an RAV) https://github.com/llvm/llvm-project/pull/105195 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits