aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/docs
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/docs')
-rw-r--r--clang-tools-extra/docs/ReleaseNotes.rst39
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/invalid-enum-default-initialization.rst72
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/list.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/llvm/use-new-mlir-op-builder.rst21
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/readability/qualified-auto.rst42
5 files changed, 175 insertions, 1 deletions
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index c75d9ca..e45f870 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -101,9 +101,25 @@ Improvements to clang-query
Improvements to clang-tidy
--------------------------
+- The :program:`run-clang-tidy.py` and :program:`clang-tidy-diff.py` scripts
+ now run checks in parallel by default using all available hardware threads.
+ Both scripts display the number of threads being used in their output.
+
New checks
^^^^^^^^^^
+- New :doc:`bugprone-invalid-enum-default-initialization
+ <clang-tidy/checks/bugprone/invalid-enum-default-initialization>` check.
+
+ Detects default initialization (to 0) of variables with ``enum`` type where
+ the enum has no enumerator with value of 0.
+
+- New :doc:`llvm-mlir-op-builder
+ <clang-tidy/checks/llvm/use-new-mlir-op-builder>` check.
+
+ Checks for uses of MLIR's old/to be deprecated ``OpBuilder::create<T>`` form
+ and suggests using ``T::create`` instead.
+
New check aliases
^^^^^^^^^^^^^^^^^
@@ -114,6 +130,10 @@ Changes in existing checks
<clang-tidy/checks/bugprone/infinite-loop>` check by adding detection for
variables introduced by structured bindings.
+- Improved :doc:`bugprone-signed-char-misuse
+ <clang-tidy/checks/bugprone/signed-char-misuse>` check by fixing
+ false positives on C23 enums with the fixed underlying type of signed char.
+
- Improved :doc:`bugprone-unhandled-self-assignment
<clang-tidy/checks/bugprone/unhandled-self-assignment>` check by adding
an additional matcher that generalizes the copy-and-swap idiom pattern
@@ -122,10 +142,28 @@ Changes in existing checks
- Improved :doc:`misc-header-include-cycle
<clang-tidy/checks/misc/header-include-cycle>` check performance.
+- Improved :doc:`modernize-use-designated-initializers
+ <clang-tidy/checks/modernize/use-designated-initializers>` check to
+ suggest using designated initializers for aliased aggregate types.
+
+- Improved :doc:`modernize-use-std-format
+ <clang-tidy/checks/modernize/use-std-format>` check to correctly match
+ when the format string is converted to a different type by an implicit
+ constructor call.
+
+- Improved :doc:`modernize-use-std-print
+ <clang-tidy/checks/modernize/use-std-print>` check to correctly match
+ when the format string is converted to a different type by an implicit
+ constructor call.
+
- Improved :doc:`portability-template-virtual-member-function
<clang-tidy/checks/portability/template-virtual-member-function>` check to
avoid false positives on pure virtual member functions.
+- Improved :doc:`readability-qualified-auto
+ <clang-tidy/checks/readability/qualified-auto>` check by adding the option
+ `IgnoreAliasing`, that allows not looking at underlying types of type aliases.
+
Removed checks
^^^^^^^^^^^^^^
@@ -152,4 +190,3 @@ Improvements to pp-trace
Clang-tidy Visual Studio plugin
-------------------------------
-
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/invalid-enum-default-initialization.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/invalid-enum-default-initialization.rst
new file mode 100644
index 0000000..a3bd2b6
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/invalid-enum-default-initialization.rst
@@ -0,0 +1,72 @@
+.. title:: clang-tidy - bugprone-invalid-enum-default-initialization
+
+bugprone-invalid-enum-default-initialization
+============================================
+
+Detects default initialization (to 0) of variables with ``enum`` type where
+the enum has no enumerator with value of 0.
+
+In C++ a default initialization is performed if a variable is initialized with
+initializer list or in other implicit ways, and no value is specified at the
+initialization. In such cases the value 0 is used for the initialization.
+This also applies to enumerations even if it does not have an enumerator with
+value 0. In this way a variable with the ``enum`` type may contain initially an
+invalid value (if the program expects that it contains only the listed
+enumerator values).
+
+The check emits a warning only if an ``enum`` variable is default-initialized
+(contrary to not initialized) and the ``enum`` does not have an enumerator with
+value of 0. The type can be a scoped or non-scoped ``enum``. Unions are not
+handled by the check (if it contains a member of enumeration type).
+
+.. code-block:: c++
+
+ enum class Enum1: int {
+ A = 1,
+ B
+ };
+
+ enum class Enum0: int {
+ A = 0,
+ B
+ };
+
+ void f() {
+ Enum1 X1{}; // warn: 'X1' is initialized to 0
+ Enum1 X2 = Enum1(); // warn: 'X2' is initialized to 0
+ Enum1 X3; // no warning: 'X3' is not initialized
+ Enum0 X4{}; // no warning: type has an enumerator with value of 0
+ }
+
+ struct S1 {
+ Enum1 A;
+ S(): A() {} // warn: 'A' is initialized to 0
+ };
+
+ struct S2 {
+ int A;
+ Enum1 B;
+ };
+
+ S2 VarS2{}; // warn: member 'B' is initialized to 0
+
+The check applies to initialization of arrays or structures with initialization
+lists in C code too. In these cases elements not specified in the list (and have
+enum type) are set to 0.
+
+.. code-block:: c
+
+ enum Enum1 {
+ Enum1_A = 1,
+ Enum1_B
+ };
+ struct Struct1 {
+ int a;
+ enum Enum1 b;
+ };
+
+ enum Enum1 Array1[2] = {Enum1_A}; // warn: omitted elements are initialized to 0
+ enum Enum1 Array2[2][2] = {{Enum1_A}, {Enum1_A}}; // warn: last element of both nested arrays is initialized to 0
+ enum Enum1 Array3[2][2] = {{Enum1_A, Enum1_A}}; // warn: elements of second array are initialized to 0
+
+ struct Struct1 S1 = {1}; // warn: element 'b' is initialized to 0
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 0cffbd3..b6444eb 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -106,6 +106,7 @@ Clang-Tidy Checks
:doc:`bugprone-incorrect-roundings <bugprone/incorrect-roundings>`,
:doc:`bugprone-infinite-loop <bugprone/infinite-loop>`,
:doc:`bugprone-integer-division <bugprone/integer-division>`,
+ :doc:`bugprone-invalid-enum-default-initialization <bugprone/invalid-enum-default-initialization>`,
:doc:`bugprone-lambda-function-name <bugprone/lambda-function-name>`,
:doc:`bugprone-macro-parentheses <bugprone/macro-parentheses>`, "Yes"
:doc:`bugprone-macro-repeated-side-effects <bugprone/macro-repeated-side-effects>`,
@@ -247,6 +248,7 @@ Clang-Tidy Checks
:doc:`linuxkernel-must-check-errs <linuxkernel/must-check-errs>`,
:doc:`llvm-header-guard <llvm/header-guard>`,
:doc:`llvm-include-order <llvm/include-order>`, "Yes"
+ :doc:`llvm-use-new-mlir-op-builder <llvm/use-new-mlir-op-builder>`, "Yes"
:doc:`llvm-namespace-comment <llvm/namespace-comment>`,
:doc:`llvm-prefer-isa-or-dyn-cast-in-conditionals <llvm/prefer-isa-or-dyn-cast-in-conditionals>`, "Yes"
:doc:`llvm-prefer-register-over-unsigned <llvm/prefer-register-over-unsigned>`, "Yes"
diff --git a/clang-tools-extra/docs/clang-tidy/checks/llvm/use-new-mlir-op-builder.rst b/clang-tools-extra/docs/clang-tidy/checks/llvm/use-new-mlir-op-builder.rst
new file mode 100644
index 0000000..dc1989d
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/llvm/use-new-mlir-op-builder.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - llvm-use-new-mlir-op-builder
+
+llvm-mlir-op-builder
+====================
+
+Checks for uses of MLIR's old/to be deprecated ``OpBuilder::create<T>`` form
+and suggests using ``T::create`` instead.
+
+Example
+-------
+
+.. code-block:: c++
+
+ builder.create<FooOp>(builder.getUnknownLoc(), "baz");
+
+
+Transforms to:
+
+.. code-block:: c++
+
+ FooOp::create(builder, builder.getUnknownLoc(), "baz");
diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability/qualified-auto.rst b/clang-tools-extra/docs/clang-tidy/checks/readability/qualified-auto.rst
index efa0857..34390e2 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability/qualified-auto.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability/qualified-auto.rst
@@ -96,3 +96,45 @@ Note in the LLVM alias, the default value is `false`.
matched against only the type name (i.e. ``Type``). E.g. to suppress reports
for ``std::array`` iterators use `std::array<.*>::(const_)?iterator` string.
The default is an empty string.
+
+.. option:: IgnoreAliasing
+
+ If set to `true` the check will use the underlying type to determine the type
+ that ``auto`` is deduced to. If set to `false` the check will not look beyond
+ the first type alias.
+ Default value is `true`.
+
+ .. code-block:: c++
+
+ using IntPtr = int*;
+ IntPtr foo();
+
+ auto bar = foo();
+
+ If :option:`IgnoreAliasing` is set to `true`, it will be transformed into:
+
+ .. code-block:: c++
+
+ auto *bar = foo();
+
+ Otherwise no changes will occur.
+
+Limitations
+-----------
+
+When :option:`IgnoreAliasing` is set to `false`, there are cases where
+Clang has not preserved the type alias and the underlying type will be used so
+false positives may occur.
+
+For example:
+
+.. code-block:: c++
+
+ using IntPtr = int *;
+
+ void loopPtr(const std::vector<IntPtr> &VectorIntPtr) {
+
+ // May fail for IgnoreAliasing==false as AST does not have the 'IntPtr'
+ for (auto Data : VectorIntPtr) {
+ }
+ }