Skip to content

Commit

Permalink
Revert "[clang][test] add testing for the AST matcher reference" (llv…
Browse files Browse the repository at this point in the history
…m#110354)

Reverts llvm#110258

The commit caused a timeout for clang-arm64-windows-msvc:
https://lab.llvm.org/buildbot/#/builders/161/builds/2385
and it looks like my commit is at fault.
  • Loading branch information
5chmidti authored Sep 28, 2024
1 parent 75e08a5 commit a800764
Show file tree
Hide file tree
Showing 8 changed files with 3,944 additions and 11,406 deletions.
7,953 changes: 2,273 additions & 5,680 deletions clang/docs/LibASTMatchersReference.html

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,6 @@ AST Matchers

- Fixed a crash when traverse lambda expr with invalid captures. (#GH106444)

- The examples in the AST matcher reference are now tested and additional
examples and descriptions were added.

clang-format
------------

Expand Down
9 changes: 1 addition & 8 deletions clang/docs/doxygen.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,7 @@ TAB_SIZE = 2
# "Side Effects:". You can put \n's in the value part of an alias to insert
# newlines.

ALIASES += compile_args{1}="Compiled with <tt>\1</tt>.\n"
ALIASES += matcher{1}="<tt>\1</tt>"
ALIASES += matcher{2$}="<tt>\2</tt>"
ALIASES += match{1}="<tt>\1</tt>"
ALIASES += match{2$}="<tt>\2</tt>"
ALIASES += nomatch{1}="<tt>\1</tt>"
ALIASES += header{1}="\code"
ALIASES += endheader="\endcode"
ALIASES =

# This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding "class=itcl::class"
Expand Down
68 changes: 5 additions & 63 deletions clang/docs/tools/dump_ast_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,72 +100,15 @@ def extract_result_types(comment):
comment = m.group(1)


def find_next_closing_rbrace(
data: str, start_pos: int, braces_to_be_matched: int
) -> int:
"""Finds the location of the closing rbrace '}' inside of data."""
"""'start_pos' should be one past the opening lbrace and braces_to_be_matched is initialized with 0"""
next_lbrace = data.find("{", start_pos)
next_rbrace = data.find("}", start_pos)
if next_lbrace != -1:
if next_lbrace < next_rbrace:
return find_next_closing_rbrace(
data, next_lbrace + 1, braces_to_be_matched + 1
)
if braces_to_be_matched == 0:
return next_rbrace
return find_next_closing_rbrace(data, next_rbrace + 1, braces_to_be_matched - 1)

if braces_to_be_matched > 0:
return find_next_closing_rbrace(data, next_rbrace + 1, braces_to_be_matched - 1)

return next_rbrace


def strip_doxygen(comment):
"""Returns the given comment without \-escaped words."""
# If there is only a doxygen keyword in the line, delete the whole line.
comment = re.sub(r"^\\[^\s]+\n", r"", comment, flags=re.M)

# If there is a doxygen \see command, change the \see prefix into "See also:".
# FIXME: it would be better to turn this into a link to the target instead.
comment = re.sub(r"\\see", r"See also:", comment)

commands: list[str] = [
"\\compile_args{",
"\\matcher{",
"\\match{",
"\\nomatch{",
]

for command in commands:
delete_command = command == "\\compile_args{"
command_begin_loc = comment.find(command)
while command_begin_loc != -1:
command_end_loc = command_begin_loc + len(command)
end_brace_loc = find_next_closing_rbrace(comment, command_end_loc + 1, 0)
if end_brace_loc == -1:
print("found unmatched {")
command_begin_loc = comment.find(command, command_end_loc)
continue

if delete_command:
comment = comment[0:command_begin_loc] + comment[end_brace_loc + 1 :]
command_begin_loc = comment.find(command, command_begin_loc)
continue

tag_seperator_loc = comment.find("$", command_end_loc)
if tag_seperator_loc != -1 and tag_seperator_loc < end_brace_loc:
command_end_loc = tag_seperator_loc + 1

comment = (
comment[0:command_begin_loc]
+ comment[command_end_loc:end_brace_loc]
+ comment[end_brace_loc + 1 :]
)

command_begin_loc = comment.find(command, command_begin_loc)

# If there is only a doxygen keyword in the line, delete the whole line.
comment = re.sub(r"^\\[^\s]+\n", r"", comment, flags=re.M)

# Delete the doxygen command and the following whitespace.
comment = re.sub(r"\\[^\s]+\s+", r"", comment)
return comment
Expand Down Expand Up @@ -248,9 +191,8 @@ def act_on_decl(declaration, comment, allowed_types):
definition.
"""
if declaration.strip():
if re.match(
r"^\s?(#|namespace|using|template <typename NodeType> using|})", declaration
):

if re.match(r"^\s?(#|namespace|using|template <typename NodeType> using|})", declaration):
return

# Node matchers are defined by writing:
Expand Down
Loading

0 comments on commit a800764

Please sign in to comment.