Skip to content

[ast matcher][NFC] make dump_ast_matchers.py run in any path #117942

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

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

HerrCai0907
Copy link
Contributor

No description provided.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Nov 27, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 27, 2024

@llvm/pr-subscribers-clang

Author: Congcong Cai (HerrCai0907)

Changes

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

1 Files Affected:

  • (modified) clang/docs/tools/dump_ast_matchers.py (+5-2)
diff --git a/clang/docs/tools/dump_ast_matchers.py b/clang/docs/tools/dump_ast_matchers.py
index 705ff0d4d40985..63e8cd0a25b39c 100755
--- a/clang/docs/tools/dump_ast_matchers.py
+++ b/clang/docs/tools/dump_ast_matchers.py
@@ -5,6 +5,7 @@
 
 import collections
 import re
+import os
 
 try:
     from urllib.request import urlopen
@@ -18,7 +19,9 @@
     CLASS_INDEX_PAGE = None
     print("Unable to get %s: %s" % (CLASS_INDEX_PAGE_URL, e))
 
-MATCHERS_FILE = "../../include/clang/ASTMatchers/ASTMatchers.h"
+CURRENT_DIR = os.path.dirname(__file__)
+MATCHERS_FILE = os.path.join(CURRENT_DIR, "../../include/clang/ASTMatchers/ASTMatchers.h")
+HTML_FILE = os.path.join(CURRENT_DIR, "../LibASTMatchersReference.html")
 
 # Each matcher is documented in one row of the form:
 #   result | name | argA
@@ -590,7 +593,7 @@ def sort_table(matcher_type, matcher_map):
 narrowing_matcher_table = sort_table("NARROWING", narrowing_matchers)
 traversal_matcher_table = sort_table("TRAVERSAL", traversal_matchers)
 
-reference = open("../LibASTMatchersReference.html").read()
+reference = open(HTML_FILE).read()
 reference = re.sub(
     r"<!-- START_DECL_MATCHERS.*END_DECL_MATCHERS -->",
     node_matcher_table,

Copy link

github-actions bot commented Nov 27, 2024

✅ With the latest revision this PR passed the Python code formatter.

@HerrCai0907 HerrCai0907 force-pushed the fix/dump_ast_matchers branch from 65d7cd1 to 4f6e876 Compare November 28, 2024 00:18
@HerrCai0907 HerrCai0907 changed the title [ast-matcher][NFC] make dump_ast_matchers.py run in any path [ast matcher][NFC] make dump_ast_matchers.py run in any path Dec 3, 2024
@HerrCai0907 HerrCai0907 requested a review from 5chmidti December 3, 2024 14:24
Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HerrCai0907 HerrCai0907 merged commit b5b15c1 into llvm:main Dec 3, 2024
9 checks passed
@HerrCai0907 HerrCai0907 deleted the fix/dump_ast_matchers branch December 3, 2024 21:21
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.

3 participants