58 lines · plain
1.. title:: clang-tidy - bugprone-unused-local-non-trivial-variable2 3bugprone-unused-local-non-trivial-variable4==========================================5 6Warns when a local non trivial variable is unused within a function.7The following types of variables are excluded from this check:8 9* trivial and trivially copyable10* references and pointers11* exception variables in catch clauses12* static or thread local13* structured bindings14* variables with ``[[maybe_unused]]`` attribute15* name-independent variables16 17This check can be configured to warn on all non-trivial variables by setting18`IncludeTypes` to `.*`, and excluding specific types using `ExcludeTypes`.19 20In the this example, `my_lock` would generate a warning that it is unused.21 22.. code-block:: c++23 24 std::mutex my_lock;25 // my_lock local variable is never used26 27In the next example, `future2` would generate a warning that it is unused.28 29.. code-block:: c++30 31 std::future<MyObject> future1;32 std::future<MyObject> future2;33 // ...34 MyObject foo = future1.get();35 // future2 is not used.36 37Options38-------39 40.. option:: IncludeTypes41 42 Semicolon-separated list of regular expressions matching types of variables43 to check. By default the following types are checked:44 45 * `::std::.*mutex`46 * `::std::future`47 * `::std::basic_string`48 * `::std::basic_regex`49 * `::std::basic_istringstream`50 * `::std::basic_stringstream`51 * `::std::bitset`52 * `::std::filesystem::path`53 54.. option:: ExcludeTypes55 56 A semicolon-separated list of regular expressions matching types that are57 excluded from the `IncludeTypes` matches. By default it is an empty list.58