xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/modernize/use-using.rst (revision 583a2583bb5f53b7b2cbd3d2043c0b2ac286464f)
1.. title:: clang-tidy - modernize-use-using
2
3modernize-use-using
4===================
5
6The check converts the usage of ``typedef`` with ``using`` keyword.
7
8Before:
9
10.. code-block:: c++
11
12  typedef int variable;
13
14  class Class{};
15  typedef void (Class::* MyPtrType)() const;
16
17  typedef struct { int a; } R_t, *R_p;
18
19After:
20
21.. code-block:: c++
22
23  using variable = int;
24
25  class Class{};
26  using MyPtrType = void (Class::*)() const;
27
28  using R_t = struct { int a; };
29  using R_p = R_t*;
30
31The checker ignores `typedef` within `extern "C" { ... }` blocks.
32
33.. code-block:: c++
34
35  extern "C" {
36    typedef int InExternC; // Left intact.
37  }
38
39This check requires using C++11 or higher to run.
40
41Options
42-------
43
44.. option:: IgnoreMacros
45
46   If set to `true`, the check will not give warnings inside macros. Default
47   is `true`.
48
49.. option:: IgnoreExternC
50
51   If set to `true`, the check will not give warning inside `extern "C"`scope.
52   Default is `false`