================ @@ -337,89 +344,93 @@ a starting point for your test cases. A rough outline of the process looks like - Repeat the process until all aspects of your check are covered by tests. The quickest way to prototype your matcher is to use :program:`clang-query` to -interactively build up your matcher. For complicated matchers, build up a matching -expression incrementally and use :program:`clang-query`'s ``let`` command to save named -matching expressions to simplify your matcher. +interactively build up your matcher. For complicated matchers, build up a +matching expression incrementally and use :program:`clang-query`'s ``let`` +command to save named matching expressions to simplify your matcher. .. code-block:: console clang-query> let c1 cxxRecordDecl() clang-query> match c1 -Alternatively, pressing the tab key after a previous matcher's open parentheses -would also show which matchers can be chained with the previous matcher, -though some matchers that work may not be listed. Note that tab completion +Alternatively, pressing the tab key after a previous matcher's open parentheses +would also show which matchers can be chained with the previous matcher, +though some matchers that work may not be listed. Note that tab completion does not currently work on Windows. -Just like breaking up a huge function into smaller chunks with -intention-revealing names can help you understand a complex algorithm, breaking -up a matcher into smaller matchers with intention-revealing names can help -you understand a complicated matcher. +Just like breaking up a huge function into smaller chunks with +intention-revealing names can help you understand a complex algorithm, breaking +up a matcher into smaller matchers with intention-revealing names can help +you understand a complicated matcher. -Once you have a working :program:`clang-query` matcher, the C++ API matchers -will be the same or similar to your interactively constructed matcher (there -can be cases where they differ slightly). You can use local variables to preserve -your intention-revealing names that you applied to nested matchers. +Once you have a working :program:`clang-query` matcher, the C++ API matchers +will be the same or similar to your interactively constructed matcher (there +can be cases where they differ slightly). You can use local variables to +preserve your intention-revealing names that you applied to nested matchers. Creating private matchers ^^^^^^^^^^^^^^^^^^^^^^^^^ -Sometimes you want to match a specific aspect of the AST that isn't provided by the -existing AST matchers. You can create your own private matcher using the same -infrastructure as the public matchers. A private matcher can simplify the processing -in your ``check`` method by eliminating complex hand-crafted AST traversal of the -matched nodes. Using the private matcher allows you to select the desired portions -of the AST directly in the matcher and refer to it by a bound name in the ``check`` -method. +Sometimes you want to match a specific aspect of the AST that isn't provided +by the existing AST matchers. You can create your own private matcher using +the same infrastructure as the public matchers. A private matcher can +simplify the processing in your ``check`` method by eliminating complex +hand-crafted AST traversal of the matched nodes. Using the private matcher +allows you to select the desired portions of the AST directly in the matcher +and refer to it by a bound name in the ``check`` method. Unit testing helper code ^^^^^^^^^^^^^^^^^^^^^^^^ -Private custom matchers are a good example of auxiliary support code for your check -that can be tested with a unit test. It will be easier to test your matchers or -other support classes by writing a unit test than by writing a ``FileCheck`` integration -test. The ``ASTMatchersTests`` target contains unit tests for the public AST matcher -classes and is a good source of testing idioms for matchers. +Private custom matchers are a good example of auxiliary support code for your +check that can be tested with a unit test. It will be easier to test your +matchers or other support classes by writing a unit test than by writing a +``FileCheck`` integration test. The ``ASTMatchersTests`` target contains unit +tests for the public AST matcher classes and is a good source of testing +idioms for matchers. -You can build the Clang-tidy unit tests by building the ``ClangTidyTests`` target. -Test targets in LLVM and Clang are excluded from the "build all" style action of -IDE-based CMake generators, so you need to explicitly build the target for the unit -tests to be built. +You can build the Clang-tidy unit tests by building the ``ClangTidyTests`` ---------------- EugeneZelenko wrote:
```suggestion You can build the Clang-Tidy unit tests by building the ``ClangTidyTests`` ``` https://github.com/llvm/llvm-project/pull/168722 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
