Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor traverse function with clearer function names #71441

Closed
wants to merge 1 commit into from
Closed

Refactor traverse function with clearer function names #71441

wants to merge 1 commit into from

Conversation

796e43a5a8cdb73b92b
Copy link

The traverse function has been updated for better readability and maintainability. The function now has clearer function names.

The `traverse` function has been updated for better readability and maintainability. The function now has clearer function names.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Nov 6, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 6, 2023

@llvm/pr-subscribers-clang

Author: None (796e43a5a8cdb73b92b)

Changes

The traverse function has been updated for better readability and maintainability. The function now has clearer function names.


Full diff: https://github.com/llvm/llvm-project/pull/71441.diff

1 Files Affected:

  • (modified) clang/lib/ASTMatchers/ASTMatchFinder.cpp (+9-8)
diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index 0bac2ed63a927ef..56bddce7d02ddfc 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -395,14 +395,15 @@ class MatchChildASTVisitor
 
   // Traverses the subtree rooted at 'Node'; returns true if the
   // traversal should continue after this function returns.
-  template <typename T>
-  bool traverse(const T &Node) {
-    static_assert(IsBaseType<T>::value,
-                  "traverse can only be instantiated with base type");
-    if (!match(Node))
-      return false;
-    return baseTraverse(Node);
-  }
+template <typename NodeType>
+bool traverse(const NodeType &node) {
+    static_assert(IsBaseType<NodeType>::value,
+        "traverse can only be instantiated with base type");
+    if (!shouldContinue(node))
+        return false;
+    return continueTraversal(node);
+}
+
 
   const DynTypedMatcher *const Matcher;
   ASTMatchFinder *const Finder;

Copy link

github-actions bot commented Nov 6, 2023

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 74e0a26fd114cac39e251e4c2b6fbbadd6009887 1fc6f26966f0192bb1789b66778381d94cd6bbe5 -- clang/lib/ASTMatchers/ASTMatchFinder.cpp
View the diff from clang-format here.
diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index 56bddce7d..612bc3b5e 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -395,15 +395,13 @@ private:
 
   // Traverses the subtree rooted at 'Node'; returns true if the
   // traversal should continue after this function returns.
-template <typename NodeType>
-bool traverse(const NodeType &node) {
+  template <typename NodeType> bool traverse(const NodeType &node) {
     static_assert(IsBaseType<NodeType>::value,
-        "traverse can only be instantiated with base type");
+                  "traverse can only be instantiated with base type");
     if (!shouldContinue(node))
-        return false;
+      return false;
     return continueTraversal(node);
-}
-
+  }
 
   const DynTypedMatcher *const Matcher;
   ASTMatchFinder *const Finder;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants