llvm-project/clang-tools-extra/docs
Nathan James b859c39c40
[clang-tidy] Add a Standalone diagnostics mode to clang-tidy
Adds a flag to `ClangTidyContext` that is used to indicate to checks that fixes will only be applied one at a time.
This is to indicate to checks that each fix emitted should not depend on any other fixes emitted across the translation unit.
I've currently implemented the `IncludeInserter`, `LoopConvertCheck` and `PreferMemberInitializerCheck` to use these support these modes.

Reasoning behind this is in use cases like `clangd` it's only possible to apply one fix at a time.
For include inserter checks, the include is only added once for the first diagnostic that requires it, this will result in subsequent fixes not having the included needed.

A similar issue is seen in the `PreferMemberInitializerCheck` where the `:` will only be added for the first member that needs fixing.

Fixes emitted in `StandaloneDiagsMode` will likely result in malformed code if they are applied all together, conversely fixes currently emitted may result in malformed code if they are applied one at a time.
For this reason invoking `clang-tidy` from the binary will always with `StandaloneDiagsMode` disabled, However using it as a library its possible to select the mode you wish to use, `clangd` always selects `StandaloneDiagsMode`.

This is an example of the current behaviour failing
```lang=c++
struct Foo {
  int A, B;
  Foo(int D, int E) {
    A = D;
    B = E; // Fix Here
  }
};
```
Incorrectly transformed to:
```lang=c++
struct Foo {
  int A, B;
  Foo(int D, int E), B(E) {
    A = D;
     // Fix Here
  }
};
```
In `StandaloneDiagsMode`, it gets transformed to:
```lang=c++
struct Foo {
  int A, B;
  Foo(int D, int E) : B(E) {
    A = D;
     // Fix Here
  }
};
```

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D97121
2022-04-16 09:53:35 +01:00
..
_static
_templates [clangd] Redirect documentation to clangd.llvm.org. 2020-03-12 11:45:40 +01:00
clang-tidy [clang-tidy] Add portability-std-allocator-const check 2022-04-14 11:13:41 -07:00
clangd [clangd] Add README pointing to docs, bugtracker etc. NFC 2020-03-12 14:00:08 +01:00
CMakeLists.txt
ModularizeUsage.rst
README.txt
ReleaseNotes.rst [clang-tidy] Add a Standalone diagnostics mode to clang-tidy 2022-04-16 09:53:35 +01:00
clang-doc.rst Update Bug report URL to Github Issues 2022-01-06 17:33:25 +08:00
clang-include-fixer.rst [docs] Update path to clang-tools-extra 2020-01-02 19:30:29 +08:00
clang-modernize.rst
clang-rename.rst [Branch-Rename] Fix some links 2021-02-01 16:43:21 +05:30
clang-tidy.rst
clangd.rst [clangd] Redirect documentation to clangd.llvm.org. 2020-03-12 11:45:40 +01:00
conf.py [docs] Remove hard-coded version numbers from sphinx configs 2022-02-01 23:14:12 -08:00
cpp11-migrate.rst
doxygen-mainpage.dox
doxygen.cfg.in [NFC] Inclusive Language: change master to main for .chm files 2021-11-08 08:23:04 -06:00
index.rst [clangd] Redirect documentation to clangd.llvm.org. 2020-03-12 11:45:40 +01:00
make.bat
modularize.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
pp-trace.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00

README.txt

----------------------------------
Documentation in clang-tools-extra
----------------------------------

To generate documentation in HTML format from files in clang-tools-extra/docs,
build the docs-clang-tools-html target.

To generate documentation from the source code using Doxygen, build the
doxygen-clang-tools target.