You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tools/README.md
+19-10Lines changed: 19 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,34 +59,43 @@ To use Clang-Tidy, you need to have O2Physics compiled and a valid symbolic link
59
59
60
60
The [`readability-identifier-naming`](https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html) check can fix deviations from the [naming conventions](https://rawgit.com/AliceO2Group/CodingGuidelines/master/naming_formatting.html).
61
61
62
-
### Cleaning `#include`s
62
+
### Cleaning `#include` statements and `using` statements
63
63
64
-
The [`misc-include-cleaner`](https://clang.llvm.org/extra/clang-tidy/checks/misc/include-cleaner.html) check can fix missing and unused `#include`s.
65
-
This helps to apply the [Include What You Use](https://github.com/AliceO2Group/O2Physics/issues/8357) principle which allows to maintain header dependencies clean.
64
+
```danger
65
+
Incorrect usage of `#include` statements and `using` statements causes [unnecessary recompilations](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md#fewer-recompiles) and can [break compilation](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md#allow-refactoring) of other parts of the project! (See also [Management of header dependencies](https://indico.cern.ch/event/1513750/#29-management-of-header-depend).)
66
+
```
67
+
68
+
The [`misc-include-cleaner`](https://clang.llvm.org/extra/clang-tidy/checks/misc/include-cleaner.html) check can fix missing and unused `#include` statements.
69
+
This helps to apply the [Include What You Use](https://github.com/AliceO2Group/O2Physics/issues/8357) (IWYU) principle which allows to maintain header dependencies clean.
70
+
The behaviour of the check can be tuned manually using [IWYU pragmas](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md).
71
+
72
+
The [`google-global-names-in-headers`](https://clang.llvm.org/extra/clang-tidy/checks/google/global-names-in-headers.html) check finds `using` declarations and directives in headers, which cause [global namespace pollution](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#rs-using-directive) that can be difficult to fix.
73
+
74
+
The [`misc-unused-using-decls`](https://clang.llvm.org/extra/clang-tidy/checks/misc/unused-using-decls.html) check finds unused `using` declarations in source files, which create fake dependencies that hamper IWYU.
66
75
67
76
### Testing (and fixing) many files at once
68
77
69
-
Here is an example of how to run the `misc-include-cleaner` check in parallel on all `.h`, `.cxx`, `.C` files in the current directory.
78
+
Here is an example of how to run selected checks in parallel on all `.h`, `.cxx`, `.C` files in the current directory (`.`).
The [`parallel`](https://www.gnu.org/software/parallel/) command is used to parallelise the execution of the `clang-tidy` command for all files.
76
85
77
-
For each file, Clang-Tidy will first try to compile it and then run the enabled check(s) and fix found problems (the `--fix` option).
86
+
For each file, Clang-Tidy will first try to compile it and then run the enabled check(s) and fix found problems (the `-fix` option).
78
87
The messages are redirected into `clang-tidy.log`.
79
88
The file name and the exit code are printed below the output of Clang-Tidy so that you can get the list of files for which Clang-Tidy failed with `grep " 1$" "clang-tidy.log"`.
80
89
81
90
## Fixing include format
82
91
83
92
Headers from the same project should be included using quotation marks (`#include "path/header.h"`), all other headers should be included using angle brackets (`#include <path/header.h>`).
84
-
Failing to do so can result in picking a wrong header.
85
-
See more details in the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf12-prefer-the-quoted-form-of-include-for-files-relative-to-the-including-file-and-the-angle-bracket-form-everywhere-else).
93
+
Failing to do so points the preprocessor to a [wrong location](https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html) and can result in picking a wrong header.
94
+
See also the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf12-prefer-the-quoted-form-of-include-for-files-relative-to-the-including-file-and-the-angle-bracket-form-everywhere-else).
86
95
87
96
The [`format_includes.awk`](https://github.com/AliceO2Group/O2Physics/blob/master/Scripts/format_includes.awk) script allows to fix the include format in a provided O2Physics file.
88
97
89
-
To fix the include format in all `.h`, `.cxx` files in the current directory, execute:
98
+
To fix the include format in all `.h`, `.cxx` files in the current directory (`.`), execute:
0 commit comments