diff options
Diffstat (limited to 'lib/ASTMatchers/ASTMatchFinder.cpp')
-rw-r--r-- | lib/ASTMatchers/ASTMatchFinder.cpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/lib/ASTMatchers/ASTMatchFinder.cpp b/lib/ASTMatchers/ASTMatchFinder.cpp index dec2e2ad1f93..f407e0875ac4 100644 --- a/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/lib/ASTMatchers/ASTMatchFinder.cpp @@ -1,9 +1,8 @@ //===--- ASTMatchFinder.cpp - Structural query framework ------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -84,20 +83,12 @@ public: // descendants of a traversed node. max_depth is the maximum depth // to traverse: use 1 for matching the children and INT_MAX for // matching the descendants. - MatchChildASTVisitor(const DynTypedMatcher *Matcher, - ASTMatchFinder *Finder, - BoundNodesTreeBuilder *Builder, - int MaxDepth, - ASTMatchFinder::TraversalKind Traversal, + MatchChildASTVisitor(const DynTypedMatcher *Matcher, ASTMatchFinder *Finder, + BoundNodesTreeBuilder *Builder, int MaxDepth, + ast_type_traits::TraversalKind Traversal, ASTMatchFinder::BindKind Bind) - : Matcher(Matcher), - Finder(Finder), - Builder(Builder), - CurrentDepth(0), - MaxDepth(MaxDepth), - Traversal(Traversal), - Bind(Bind), - Matches(false) {} + : Matcher(Matcher), Finder(Finder), Builder(Builder), CurrentDepth(0), + MaxDepth(MaxDepth), Traversal(Traversal), Bind(Bind), Matches(false) {} // Returns true if a match is found in the subtree rooted at the // given AST node. This is done via a set of mutually recursive @@ -152,7 +143,8 @@ public: 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<Expr>(StmtNode)) StmtToTraverse = ExprNode->IgnoreParenImpCasts(); } @@ -300,7 +292,7 @@ private: BoundNodesTreeBuilder ResultBindings; int CurrentDepth; const int MaxDepth; - const ASTMatchFinder::TraversalKind Traversal; + const ast_type_traits::TraversalKind Traversal; const ASTMatchFinder::BindKind Bind; bool Matches; }; @@ -394,7 +386,8 @@ public: 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, @@ -428,7 +421,8 @@ public: 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); @@ -442,7 +436,7 @@ public: 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(); @@ -457,7 +451,8 @@ public: 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, |