1.. title:: clang-tidy - bugprone-unused-local-non-trivial-variable 2 3bugprone-unused-local-non-trivial-variable 4========================================== 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 copyable 10* references and pointers 11* exception variables in catch clauses 12* static or thread local 13* structured bindings 14* variables with ``[[maybe_unused]]`` attribute 15* name-independent variables 16 17This check can be configured to warn on all non-trivial variables by setting 18`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 used 26 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 37Options 38------- 39 40.. option:: IncludeTypes 41 42 Semicolon-separated list of regular expressions matching types of variables 43 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:: ExcludeTypes 55 56 A semicolon-separated list of regular expressions matching types that are 57 excluded from the `IncludeTypes` matches. By default it is an empty list. 58