Skip to content

Commit 65d7cd1

Browse files
committed
[ast-matcher][NFC] make dump_ast_matchers.py run in any path
1 parent 32ff209 commit 65d7cd1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

clang/docs/tools/dump_ast_matchers.py

Lines changed: 5 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,9 @@
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(CURRENT_DIR, "../../include/clang/ASTMatchers/ASTMatchers.h")
24+
HTML_FILE = os.path.join(CURRENT_DIR, "../LibASTMatchersReference.html")
2225

2326
# Each matcher is documented in one row of the form:
2427
# result | name | argA
@@ -590,7 +593,7 @@ def sort_table(matcher_type, matcher_map):
590593
narrowing_matcher_table = sort_table("NARROWING", narrowing_matchers)
591594
traversal_matcher_table = sort_table("TRAVERSAL", traversal_matchers)
592595

593-
reference = open("../LibASTMatchersReference.html").read()
596+
reference = open(HTML_FILE).read()
594597
reference = re.sub(
595598
r"<!-- START_DECL_MATCHERS.*END_DECL_MATCHERS -->",
596599
node_matcher_table,

0 commit comments

Comments
 (0)