Skip to content

Commit b5b15c1

Browse files
authored
[ast matcher][NFC] make dump_ast_matchers.py run in any path (#117942)
1 parent 7417ba6 commit b5b15c1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

clang/docs/tools/dump_ast_matchers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import collections
77
import re
8+
import os
89

910
try:
1011
from urllib.request import urlopen
@@ -18,7 +19,11 @@
1819
CLASS_INDEX_PAGE = None
1920
print("Unable to get %s: %s" % (CLASS_INDEX_PAGE_URL, e))
2021

21-
MATCHERS_FILE = "../../include/clang/ASTMatchers/ASTMatchers.h"
22+
CURRENT_DIR = os.path.dirname(__file__)
23+
MATCHERS_FILE = os.path.join(
24+
CURRENT_DIR, "../../include/clang/ASTMatchers/ASTMatchers.h"
25+
)
26+
HTML_FILE = os.path.join(CURRENT_DIR, "../LibASTMatchersReference.html")
2227

2328
# Each matcher is documented in one row of the form:
2429
# result | name | argA
@@ -590,7 +595,7 @@ def sort_table(matcher_type, matcher_map):
590595
narrowing_matcher_table = sort_table("NARROWING", narrowing_matchers)
591596
traversal_matcher_table = sort_table("TRAVERSAL", traversal_matchers)
592597

593-
reference = open("../LibASTMatchersReference.html").read()
598+
reference = open(HTML_FILE).read()
594599
reference = re.sub(
595600
r"<!-- START_DECL_MATCHERS.*END_DECL_MATCHERS -->",
596601
node_matcher_table,

0 commit comments

Comments
 (0)