[clang] b5b15c1 - [ast matcher][NFC] make dump_ast_matchers.py run in any path (#117942)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 3 13:21:12 PST 2024
Author: Congcong Cai
Date: 2024-12-04T05:21:07+08:00
New Revision: b5b15c1973935da943e8cee26dc961c6dbe339b9
URL: https://github.com/llvm/llvm-project/commit/b5b15c1973935da943e8cee26dc961c6dbe339b9
DIFF: https://github.com/llvm/llvm-project/commit/b5b15c1973935da943e8cee26dc961c6dbe339b9.diff
LOG: [ast matcher][NFC] make dump_ast_matchers.py run in any path (#117942)
Added:
Modified:
clang/docs/tools/dump_ast_matchers.py
Removed:
################################################################################
diff --git a/clang/docs/tools/dump_ast_matchers.py b/clang/docs/tools/dump_ast_matchers.py
index 705ff0d4d40985..b6f00657ec914c 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,11 @@
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 +595,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,
More information about the cfe-commits
mailing list