Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fab9256
[LLVM][AArch64] Fix invalid use of AArch64ISD::UZP2 in performConcatV…
paulwalker-arm Aug 30, 2024
68d8b38
[builtins] Fix missing main() function in float16/bfloat16 support ch…
overmighty Aug 30, 2024
b065ec0
[Inline][X86] Regenerate inline-target-cpu-* tests
RKSimon Aug 30, 2024
fda7649
[InstCombine][X86] Split off vperm shuffle tests from other avx512 tests
RKSimon Aug 30, 2024
6345604
Revert: [AMDGPU] Graph-based Module Splitting Rewrite (llvm#104763) (…
dklimkin Aug 30, 2024
2d5613a
[dsymutil] return EXIT_FAILURE when Crashed (#106619)
rmaz Aug 30, 2024
87a988e
[SLP]Fix PR106655: Use FinalShuffle for alternate cast nodes.
alexey-bataev Aug 30, 2024
ce5620b
[LLVM][VPlan] Pick more optimal initial value for VPBlend. (#104019)
paulwalker-arm Aug 30, 2024
64f1995
Fix stack overflow in allPathsGoThroughCold past 6b11573b8c5e (#106384)
dklimkin Aug 30, 2024
ceb613a
[RISCV] Add full test coverage for acos/asin/atan and cosh/sinh/tanh …
RKSimon Aug 30, 2024
8586d03
[flang] Don't generate empty else blocks (#106618)
vdonaldson Aug 30, 2024
2a8fda4
LICM: extend hoistAddSub to unsigned case (#106373)
artagnon Aug 30, 2024
86a60e7
[AVR] Fix parsing & emitting relative jumps (#106722)
Patryk27 Aug 30, 2024
a919588
[compiler-rt][rtsan] NFC: Rename rtsan_on->rtsan_enable rtsan_off->rt…
cjappl Aug 30, 2024
7ffe67c
[RemoveDIs] Fix asan-identified leak in unittest (#106723)
OCHyams Aug 30, 2024
4a10b4c
[flang] fix flang builds with clang 20 after #100692 (#106718)
jeanPerier Aug 30, 2024
96ad495
[SLP] vectorizeChainsInBlock - remove superfluous continue at the end…
RKSimon Aug 30, 2024
b719c92
[SLP] findBestRootPair - fix incorrect argument name comment. NFC.
RKSimon Aug 30, 2024
362d37a
Update clang tidy Contributing guide (#106672)
MichelleCDjunaidi Aug 30, 2024
2497739
[AArch64][AsmParser] Directives should clear transitively implied fea…
labrinea Aug 30, 2024
c792de2
[libcxx][test] Add macro for when long double is just double (#106708)
DavidSpickett Aug 30, 2024
f4ea19b
[libc++][syncbuf] Implement LWG3253 (#99778)
mordante Aug 30, 2024
ab40ae8
[lldb] Store SupportFiles in SourceManager::File (NFC) (#106639)
JDevlieghere Aug 30, 2024
b0eefb4
[lldb] Update SupportFile documentation (NFC)
JDevlieghere Aug 29, 2024
0c4cf79
[clang] Install scan-build-py into plain "lib" directory (#106612)
mgorny Aug 29, 2024
369d814
[ValueTracking] use KnownBits to compute fpclass from bitcast (#97762)
AlexMaclean Aug 30, 2024
c4a5381
[test-suite] Document the LLVM test-suite benchmark apps (#105843)
sjoerdmeijer Aug 30, 2024
ece6566
[MLIR][NVVM] Add support for fence.proxy.{acquire, release} Ops (#106…
schwarzschild-radius Aug 30, 2024
fef3426
Revert "[LLVM][rtsan] Add LLVM nosanitize_realtime attribute (#105447…
cjappl Aug 30, 2024
82a5ab7
[X86] x86-vperm.ll - strip superfluous semicolon check lines. NFC.
RKSimon Aug 30, 2024
d01e0f7
[InstCombine][X86] Add vpermv/vpermv3 test coverage for #106413
RKSimon Aug 30, 2024
a3816b5
[AVR] Fix LLD test (#106739)
Patryk27 Aug 30, 2024
d69cbed
[LLVM][rtsan] Add LLVM attribute sanitize_realtime_unsafe
davidtrevelyan Aug 30, 2024
04c350b
Add sanitize_realtime_unsafe attribute verification
davidtrevelyan Aug 30, 2024
689f19b
Revert whitespace changes in LangRef.rst
davidtrevelyan Aug 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 46 additions & 18 deletions clang-tools-extra/docs/clang-tidy/Contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@ Writing a clang-tidy Check

So you have an idea of a useful check for :program:`clang-tidy`.

First, if you're not familiar with LLVM development, read through the `Getting
Started with LLVM`_ document for instructions on setting up your workflow and
First, if you're not familiar with LLVM development, read through the `Getting Started
with the LLVM System`_ document for instructions on setting up your workflow and
the `LLVM Coding Standards`_ document to familiarize yourself with the coding
style used in the project. For code reviews we mostly use `LLVM Phabricator`_.
style used in the project. For code reviews we currently use `LLVM Github`_,
though historically we used Phabricator.

.. _Getting Started with LLVM: https://llvm.org/docs/GettingStarted.html
.. _Getting Started with the LLVM System: https://llvm.org/docs/GettingStarted.html
.. _LLVM Coding Standards: https://llvm.org/docs/CodingStandards.html
.. _LLVM Phabricator: https://llvm.org/docs/Phabricator.html
.. _LLVM Github: https://github.com/llvm/llvm-project

Next, you need to decide which module the check belongs to. Modules
are located in subdirectories of `clang-tidy/
Expand Down Expand Up @@ -336,13 +337,24 @@ a starting point for your test cases. A rough outline of the process looks like
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. 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 matcher, the
C++ API will be virtually identical to your interactively constructed matcher. You can
use local variables to preserve your intention-revealing names that you applied to
nested matchers.
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.

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 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
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -646,10 +658,13 @@ directory. The path to this directory is available in a lit test with the varia
Out-of-tree check plugins
-------------------------


Developing an out-of-tree check as a plugin largely follows the steps
outlined above. The plugin is a shared library whose code lives outside
outlined above, including creating a new module and doing the hacks to
register the module. The plugin is a shared library whose code lives outside
the clang-tidy build system. Build and link this shared library against
LLVM as done for other kinds of Clang plugins.
LLVM as done for other kinds of Clang plugins. If using CMake, use the keyword
``MODULE`` while invoking ``add_library`` or ``llvm_add_library``.

The plugin can be loaded by passing `-load` to `clang-tidy` in addition to the
names of the checks to enable.
Expand All @@ -664,6 +679,19 @@ compiled against the version of clang-tidy that will be loading the plugin.
The plugins can use threads, TLS, or any other facilities available to in-tree
code which is accessible from the external headers.

Note that testing out-of-tree checks might involve getting ``llvm-lit`` from an LLVM
installation compiled from source. See `Getting Started with the LLVM System`_ for ways
to do so.

Alternatively, get `lit`_ following the `test-suite guide`_ and get the `FileCheck`_ binary,
and write a version of `check_clang_tidy.py`_ to suit your needs.

.. _Getting Started with the LLVM System: https://llvm.org/docs/GettingStarted.html
.. _test-suite guide: https://llvm.org/docs/TestSuiteGuide.html
.. _lit: https://llvm.org/docs/CommandGuide/lit.html
.. _FileCheck: https://llvm.org/docs/CommandGuide/FileCheck.html
.. _check_clang_tidy.py: https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Running clang-tidy on LLVM
--------------------------

Expand All @@ -688,10 +716,10 @@ warnings and errors. The script provides multiple configuration flags.

* 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
``run-clang-tidy.py clang-tidy/.*Check\.cpp`` will only analyze `clang-tidy`
checks. It may also be necessary to restrict the header files that warnings
are displayed from using the ``-header-filter`` flag. It has the same behavior
as the corresponding :program:`clang-tidy` flag.
are displayed from by using the ``-header-filter`` and ``-exclude-header-filter`` flags.
They have the same behavior as the corresponding :program:`clang-tidy` flags.

* To apply suggested fixes ``-fix`` can be passed as an argument. This gathers
all changes in a temporary directory and applies them. Passing ``-format``
Expand Down Expand Up @@ -758,4 +786,4 @@ There is only one argument that controls profile storage:

* If you run :program:`clang-tidy` from within ``/foo`` directory, and specify
``-store-check-profile=.``, then the profile will still be saved to
``/foo/<ISO8601-like timestamp>-example.cpp.json``
``/foo/<ISO8601-like timestamp>-example.cpp.json``
Loading