Index: include/clang/AST/ASTTypeTraits.h =================================================================== --- include/clang/AST/ASTTypeTraits.h +++ include/clang/AST/ASTTypeTraits.h @@ -38,6 +38,16 @@ namespace ast_type_traits { +/// Defines how we descend a level in the AST when we pass +/// through expressions. +enum TraversalKind { + /// Will traverse any child nodes. + TK_AsIs, + + /// Will not traverse implicit casts and parentheses. + TK_IgnoreImplicitCastsAndParentheses +}; + /// Kind identifier. /// /// It can be constructed from any node kind and allows for runtime type Index: include/clang/ASTMatchers/ASTMatchersInternal.h =================================================================== --- include/clang/ASTMatchers/ASTMatchersInternal.h +++ include/clang/ASTMatchers/ASTMatchersInternal.h @@ -950,15 +950,6 @@ /// all nodes, as all nodes have ancestors. class ASTMatchFinder { public: - /// Defines how we descend a level in the AST when we pass - /// through expressions. - enum TraversalKind { - /// Will traverse any child nodes. - TK_AsIs, - - /// Will not traverse implicit casts and parentheses. - TK_IgnoreImplicitCastsAndParentheses - }; /// Defines how bindings are processed on recursive matches. enum BindKind { @@ -992,7 +983,7 @@ bool matchesChildOf(const T &Node, const DynTypedMatcher &Matcher, BoundNodesTreeBuilder *Builder, - TraversalKind Traverse, + ast_type_traits::TraversalKind Traverse, BindKind Bind) { static_assert(std::is_base_of::value || std::is_base_of::value || @@ -1042,7 +1033,7 @@ virtual bool matchesChildOf(const ast_type_traits::DynTypedNode &Node, const DynTypedMatcher &Matcher, BoundNodesTreeBuilder *Builder, - TraversalKind Traverse, + ast_type_traits::TraversalKind Traverse, BindKind Bind) = 0; virtual bool matchesDescendantOf(const ast_type_traits::DynTypedNode &Node, @@ -1290,7 +1281,7 @@ bool matches(const T &Node, ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder) const override { return Finder->matchesChildOf(Node, this->InnerMatcher, Builder, - ASTMatchFinder::TK_AsIs, + ast_type_traits::TraversalKind::TK_AsIs, ASTMatchFinder::BK_First); } }; @@ -1313,7 +1304,7 @@ BoundNodesTreeBuilder* Builder) const override { return Finder->matchesChildOf( Node, this->InnerMatcher, Builder, - ASTMatchFinder::TK_IgnoreImplicitCastsAndParentheses, + ast_type_traits::TraversalKind::TK_IgnoreImplicitCastsAndParentheses, ASTMatchFinder::BK_All); } }; Index: lib/ASTMatchers/ASTMatchFinder.cpp =================================================================== --- lib/ASTMatchers/ASTMatchFinder.cpp +++ lib/ASTMatchers/ASTMatchFinder.cpp @@ -87,7 +87,7 @@ ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder, int MaxDepth, - ASTMatchFinder::TraversalKind Traversal, + ast_type_traits::TraversalKind Traversal, ASTMatchFinder::BindKind Bind) : Matcher(Matcher), Finder(Finder), @@ -151,7 +151,7 @@ ScopedIncrement ScopedDepth(&CurrentDepth); Stmt *StmtToTraverse = StmtNode; - if (Traversal == ASTMatchFinder::TK_IgnoreImplicitCastsAndParentheses) { + if (Traversal == ast_type_traits::TraversalKind::TK_IgnoreImplicitCastsAndParentheses) { if (Expr *ExprNode = dyn_cast_or_null(StmtNode)) StmtToTraverse = ExprNode->IgnoreParenImpCasts(); } @@ -299,7 +299,7 @@ BoundNodesTreeBuilder ResultBindings; int CurrentDepth; const int MaxDepth; - const ASTMatchFinder::TraversalKind Traversal; + const ast_type_traits::TraversalKind Traversal; const ASTMatchFinder::BindKind Bind; bool Matches; }; @@ -393,7 +393,7 @@ bool memoizedMatchesRecursively(const ast_type_traits::DynTypedNode &Node, const DynTypedMatcher &Matcher, BoundNodesTreeBuilder *Builder, int MaxDepth, - TraversalKind Traversal, BindKind Bind) { + ast_type_traits::TraversalKind Traversal, BindKind Bind) { // For AST-nodes that don't have an identity, we can't memoize. if (!Node.getMemoizationData() || !Builder->isComparable()) return matchesRecursively(Node, Matcher, Builder, MaxDepth, Traversal, @@ -427,7 +427,7 @@ bool matchesRecursively(const ast_type_traits::DynTypedNode &Node, const DynTypedMatcher &Matcher, BoundNodesTreeBuilder *Builder, int MaxDepth, - TraversalKind Traversal, BindKind Bind) { + ast_type_traits::TraversalKind Traversal, BindKind Bind) { MatchChildASTVisitor Visitor( &Matcher, this, Builder, MaxDepth, Traversal, Bind); return Visitor.findMatch(Node); @@ -441,7 +441,7 @@ bool matchesChildOf(const ast_type_traits::DynTypedNode &Node, const DynTypedMatcher &Matcher, BoundNodesTreeBuilder *Builder, - TraversalKind Traversal, + ast_type_traits::TraversalKind Traversal, BindKind Bind) override { if (ResultCache.size() > MaxMemoizationEntries) ResultCache.clear(); @@ -456,7 +456,7 @@ if (ResultCache.size() > MaxMemoizationEntries) ResultCache.clear(); return memoizedMatchesRecursively(Node, Matcher, Builder, INT_MAX, - TK_AsIs, Bind); + ast_type_traits::TraversalKind::TK_AsIs, Bind); } // Implements ASTMatchFinder::matchesAncestorOf. bool matchesAncestorOf(const ast_type_traits::DynTypedNode &Node, Index: unittests/ASTMatchers/ASTMatchersInternalTest.cpp =================================================================== --- unittests/ASTMatchers/ASTMatchersInternalTest.cpp +++ unittests/ASTMatchers/ASTMatchersInternalTest.cpp @@ -76,7 +76,7 @@ internal::Matcher, AMatcher) { return Finder->matchesChildOf( Node, AMatcher, Builder, - ASTMatchFinder::TK_IgnoreImplicitCastsAndParentheses, + ast_type_traits::TraversalKind::TK_IgnoreImplicitCastsAndParentheses, ASTMatchFinder::BK_First); }