================ @@ -231,101 +232,107 @@ can further inspect them and report diagnostics. and `clang-tidy/google/ExplicitConstructorCheck.cpp <https://reviews.llvm.org/diffusion/L/browse/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp>`_). -If you need to interact with macros or preprocessor directives, you will want to -override the method ``registerPPCallbacks``. The ``add_new_check.py`` script -does not generate an override for this method in the starting point for your -new check. +If you need to interact with macros or preprocessor directives, you will want +to override the method ``registerPPCallbacks``. The ``add_new_check.py`` +script does not generate an override for this method in the starting point for +your new check. Check development tips ---------------------- -Writing your first check can be a daunting task, particularly if you are unfamiliar -with the LLVM and Clang code bases. Here are some suggestions for orienting yourself -in the codebase and working on your check incrementally. +Writing your first check can be a daunting task, particularly if you are +unfamiliar with the LLVM and Clang code bases. Here are some suggestions for +orienting yourself in the codebase and working on your check incrementally. Guide to useful documentation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Many of the support classes created for LLVM are used by Clang, such as `StringRef <https://llvm.org/docs/ProgrammersManual.html#the-stringref-class>`_ and `SmallVector <https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h>`_. -These and other commonly used classes are described in the `Important and useful LLVM APIs -<https://llvm.org/docs/ProgrammersManual.html#important-and-useful-llvm-apis>`_ and -`Picking the Right Data Structure for the Task +These and other commonly used classes are described in the `Important and +useful LLVM APIs <https://llvm.org/docs/ProgrammersManual.html#important-and-useful-llvm-apis>`_ +and `Picking the Right Data Structure for the Task <https://llvm.org/docs/ProgrammersManual.html#picking-the-right-data-structure-for-a-task>`_ sections of the `LLVM Programmer's Manual -<https://llvm.org/docs/ProgrammersManual.html>`_. You don't need to memorize all the +<https://llvm.org/docs/ProgrammersManual.html>`. You don't need to memorize all the details of these classes; the generated `doxygen documentation <https://llvm.org/doxygen/>`_ -has everything if you need it. In the header `LLVM/ADT/STLExtras.h +has everything if you need it. In the header `LLVM/ADT/STLExtras.h <https://llvm.org/doxygen/STLExtras_8h.html>`_ you'll find useful versions of the STL algorithms that operate on LLVM containers, such as `llvm::all_of <https://llvm.org/doxygen/STLExtras_8h.html#func-members>`_. -Clang is implemented on top of LLVM and introduces its own set of classes that you -will interact with while writing your check. When a check issues diagnostics and -fix-its, these are associated with locations in the source code. Source code locations, -source files, ranges of source locations and the `SourceManager -<https://clang.llvm.org/doxygen/classclang_1_1SourceManager.html>`_ class provide -the mechanisms for describing such locations. These and +Clang is implemented on top of LLVM and introduces its own set of classes that +you will interact with while writing your check. When a check issues +diagnostics and fix-its, these are associated with locations in the source +code. Source code locations, source files, ranges of source locations and the +`SourceManager <https://clang.llvm.org/doxygen/classclang_1_1SourceManager.html>`_ +class provide the mechanisms for describing such locations. These and other topics are described in the `"Clang" CFE Internals Manual -<https://clang.llvm.org/docs/InternalsManual.html>`_. Whereas the doxygen generated -documentation serves as a reference to the internals of Clang, this document serves -as a guide to other developers. Topics in that manual of interest to a check developer -are: +<https://clang.llvm.org/docs/InternalsManual.html>`_. Whereas the doxygen generated +documentation serves as a reference to the internals of Clang, this document +servesas a guide to other developers. Topics in that manual of interest to a +check developer are: - `The Clang "Basic" Library <https://clang.llvm.org/docs/InternalsManual.html#the-clang-basic-library>`_ for information about diagnostics, fix-it hints and source locations. - `The Lexer and Preprocessor Library <https://clang.llvm.org/docs/InternalsManual.html#the-lexer-and-preprocessor-library>`_ - for information about tokens, lexing (transforming characters into tokens) and the - preprocessor. + for information about tokens, lexing (transforming characters into tokens) + and the preprocessor. - `The AST Library <https://clang.llvm.org/docs/InternalsManual.html#the-ast-library>`_ - for information about how C++ source statements are represented as an abstract syntax - tree (AST). - -Most checks will interact with C++ source code via the AST. Some checks will interact -with the preprocessor. The input source file is lexed and preprocessed and then parsed -into the AST. Once the AST is fully constructed, the check is run by applying the check's -registered AST matchers against the AST and invoking the check with the set of matched -nodes from the AST. Monitoring the actions of the preprocessor is detached from the -AST construction, but a check can collect information during preprocessing for later -use by the check when nodes are matched by the AST. - -Every syntactic (and sometimes semantic) element of the C++ source code is represented by -different classes in the AST. You select the portions of the AST you're interested in -by composing AST matcher functions. You will want to study carefully the `AST Matcher -Reference <https://clang.llvm.org/docs/LibASTMatchersReference.html>`_ to understand -the relationship between the different matcher functions. + for information about how C++ source statements are represented as an + abstract syntax tree (AST). + +Most checks will interact with C++ source code via the AST. Some checks will +interact with the preprocessor. The input source file is lexed and preprocessed +and then parsed into the AST. Once the AST is fully constructed, the check is +run by applying the check's registered AST matchers against the AST and +invoking the check with the set of matched nodes from the AST. Monitoring the +actions of the preprocessor is detached from the AST construction, but a check +can collect information during preprocessing for later use by the check when +nodes are matched by the AST. + +Every syntactic (and sometimes semantic) element of the C++ source code is +represented by different classes in the AST. You select the portions of the +AST you're interested in by composing AST matcher functions. You will want ---------------- EugeneZelenko wrote:
```suggestion AST you're interested in by composing AST matcher functions. You will want ``` https://github.com/llvm/llvm-project/pull/168722 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
