Author: alexfh Date: Thu Aug 27 13:10:07 2015 New Revision: 246173 URL: http://llvm.org/viewvc/llvm-project?rev=246173&view=rev Log: [clang-tidy] Move clang-tidy docs to a separate directory. Create doc files for checks
The doc files for checks have been generated from the corresponding header files using the docs/clang-tidy/tools/dump_check_docs.py script. Committing the script as well, but the intention is to move all the user-facing docs from header files to the rST files and add links to .h files appropriately. Added: clang-tools-extra/trunk/docs/clang-tidy/ clang-tools-extra/trunk/docs/clang-tidy/checks/ clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-explicit-make-pair.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-namespaces.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-using-namespace.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-explicit-constructor.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-braces-around-statements.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-casting.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-function-size.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-namespace-comments.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-redundant-smartptr-get.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-todo.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-int.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-member-string-references.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-memset.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-operator.rst clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-header-guard.rst clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-include-order.rst clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-twine-local.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assert-side-effect.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assign-operator-signature.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-bool-pointer-implicit-conversion.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inaccurate-erase.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-parentheses.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-static-assert.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-swapped-arguments.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-undelegated-constructor.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-uniqueptr-reset-release.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-alias-decls.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-parameters.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-raii.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-container-size-empty.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-else-after-return.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-function-size.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-named-parameter.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst clang-tools-extra/trunk/docs/clang-tidy/index.rst - copied, changed from r246170, clang-tools-extra/trunk/docs/clang-tidy.rst clang-tools-extra/trunk/docs/clang-tidy/tools/ clang-tools-extra/trunk/docs/clang-tidy/tools/dump_check_docs.py (with props) Removed: clang-tools-extra/trunk/docs/clang-tidy.rst Modified: clang-tools-extra/trunk/docs/Doxyfile clang-tools-extra/trunk/docs/index.rst Modified: clang-tools-extra/trunk/docs/Doxyfile URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/Doxyfile?rev=246173&r1=246172&r2=246173&view=diff ============================================================================== --- clang-tools-extra/trunk/docs/Doxyfile (original) +++ clang-tools-extra/trunk/docs/Doxyfile Thu Aug 27 13:10:07 2015 @@ -648,7 +648,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ../clang-modernize ../clang-apply-replacements +INPUT = ../clang-modernize ../clang-apply-replacements ../clang-tidy # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is Removed: clang-tools-extra/trunk/docs/clang-tidy.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy.rst?rev=246172&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy.rst (original) +++ clang-tools-extra/trunk/docs/clang-tidy.rst (removed) @@ -1,502 +0,0 @@ -========== -Clang-Tidy -========== - -:program:`clang-tidy` is a clang-based C++ linter tool. Its purpose is to -provide an extensible framework for diagnosing and fixing typical programming -errors, like style violations, interface misuse, or bugs that can be deduced via -static analysis. :program:`clang-tidy` is modular and provides a convenient -interface for writing new checks. - - -Using clang-tidy -================ - -:program:`clang-tidy` is a `LibTooling`_-based tool, and it's easier to work -with if you set up a compile command database for your project (for an example -of how to do this see `How To Setup Tooling For LLVM`_). You can also specify -compilation options on the command line after ``--``: - -.. code-block:: console - - $ clang-tidy test.cpp -- -Imy_project/include -DMY_DEFINES ... - -:program:`clang-tidy` has its own checks and can also run Clang static analyzer -checks. Each check has a name and the checks to run can be chosen using the -``-checks=`` option, which specifies a comma-separated list of positive and -negative (prefixed with ``-``) globs. Positive globs add subsets of checks, -negative globs remove them. For example, - -.. code-block:: console - - $ clang-tidy test.cpp -checks=-*,clang-analyzer-*,-clang-analyzer-alpha* - -will disable all default checks (``-*``) and enable all ``clang-analyzer-*`` -checks except for ``clang-analyzer-alpha*`` ones. - -The ``-list-checks`` option lists all the enabled checks. When used without -``-checks=``, it shows checks enabled by default. Use ``-checks=*`` to see all -available checks or with any other value of ``-checks=`` to see which checks are -enabled by this value. - -There are currently the following groups of checks: - -* Checks related to the LLVM coding conventions have names starting with - ``llvm-``. - -* Checks related to the Google coding conventions have names starting with - ``google-``. - -* Checks with names starting with ``misc-`` don't relate to any particular - coding style. - -* Clang static analyzer checks are named starting with ``clang-analyzer-``. - -Clang diagnostics are treated in a similar way as check diagnostics. Clang -diagnostics are displayed by clang-tidy and can be filtered out using -``-checks=`` option. However, the ``-checks=`` option does not affect -compilation arguments, so it can not turn on Clang warnings which are not -already turned on in build configuration. - -Clang diagnostics have check names starting with ``clang-diagnostic-``. -Diagnostics which have a corresponding warning option, are named -``clang-diagostic-<warning-option>``, e.g. Clang warning controlled by -``-Wliteral-conversion`` will be reported with check name -``clang-diagnostic-literal-conversion``. - -The ``-fix`` flag instructs :program:`clang-tidy` to fix found errors if -supported by corresponding checks. - -An overview of all the command-line options: - -.. code-block:: console - - $ clang-tidy -help - USAGE: clang-tidy [options] <source0> [... <sourceN>] - - OPTIONS: - - General options: - - -help - Display available options (-help-hidden - for more) - -help-list - Display list of available options - (-help-list-hidden for more) - -version - Display the version of this program - - clang-tidy options: - - -analyze-temporary-dtors - Enable temporary destructor-aware analysis in - clang-analyzer- checks. - This option overrides the value read from a - .clang-tidy file. - -checks=<string> - Comma-separated list of globs with optional '-' - prefix. Globs are processed in order of appearance - in the list. Globs without '-' prefix add checks - with matching names to the set, globs with the '-' - prefix remove checks with matching names from the - set of enabled checks. - This option's value is appended to the value read - from a .clang-tidy file, if any. - -config=<string> - Specifies a configuration in YAML/JSON format: - -config="{Checks: '*', CheckOptions: [{key: x, value: y}]}" - When the value is empty, clang-tidy will attempt to find - a file named .clang-tidy for each source file in its parent - directories. - -dump-config - Dumps configuration in the YAML format to stdout. This option - should be used along with a file name (and '--' if the file is - outside of a project with configured compilation database). The - configuration used for this file will be printed. - -enable-check-profile - Enable per-check timing profiles, and print a report to stderr. - -export-fixes=<filename> - YAML file to store suggested fixes in. The - stored fixes can be applied to the input source - code with clang-apply-replacements. - -extra-arg=<string> - Additional argument to append to the compiler command line - -extra-arg-before=<string> - Additional argument to prepend to the compiler command line - -fix - Apply suggested fixes. Without -fix-errors - clang-tidy will bail out if any compilation - errors were found. - -fix-errors - Apply suggested fixes even if compilation errors - were found. If compiler errors have attached - fix-its, clang-tidy will apply them as well. - -header-filter=<string> - Regular expression matching the names of the - headers to output diagnostics from. Diagnostics - from the main file of each translation unit are - always displayed. - Can be used together with -line-filter. - This option overrides the value read from a - .clang-tidy file. - -line-filter=<string> - List of files with line ranges to filter the - warnings. Can be used together with - -header-filter. The format of the list is a JSON - array of objects: - [ - {"name":"file1.cpp","lines":[[1,3],[5,7]]}, - {"name":"file2.h"} - ] - -list-checks - List all enabled checks and exit. Use with - -checks=* to list all available checks. - -p=<string> - Build path - -system-headers - Display the errors from system headers. - - -p <build-path> is used to read a compile command database. - - For example, it can be a CMake build directory in which a file named - compile_commands.json exists (use -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - CMake option to get this output). When no build path is specified, - a search for compile_commands.json will be attempted through all - parent paths of the first input file . See: - http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html for an - example of setting up Clang Tooling on a source tree. - - <source0> ... specify the paths of source files. These paths are - looked up in the compile command database. If the path of a file is - absolute, it needs to point into CMake's source tree. If the path is - relative, the current working directory needs to be in the CMake - source tree and the file must be in a subdirectory of the current - working directory. "./" prefixes in the relative files will be - automatically removed, but the rest of a relative path must be a - suffix of a path in the compile command database. - - Configuration files: - clang-tidy attempts to read configuration for each source file from a - .clang-tidy file located in the closest parent directory of the source - file. If any configuration options have a corresponding command-line - option, command-line option takes precedence. The effective - configuration can be inspected using -dump-config: - - $ clang-tidy -dump-config - -- - --- - Checks: '-*,some-check' - HeaderFilterRegex: '' - AnalyzeTemporaryDtors: false - User: user - CheckOptions: - - key: some-check.SomeOption - value: 'some value' - ... - -.. _LibTooling: http://clang.llvm.org/docs/LibTooling.html -.. _How To Setup Tooling For LLVM: http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html - - -Getting Involved -================ - -:program:`clang-tidy` has several own checks and can run Clang static analyzer -checks, but its power is in the ability to easily write custom checks. - -Checks are organized in modules, which can be linked into :program:`clang-tidy` -with minimal or no code changes in clang-tidy. - -Checks can plug the analysis on the preprocessor level using `PPCallbacks`_ or -on the AST level using `AST Matchers`_. When an error is found, checks can -report them in a way similar to how Clang diagnostics work. A fix-it hint can be -attached to a diagnostic message. - -The interface provided by clang-tidy makes it easy to write useful and precise -checks in just a few lines of code. If you have an idea for a good check, the -rest of this document explains how to do this. - -.. _AST Matchers: http://clang.llvm.org/docs/LibASTMatchers.html -.. _PPCallbacks: http://clang.llvm.org/doxygen/classclang_1_1PPCallbacks.html - - -Choosing the Right Place for your Check ---------------------------------------- - -If you have an idea of a check, you should decide whether it should be -implemented as a: - -+ *Clang diagnostic*: if the check is generic enough, targets code patterns that - most probably are bugs (rather than style or readability issues), can be - implemented effectively and with extremely low false positive rate, it may - make a good Clang diagnostic. - -+ *Clang static analyzer check*: if the check requires some sort of control flow - analysis, it should probably be implemented as a static analyzer check. - -+ *clang-tidy check* is a good choice for linter-style checks, checks that are - related to a certain coding style, checks that address code readability, etc. - - -Preparing your Workspace ------------------------- - -If you are new to LLVM development, you should read the `Getting Started with -the LLVM System`_, `Using Clang Tools`_ and `How To Setup Tooling For LLVM`_ -documents to check out and build LLVM, Clang and Clang Extra Tools with CMake. - -Once you are done, change to the ``llvm/tools/clang/tools/extra`` directory, and -let's start! - -.. _Getting Started with the LLVM System: http://llvm.org/docs/GettingStarted.html -.. _Using Clang Tools: http://clang.llvm.org/docs/ClangTools.html - - -The Directory Structure ------------------------ - -:program:`clang-tidy` source code resides in the -``llvm/tools/clang/tools/extra`` directory and is structured as follows: - -:: - - clang-tidy/ # Clang-tidy core. - |-- ClangTidy.h # Interfaces for users and checks. - |-- ClangTidyModule.h # Interface for clang-tidy modules. - |-- ClangTidyModuleRegistry.h # Interface for registering of modules. - ... - |-- google/ # Google clang-tidy module. - |-- |-- GoogleTidyModule.cpp - |-- |-- GoogleTidyModule.h - ... - |-- llvm/ # LLVM clang-tidy module. - |-- |-- LLVMTidyModule.cpp - |-- |-- LLVMTidyModule.h - ... - |-- tool/ # Sources of the clang-tidy binary. - ... - test/clang-tidy/ # Integration tests. - ... - unittests/clang-tidy/ # Unit tests. - |-- ClangTidyTest.h - |-- GoogleModuleTest.cpp - |-- LLVMModuleTest.cpp - ... - - -Writing a clang-tidy Check --------------------------- - -So you have an idea of a useful check for :program:`clang-tidy`. - -You need to decide which module the check belongs to. If the check verifies -conformance of the code to a certain coding style, it probably deserves a -separate module and a directory in ``clang-tidy/`` (there are LLVM and Google -modules already). - -After choosing the module, you need to create a class for your check: - -.. code-block:: c++ - - #include "../ClangTidy.h" - - namespace clang { - namespace tidy { - - class MyCheck : public ClangTidyCheck { - }; - - } // namespace tidy - } // namespace clang - -Next, you need to decide whether it should operate on the preprocessor level or -on the AST level. Let's imagine that we need to work with the AST in our check. -In this case we need to override two methods: - -.. code-block:: c++ - - ... - class ExplicitConstructorCheck : public ClangTidyCheck { - public: - ExplicitConstructorCheck(StringRef Name, ClangTidyContext *Context) - : ClangTidyCheck(Name, Context) {} - void registerMatchers(ast_matchers::MatchFinder *Finder) override; - void check(ast_matchers::MatchFinder::MatchResult &Result) override; - }; - -Constructor of the check receives the ``Name`` and ``Context`` parameters, and -must forward them to the ``ClangTidyCheck`` constructor. - -In the ``registerMatchers`` method we create an AST Matcher (see `AST Matchers`_ -for more information) that will find the pattern in the AST that we want to -inspect. The results of the matching are passed to the ``check`` method, which -can further inspect them and report diagnostics. - -.. code-block:: c++ - - using namespace ast_matchers; - - void ExplicitConstructorCheck::registerMatchers(MatchFinder *Finder) { - Finder->addMatcher(constructorDecl().bind("ctor"), this); - } - - void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) { - const CXXConstructorDecl *Ctor = - Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor"); - // Do not be confused: isExplicit means 'explicit' keyword is present, - // isImplicit means that it's a compiler-generated constructor. - if (Ctor->isOutOfLine() || Ctor->isExplicit() || Ctor->isImplicit()) - return; - if (Ctor->getNumParams() == 0 || Ctor->getMinRequiredArguments() > 1) - return; - SourceLocation Loc = Ctor->getLocation(); - diag(Loc, "Single-argument constructors must be explicit") - << FixItHint::CreateInsertion(Loc, "explicit "); - } - -(The full code for this check resides in -``clang-tidy/google/ExplicitConstructorCheck.{h,cpp}``). - - -Registering your Check ----------------------- - -The check should be registered in the corresponding module with a distinct name: - -.. code-block:: c++ - - class MyModule : public ClangTidyModule { - public: - void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { - CheckFactories.registerCheck<ExplicitConstructorCheck>( - "my-explicit-constructor"); - } - }; - -Now we need to register the module in the ``ClangTidyModuleRegistry`` using a -statically initialized variable: - -.. code-block:: c++ - - static ClangTidyModuleRegistry::Add<MyModule> X("my-module", - "Adds my lint checks."); - - -When using LLVM build system, we need to use the following hack to ensure the -module is linked into the clang-tidy binary: - -Add this near the ``ClangTidyModuleRegistry::Add<MyModule>`` variable: - -.. code-block:: c++ - - // This anchor is used to force the linker to link in the generated object file - // and thus register the MyModule. - volatile int MyModuleAnchorSource = 0; - -And this to the main translation unit of the clang-tidy binary (or the binary -you link the ``clang-tidy`` library in) ``clang-tidy/tool/ClangTidyMain.cpp``: - -.. code-block:: c++ - - // This anchor is used to force the linker to link the MyModule. - extern volatile int MyModuleAnchorSource; - static int MyModuleAnchorDestination = MyModuleAnchorSource; - - -Configuring Checks ------------------- - -If a check needs configuration options, it can access check-specific options -using the ``Options.get<Type>("SomeOption", DefaultValue)`` call in the check -constructor. In this case the check should also override the -``ClangTidyCheck::storeOptions`` method to make the options provided by the -check discoverable. This method lets :program:`clang-tidy` know which options -the check implements and what the current values are (e.g. for the -``-dump-config`` command line option). - -.. code-block:: c++ - - class MyCheck : public ClangTidyCheck { - const unsigned SomeOption1; - const std::string SomeOption2; - - public: - MyCheck(StringRef Name, ClangTidyContext *Context) - : ClangTidyCheck(Name, Context), - SomeOption(Options.get("SomeOption1", -1U)), - SomeOption(Options.get("SomeOption2", "some default")) {} - - void storeOptions(ClangTidyOptions::OptionMap &Opts) override { - Options.store(Opts, "SomeOption1", SomeOption1); - Options.store(Opts, "SomeOption2", SomeOption2); - } - ... - -Assuming the check is registered with the name "my-check", the option can then -be set in a ``.clang-tidy`` file in the following way: - -.. code-block:: yaml - - CheckOptions: - - key: my-check.SomeOption1 - value: 123 - - key: my-check.SomeOption2 - value: 'some other value' - -If you need to specify check options on a command line, you can use the inline -YAML format: - -.. code-block:: bash - - $ clang-tidy -config="{CheckOptions: [{key: a, value: b}, {key: x, value: y}]}" ... - - -Testing Checks --------------- - -:program:`clang-tidy` checks can be tested using either unit tests or -`lit`_ tests. Unit tests may be more convenient to test complex replacements -with strict checks. `Lit`_ tests allow using partial text matching and regular -expressions which makes them more suitable for writing compact tests for -diagnostic messages. - -The ``check_clang_tidy.py`` script provides an easy way to test both -diagnostic messages and fix-its. It filters out ``CHECK`` lines from the test -file, runs :program:`clang-tidy` and verifies messages and fixes with two -separate `FileCheck`_ invocations. To use the script, put a .cpp file with the -appropriate ``RUN`` line in the ``test/clang-tidy`` directory. Use -``CHECK-MESSAGES:`` and ``CHECK-FIXES:`` lines to write checks against -diagnostic messages and fixed code. - -It's advised to make the checks as specific as possible to avoid checks matching -to incorrect parts of the input. Use ``[[@LINE+X]]``/``[[@LINE-X]]`` -substitutions and distinct function and variable names in the test code. - -Here's an example of a test using the ``check_clang_tidy.py`` script: - -.. code-block:: bash - - // RUN: %python %S/check_clang_tidy.py %s google-readability-casting %t - - void f(int a) { - int b = (int)a; - // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant cast to the same type [google-readability-casting] - // CHECK-FIXES: int b = a; - } - -.. _lit: http://llvm.org/docs/CommandGuide/lit.html -.. _FileCheck: http://llvm.org/docs/CommandGuide/FileCheck.html - - -Running clang-tidy on LLVM --------------------------- - -To test a check it's best to try it out on a larger code base. LLVM and Clang -are the natural targets as you already have the source around. The most -convenient way to run :program:`clang-tidy` is with a compile command database; -CMake can automatically generate one, for a description of how to enable it see -`How To Setup Tooling For LLVM`_. Once ``compile_commands.json`` is in place and -a working version of :program:`clang-tidy` is in ``PATH`` the entire code base -can be analyzed with ``clang-tidy/tool/run-clang-tidy.py``. The script executes -:program:`clang-tidy` with the default set of checks on every translation unit -in the compile command database and displays the resulting warnings and errors. -The script provides multiple configuration flags. - -* The default set of checks can be overridden using the ``-checks`` argument, - taking the identical format as :program:`clang-tidy` does. For example - ``-checks=-*,misc-use-override`` will run the ``misc-use-override`` - checker only. - -* To restrict the files examined you can provide one or more regex arguments - that the file names are matched against. - ``run-clang-tidy.py clang-tidy/.*Check\.cpp`` will only analyze clang-tidy - checkers. It may also be necessary to restrict the header files warnings are - displayed from using the ``-header-filter`` flag. It has the same behavior - as the corresponding :program:`clang-tidy` flag. - -* To apply suggested fixes ``-fix`` can be passed as an argument. This gathers - all changes in a temporary directory and applies them. Passing ``-format`` - will run clang-format over changed lines. - Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-explicit-make-pair.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-explicit-make-pair.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-explicit-make-pair.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-explicit-make-pair.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,10 @@ +google-build-explicit-make-pair +=============================== + + +Check that ``make_pair``'s template arguments are deduced. + +G++ 4.6 in C++11 mode fails badly if ``make_pair``'s template arguments are +specified explicitly, and such use isn't intended in any case. + +Corresponding cpplint.py check name: 'build/explicit_make_pair'. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-namespaces.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-namespaces.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-namespaces.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-namespaces.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,9 @@ +google-build-namespaces +======================= + + +Finds anonymous namespaces in headers. + +http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Namespaces#Namespaces + +Corresponding cpplint.py check name: 'build/namespaces'. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-using-namespace.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-using-namespace.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-using-namespace.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-using-namespace.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,19 @@ +google-build-using-namespace +============================ + + +Finds using namespace directives. + +http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Namespaces#Namespaces + +The check implements the following rule of the Google C++ Style Guide: + + You may not use a using-directive to make all names from a namespace + available. + + .. code:: c++ + + // Forbidden -- This pollutes the namespace. + using namespace foo; + +Corresponding cpplint.py check name: ``build/namespaces``. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-explicit-constructor.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-explicit-constructor.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-explicit-constructor.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-explicit-constructor.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,7 @@ +google-explicit-constructor +=========================== + + +Checks that all single-argument constructors are explicit. + +See http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Explicit_Constructors Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,6 @@ +google-global-names-in-headers +============================== + + +Flag global namespace pollution in header files. +Right now it only triggers on using declarations and directives. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-braces-around-statements.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-braces-around-statements.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-braces-around-statements.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-braces-around-statements.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,29 @@ +google-readability-braces-around-statements +=========================================== + + +Checks that bodies of ``if`` statements and loops (``for``, ``range-for``, +``do-while``, and ``while``) are inside braces + +Before: + +.. code:: c++ + + if (condition) + statement; + +After: + +.. code:: c++ + + if (condition) { + statement; + } + +Additionally, one can define an option ``ShortStatementLines`` defining the +minimal number of lines that the statement should have in order to trigger +this check. + +The number of lines is counted from the end of condition or initial keyword +(``do``/``else``) until the last line of the inner statement. Default value 0 +means that braces will be added to all statements (not having them already). Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-casting.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-casting.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-casting.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-casting.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,13 @@ +google-readability-casting +========================== + + +Finds usages of C-style casts. + +http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Casting#Casting + +Corresponding cpplint.py check name: 'readability/casting'. + +This check is similar to ``-Wold-style-cast``, but it suggests automated fixes +in some cases. The reported locations should not be different from the +ones generated by ``-Wold-style-cast``. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-function-size.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-function-size.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-function-size.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-function-size.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,15 @@ +google-readability-function-size +================================ + + +Checks for large functions based on various metrics. + +These options are supported: + + * ``LineThreshold`` - flag functions exceeding this number of lines. The + default is ``-1`` (ignore the number of lines). + * ``StatementThreshold`` - flag functions exceeding this number of + statements. This may differ significantly from the number of lines for + macro-heavy code. The default is ``800``. + * ``BranchThreshold`` - flag functions exceeding this number of control + statements. The default is ``-1`` (ignore the number of branches). Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-namespace-comments.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-namespace-comments.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-namespace-comments.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-namespace-comments.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,9 @@ +google-readability-namespace-comments +===================================== + + +Checks that long namespaces have a closing comment. + +http://llvm.org/docs/CodingStandards.html#namespace-indentation + +http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Namespaces Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-redundant-smartptr-get.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-redundant-smartptr-get.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-redundant-smartptr-get.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-redundant-smartptr-get.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,14 @@ +google-readability-redundant-smartptr-get +========================================= + + +Find and remove redundant calls to smart pointer's ``.get()`` method. + +Examples: + +.. code:: c++ + + ptr.get()->Foo() ==> ptr->Foo() + *ptr.get() ==> *ptr + *ptr->get() ==> **ptr + Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-todo.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-todo.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-todo.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-todo.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,7 @@ +google-readability-todo +======================= + + +Finds TODO comments without a username or bug number. + +Corresponding cpplint.py check: 'readability/todo' Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-int.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-int.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-int.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-int.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,8 @@ +google-runtime-int +================== + + +Finds uses of ``short``, ``long`` and ``long long`` and suggest replacing them +with ``u?intXX(_t)?``. + +Correspondig cpplint.py check: 'runtime/int'. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-member-string-references.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-member-string-references.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-member-string-references.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-member-string-references.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,25 @@ +google-runtime-member-string-references +======================================= + + +Finds members of type ``const string&``. + +const string reference members are generally considered unsafe as they can +be created from a temporary quite easily. + +.. code:: c++ + + struct S { + S(const string &Str) : Str(Str) {} + const string &Str; + }; + S instance("string"); + +In the constructor call a string temporary is created from ``const char *`` +and destroyed immediately after the call. This leaves around a dangling +reference. + +This check emit warnings for both ``std::string`` and ``::string`` const +reference members. + +Corresponding cpplint.py check name: 'runtime/member_string_reference'. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-memset.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-memset.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-memset.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-memset.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,10 @@ +google-runtime-memset +===================== + + +Finds calls to memset with a literal zero in the length argument. + +This is most likely unintended and the length and value arguments are +swapped. + +Corresponding cpplint.py check name: 'runtime/memset'. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-operator.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-operator.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-operator.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-operator.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,9 @@ +google-runtime-operator +======================= + + +Finds overloads of unary ``operator &``. + +http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Operator_Overloading#Operator_Overloading + +Corresponding cpplint.py check name: 'runtime/operator'. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,54 @@ +List of clang-tidy Checks +========================= + +.. toctree:: + google-build-explicit-make-pair + google-build-namespaces + google-build-using-namespace + google-explicit-constructor + google-global-names-in-headers + google-readability-braces-around-statements + google-readability-casting + google-readability-function-size + google-readability-namespace-comments + google-readability-redundant-smartptr-get + google-readability-todo + google-runtime-int + google-runtime-member-string-references + google-runtime-memset + google-runtime-operator + llvm-header-guard + llvm-include-order + llvm-namespace-comment + llvm-twine-local + misc-argument-comment + misc-assert-side-effect + misc-assign-operator-signature + misc-bool-pointer-implicit-conversion + misc-inaccurate-erase + misc-inefficient-algorithm + misc-macro-parentheses + misc-macro-repeated-side-effects + misc-move-constructor-init + misc-noexcept-move-constructor + misc-static-assert + misc-swapped-arguments + misc-undelegated-constructor + misc-uniqueptr-reset-release + misc-unused-alias-decls + misc-unused-parameters + misc-unused-raii + misc-use-override + modernize-loop-convert + modernize-pass-by-value + modernize-use-nullptr + readability-braces-around-statements + readability-container-size-empty + readability-else-after-return + readability-function-size + readability-identifier-naming + readability-named-parameter + readability-redundant-smartptr-get + readability-redundant-string-cstr + readability-shrink-to-fit + readability-simplify-boolean-expr \ No newline at end of file Added: clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-header-guard.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-header-guard.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-header-guard.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-header-guard.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,4 @@ +llvm-header-guard +================= + +TODO: add docs Added: clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-include-order.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-include-order.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-include-order.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-include-order.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,7 @@ +llvm-include-order +================== + + +Checks the correct order of ``#includes``. + +See http://llvm.org/docs/CodingStandards.html#include-style Added: clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,9 @@ +llvm-namespace-comment +====================== + + +Checks that long namespaces have a closing comment. + +http://llvm.org/docs/CodingStandards.html#namespace-indentation + +http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Namespaces Added: clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-twine-local.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-twine-local.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-twine-local.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-twine-local.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,6 @@ +llvm-twine-local +================ + + +Looks for local ``Twine`` variables which are prone to use after frees and +should be generally avoided. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,18 @@ +misc-argument-comment +===================== + + +Checks that argument comments match parameter names. + +The check understands argument comments in the form ``/*parameter_name=*/`` +that are placed right before the argument. + +.. code:: c++ + + void f(bool foo); + + ... + f(/*bar=*/true); + // warning: argument name 'bar' in comment does not match parameter name 'foo' + +The check tries to detect typos and suggest automated fixes for them. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assert-side-effect.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assert-side-effect.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assert-side-effect.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assert-side-effect.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,17 @@ +misc-assert-side-effect +======================= + + +Finds ``assert()`` with side effect. + +The condition of ``assert()`` is evaluated only in debug builds so a +condition with side effect can cause different behavior in debug / release +builds. + +There are two options: + + - ``AssertMacros``: A comma-separated list of the names of assert macros to + be checked. + - ``CheckFunctionCalls``: Whether to treat non-const member and non-member + functions as they produce side effects. Disabled by default because it + can increase the number of false positive warnings. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assign-operator-signature.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assign-operator-signature.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assign-operator-signature.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assign-operator-signature.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,10 @@ +misc-assign-operator-signature +============================== + + +Finds declarations of assign operators with the wrong return and/or argument +types. + + * The return type must be ``Class&``. + * Works with move-assign and assign by value. + * Private and deleted operators are ignored. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-bool-pointer-implicit-conversion.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-bool-pointer-implicit-conversion.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-bool-pointer-implicit-conversion.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-bool-pointer-implicit-conversion.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,16 @@ +misc-bool-pointer-implicit-conversion +===================================== + + +Checks for conditions based on implicit conversion from a bool pointer to +bool. + +Example: + +.. code:: c++ + + bool *p; + if (p) { + // Never used in a pointer-specific way. + } + Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inaccurate-erase.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inaccurate-erase.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inaccurate-erase.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inaccurate-erase.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,11 @@ +misc-inaccurate-erase +===================== + + +Checks for inaccurate use of the ``erase()`` method. + +Algorithms like ``remove()`` do not actually remove any element from the +container but return an iterator to the first redundant element at the end +of the container. These redundant elements must be removed using the +``erase()`` method. This check warns when not all of the elements will be +removed due to using an inappropriate overload. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,9 @@ +misc-inefficient-algorithm +========================== + + +Warns on inefficient use of STL algorithms on associative containers. + +Associative containers implements some of the algorithms as methods which +should be preferred to the algorithms in the algorithm header. The methods +can take advanatage of the order of the elements. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-parentheses.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-parentheses.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-parentheses.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-parentheses.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,17 @@ +misc-macro-parentheses +====================== + + +Finds macros that can have unexpected behaviour due to missing parentheses. + +Macros are expanded by the preprocessor as-is. As a result, there can be +unexpected behaviour; operators may be evaluated in unexpected order and +unary operators may become binary operators, etc. + +When the replacement list has an expression, it is recommended to surround +it with parentheses. This ensures that the macro result is evaluated +completely before it is used. + +It is also recommended to surround macro arguments in the replacement list +with parentheses. This ensures that the argument value is calculated +properly. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,5 @@ +misc-macro-repeated-side-effects +================================ + + +Checks for repeated argument with side effects in macros. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,7 @@ +misc-move-constructor-init +========================== + + +The check flags user-defined move constructors that have a ctor-initializer +initializing a member or base class through a copy constructor instead of a +move constructor. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,11 @@ +misc-noexcept-move-constructor +============================== + + +The check flags user-defined move constructors and assignment operators not +marked with ``noexcept`` or marked with ``noexcept(expr)`` where ``expr`` +evaluates to ``false`` (but is not a ``false`` literal itself). + +Move constructors of all the types used with STL containers, for example, +need to be declared ``noexcept``. Otherwise STL will choose copy constructors +instead. The same is valid for move assignment operations. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-static-assert.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-static-assert.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-static-assert.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-static-assert.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,9 @@ +misc-static-assert +================== + + +Replaces ``assert()`` with ``static_assert()`` if the condition is evaluatable +at compile time. + +The condition of ``static_assert()`` is evaluated at compile time which is +safer and more efficient. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-swapped-arguments.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-swapped-arguments.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-swapped-arguments.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-swapped-arguments.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,5 @@ +misc-swapped-arguments +====================== + + +Finds potentially swapped arguments by looking at implicit conversions. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-undelegated-constructor.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-undelegated-constructor.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-undelegated-constructor.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-undelegated-constructor.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,9 @@ +misc-undelegated-constructor +============================ + + +Finds creation of temporary objects in constructors that look like a +function call to another constructor of the same class. + +The user most likely meant to use a delegating constructor or base class +initializer. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-uniqueptr-reset-release.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-uniqueptr-reset-release.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-uniqueptr-reset-release.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-uniqueptr-reset-release.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,15 @@ +misc-uniqueptr-reset-release +============================ + + +Find and replace ``unique_ptr::reset(release())`` with ``std::move()``. + +Example: + +.. code:: c++ + + std::unique_ptr<Foo> x, y; + x.reset(y.release()); -> x = std::move(y); + +If ``y`` is already rvalue, ``std::move()`` is not added. ``x`` and ``y`` can also +be ``std::unique_ptr<Foo>*``. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-alias-decls.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-alias-decls.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-alias-decls.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-alias-decls.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,5 @@ +misc-unused-alias-decls +======================= + + +Finds unused namespace alias declarations. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-parameters.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-parameters.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-parameters.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-parameters.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,6 @@ +misc-unused-parameters +====================== + + +Finds unused parameters and fixes them, so that ``-Wunused-parameter`` can be +turned on. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-raii.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-raii.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-raii.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-raii.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,28 @@ +misc-unused-raii +================ + + +Finds temporaries that look like RAII objects. + +The canonical example for this is a scoped lock. + +.. code:: c++ + + { + scoped_lock(&global_mutex); + critical_section(); + } + +The destructor of the scoped_lock is called before the ``critical_section`` is +entered, leaving it unprotected. + +We apply a number of heuristics to reduce the false positive count of this +check: + + * Ignore code expanded from macros. Testing frameworks make heavy use of + this. + * Ignore types with no user-declared constructor. Those are very unlikely + to be RAII objects. + * Ignore objects at the end of a compound statement (doesn't change + behavior). + * Ignore objects returned from a call. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,5 @@ +misc-use-override +================= + + +Use C++11's ``override`` and remove ``virtual`` where applicable. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,4 @@ +modernize-loop-convert +====================== + + Added: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,4 @@ +modernize-pass-by-value +======================= + + Added: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,4 @@ +modernize-use-nullptr +===================== + + Added: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,29 @@ +readability-braces-around-statements +==================================== + + +Checks that bodies of ``if`` statements and loops (``for``, ``range-for``, +``do-while``, and ``while``) are inside braces + +Before: + +.. code:: c++ + + if (condition) + statement; + +After: + +.. code:: c++ + + if (condition) { + statement; + } + +Additionally, one can define an option ``ShortStatementLines`` defining the +minimal number of lines that the statement should have in order to trigger +this check. + +The number of lines is counted from the end of condition or initial keyword +(``do``/``else``) until the last line of the inner statement. Default value 0 +means that braces will be added to all statements (not having them already). Added: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-container-size-empty.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-container-size-empty.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-container-size-empty.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-container-size-empty.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,14 @@ +readability-container-size-empty +================================ + + +Checks whether a call to the ``size()`` method can be replaced with a call to +``empty()``. + +The emptiness of a container should be checked using the ``empty()`` method +instead of the ``size()`` method. It is not guaranteed that ``size()`` is a +constant-time function, and it is generally more efficient and also shows +clearer intent to use ``empty()``. Furthermore some containers may implement +the ``empty()`` method but not implement the ``size()`` method. Using ``empty()`` +whenever possible makes it easier to switch to another container in the +future. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-else-after-return.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-else-after-return.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-else-after-return.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-else-after-return.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,7 @@ +readability-else-after-return +============================= + + +Flags the usages of ``else`` after ``return``. + +http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return Added: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-function-size.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-function-size.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-function-size.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-function-size.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,15 @@ +readability-function-size +========================= + + +Checks for large functions based on various metrics. + +These options are supported: + + * ``LineThreshold`` - flag functions exceeding this number of lines. The + default is ``-1`` (ignore the number of lines). + * ``StatementThreshold`` - flag functions exceeding this number of + statements. This may differ significantly from the number of lines for + macro-heavy code. The default is ``800``. + * ``BranchThreshold`` - flag functions exceeding this number of control + statements. The default is ``-1`` (ignore the number of branches). Added: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-identifier-naming.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,17 @@ +readability-identifier-naming +============================= + + +Checks for identifiers naming style mismatch. + +This check will try to enforce coding guidelines on the identifiers naming. +It supports ``lower_case``, ``UPPER_CASE``, ``camelBack`` and ``CamelCase`` casing +and tries to convert from one to another if a mismatch is detected. + +It also supports a fixed prefix and suffix that will be prepended or +appended to the identifiers, regardless of the casing. + +Many configuration options are available, in order to be able to create +different rules for different kind of identifier. In general, the +rules are falling back to a more generic rule if the specific case is not +configured. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-named-parameter.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-named-parameter.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-named-parameter.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-named-parameter.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,15 @@ +readability-named-parameter +=========================== + + +Find functions with unnamed arguments. + +The check implements the following rule originating in the Google C++ Style +Guide: + +http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Function_Declarations_and_Definitions#Function_Declarations_and_Definitions + +All parameters should be named, with identical names in the declaration and +implementation. + +Corresponding cpplint.py check name: 'readability/function'. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,14 @@ +readability-redundant-smartptr-get +================================== + + +Find and remove redundant calls to smart pointer's ``.get()`` method. + +Examples: + +.. code:: c++ + + ptr.get()->Foo() ==> ptr->Foo() + *ptr.get() ==> *ptr + *ptr->get() ==> **ptr + Added: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,5 @@ +readability-redundant-string-cstr +================================= + + +Finds unnecessary calls to ``std::string::c_str()``. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,10 @@ +readability-shrink-to-fit +========================= + + +Replace copy and swap tricks on shrinkable containers with the +``shrink_to_fit()`` method call. + +The ``shrink_to_fit()`` method is more readable and more effective than +the copy and swap trick to reduce the capacity of a shrinkable container. +Note that, the ``shrink_to_fit()`` method is only available in C++11 and up. Added: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst Thu Aug 27 13:10:07 2015 @@ -0,0 +1,76 @@ +readability-simplify-boolean-expr +================================= + + +Looks for boolean expressions involving boolean constants and simplifies +them to use the appropriate boolean expression directly. + +Examples: + +=========================================== ================ +Initial expression Result +------------------------------------------- ---------------- +``if (b == true)`` ``if (b)`` +``if (b == false)`` ``if (!b)`` +``if (b && true)`` ``if (b)`` +``if (b && false)`` ``if (false)`` +``if (b || true)`` ``if (true)`` +``if (b || false)`` ``if (b)`` +``e ? true : false`` ``e`` +``e ? false : true`` ``!e`` +``if (true) t(); else f();`` ``t();`` +``if (false) t(); else f();`` ``f();`` +``if (e) return true; else return false;`` ``return e;`` +``if (e) return false; else return true;`` ``return !e;`` +``if (e) b = true; else b = false;`` ``b = e;`` +``if (e) b = false; else b = true;`` ``b = !e;`` +``if (e) return true; return false;`` ``return e;`` +``if (e) return false; return true;`` ``return !e;`` +=========================================== ================ + +The resulting expression ``e`` is modified as follows: + 1. Unnecessary parentheses around the expression are removed. + 2. Negated applications of ``!`` are eliminated. + 3. Negated applications of comparison operators are changed to use the + opposite condition. + 4. Implicit conversions of pointer to ``bool`` are replaced with explicit + comparisons to ``nullptr``. + 5. Implicit casts to ``bool`` are replaced with explicit casts to ``bool``. + 6. Object expressions with ``explicit operator bool`` conversion operators + are replaced with explicit casts to ``bool``. + +Examples: + 1. The ternary assignment ``bool b = (i < 0) ? true : false;`` has redundant + parentheses and becomes ``bool b = i < 0;``. + + 2. The conditional return ``if (!b) return false; return true;`` has an + implied double negation and becomes ``return b;``. + + 3. The conditional return ``if (i < 0) return false; return true;`` becomes + ``return i >= 0;``. + + The conditional return ``if (i != 0) return false; return true;`` becomes + ``return i == 0;``. + + 4. The conditional return ``if (p) return true; return false;`` has an + implicit conversion of a pointer to ``bool`` and becomes + ``return p != nullptr;``. + + The ternary assignment ``bool b = (i & 1) ? true : false;`` has an + implicit conversion of ``i & 1`` to ``bool`` and becomes + ``bool b = static_cast<bool>(i & 1);``. + + 5. The conditional return ``if (i & 1) return true; else return false;`` has + an implicit conversion of an integer quantity ``i & 1`` to ``bool`` and + becomes ``return static_cast<bool>(i & 1);`` + + 6. Given ``struct X { explicit operator bool(); };``, and an instance ``x`` of + ``struct X``, the conditional return ``if (x) return true; return false;`` + becomes ``return static_cast<bool>(x);`` + +When a conditional boolean return or assignment appears at the end of a +chain of ``if``, ``else if`` statements, the conditional statement is left +unchanged unless the option ``ChainedConditionalReturn`` or +``ChainedConditionalAssignment``, respectively, is specified as non-zero. +The default value for both options is zero. + Copied: clang-tools-extra/trunk/docs/clang-tidy/index.rst (from r246170, clang-tools-extra/trunk/docs/clang-tidy.rst) URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?p2=clang-tools-extra/trunk/docs/clang-tidy/index.rst&p1=clang-tools-extra/trunk/docs/clang-tidy.rst&r1=246170&r2=246173&rev=246173&view=diff ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy.rst (original) +++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Thu Aug 27 13:10:07 2015 @@ -2,6 +2,12 @@ Clang-Tidy ========== +.. toctree:: + :maxdepth: 1 + + checks/list + + :program:`clang-tidy` is a clang-based C++ linter tool. Its purpose is to provide an extensible framework for diagnosing and fixing typical programming errors, like style violations, interface misuse, or bugs that can be deduced via @@ -248,12 +254,14 @@ The Directory Structure |-- ClangTidyModuleRegistry.h # Interface for registering of modules. ... |-- google/ # Google clang-tidy module. - |-- |-- GoogleTidyModule.cpp - |-- |-- GoogleTidyModule.h + |-+ + |-- GoogleTidyModule.cpp + |-- GoogleTidyModule.h ... |-- llvm/ # LLVM clang-tidy module. - |-- |-- LLVMTidyModule.cpp - |-- |-- LLVMTidyModule.h + |-+ + |-- LLVMTidyModule.cpp + |-- LLVMTidyModule.h ... |-- tool/ # Sources of the clang-tidy binary. ... Added: clang-tools-extra/trunk/docs/clang-tidy/tools/dump_check_docs.py URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/tools/dump_check_docs.py?rev=246173&view=auto ============================================================================== --- clang-tools-extra/trunk/docs/clang-tidy/tools/dump_check_docs.py (added) +++ clang-tools-extra/trunk/docs/clang-tidy/tools/dump_check_docs.py Thu Aug 27 13:10:07 2015 @@ -0,0 +1,79 @@ +#!/usr/bin/python + +r""" +Create stubs for check documentation files. +""" + +import os +import re +import sys + +def main(): + clang_tidy_dir = os.path.normpath( + os.path.join(os.path.dirname(sys.argv[0]), '..', '..', '..', + 'clang-tidy')) + + checks_doc_dir = os.path.normpath( + os.path.join(clang_tidy_dir, '..', 'docs', 'clang-tidy', 'checks')) + + registered_checks = {} + defined_checks = {} + + for dir_name, subdir_list, file_list in os.walk(clang_tidy_dir): + print('Processing directory ' + dir_name + '...') + for file_name in file_list: + full_name = os.path.join(dir_name, file_name) + if file_name.endswith('Module.cpp'): + print('Module ' + file_name) + with open(full_name, 'r') as f: + text = f.read() + for class_name, check_name in re.findall( + r'\.\s*registerCheck\s*<\s*([A-Za-z0-9:]+)\s*>\(\s*"([a-z0-9-]+)"', + text): + registered_checks[check_name] = class_name + elif file_name.endswith('.h'): + print(' ' + file_name + '...') + with open(full_name, 'r') as f: + text = f.read() + for comment, _, _, class_name in re.findall( + r'((([\r\n]//)[^\r\n]*)*)\s+class (\w+)\s*:' + + '\s*public\s+ClangTidyCheck\s*\{', text): + defined_checks[class_name] = comment + + print('Registered checks [%s]: [%s]' % + (len(registered_checks), registered_checks)) + print('Check implementations: %s' % len(defined_checks)) + + checks = registered_checks.keys() + checks.sort() + + for check_name in checks: + doc_file_name = os.path.join(checks_doc_dir, check_name + '.rst') + #if os.path.exists(doc_file_name): + # print('Skipping existing file %s...') + # continue + print('Updating %s...' % doc_file_name) + with open(doc_file_name, 'w') as f: + class_name = re.sub(r'.*:', '', registered_checks[check_name]) + f.write(check_name + '\n' + ('=' * len(check_name)) + '\n\n') + if class_name in defined_checks: + text = defined_checks[class_name] + text = re.sub(r'\n//+ ?(\\brief )?', r'\n', text) + text = re.sub(r'(\n *)\\code\n', r'\1.. code:: c++\n\n', text) + text = re.sub(r'(\n *)\\endcode(\n|$)', r'\n', text) + text = re.sub(r'`', r'``', text) + f.write(text + '\n') + else: + f.write('TODO: add docs\n') + + with open(os.path.join(checks_doc_dir, 'list.rst'), 'w') as f: + f.write( +r"""List of clang-tidy Checks +========================= + +.. toctree:: + """ + '\n '.join(checks)) + + +if __name__ == '__main__': + main() Propchange: clang-tools-extra/trunk/docs/clang-tidy/tools/dump_check_docs.py ------------------------------------------------------------------------------ svn:executable = * Modified: clang-tools-extra/trunk/docs/index.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/index.rst?rev=246173&r1=246172&r2=246173&view=diff ============================================================================== --- clang-tools-extra/trunk/docs/index.rst (original) +++ clang-tools-extra/trunk/docs/index.rst Thu Aug 27 13:10:07 2015 @@ -16,7 +16,7 @@ Contents :maxdepth: 1 clang-modernize - clang-tidy + clang-tidy/index modularize pp-trace _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits