[clang-tools-extra] r290838 - Extend documentation of how to test clang-tidy checks.

James Dennett via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 2 13:45:34 PST 2017


Author: jdennett
Date: Mon Jan  2 15:45:34 2017
New Revision: 290838

URL: http://llvm.org/viewvc/llvm-project?rev=290838&view=rev
Log:
Extend documentation of how to test clang-tidy checks.

Summary:
The documentation assumed expertise with FileCheck; many clang-tidy check
authors may not have significant exposure to FileCheck, and so it's worth
spending a few more words here to spell things out.

Reviewers: alexfh

Subscribers: cfe-commits, JDevlieghere

Differential Revision: https://reviews.llvm.org/D28189

Modified:
    clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=290838&r1=290837&r2=290838&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Mon Jan  2 15:45:34 2017
@@ -546,7 +546,26 @@ 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
+separate `FileCheck`_ invocations: once with FileCheck's directive
+prefix set to ``CHECK-MESSAGES``, validating the diagnostic messages,
+and once with the directive prefix set to ``CHECK-FIXES``, running
+against the fixed code (i.e., the code after generated fixits are
+applied). In particular, ``CHECK-FIXES:`` can be used to check
+that code was not modified by fixits, by checking that it is present
+unchanged in the fixed code.  The full set of `FileCheck`_ directives
+is available (e.g., ``CHECK-MESSAGES-SAME:``, ``CHECK-MESSAGES-NOT:``), though
+typically the basic ``CHECK`` forms (``CHECK-MESSAGES`` and ``CHECK-FIXES``)
+are sufficient for clang-tidy tests.  Note that the `FileCheck`_
+documentation mostly assumes the default prefix (``CHECK``), and hence
+describes the directive as ``CHECK:``, ``CHECK-SAME:``, ``CHECK-NOT:``, etc.
+Replace ``CHECK`` by either ``CHECK-FIXES`` or ``CHECK-MESSAGES`` for
+clang-tidy tests.
+
+An additional check enabled by ``check_clang_tidy.py`` ensures that
+if `CHECK-MESSAGES:` is used in a file then every warning or error
+must have an associated CHECK in that file.
+
+To use the ``check_clang_tidy.py`` 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.




More information about the cfe-commits mailing list