<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/86714>86714</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] Create check for inconsistent/missed typedef/using alias type names
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            check-request
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          FruitClover
      </td>
    </tr>
</table>

<pre>
    Consider the following example: https://godbolt.org/z/jE8Yc7sz6
```c++
using Type = int;

struct Base {
  virtual Type fooType(Type x);
 virtual int fooInt(int x);
};

struct Derived : Base {
  int fooType(int x);
  Type fooInt(Type x);
};
```

Here we misuse/miss consistent **alias names** in derived methods (compared to base
class signatures), which could lead to tricky bugs (after `using Type = ...`
changes) and this is also complicates plain text search.

The idea is that we could detect such **`using`/`typedef`** inconsistency/misuse in
some cases with clang-tidy.

To start up, we could focus on:

- Class methods only.
- Return type check.
- Argument type check.


To illustrate which cases are compatible/which are not - check the following table:
<details>
<summary>legend</summary>

- `Base Type`: return/argument type for class class methods.
- `Derived Type`: return/argument type for derived class methods.
- `Warning/FixItHint`: if check should emit warning/hint 
   
(we use `int` as some non-aliased type, and <alias> as `using T = ..` or
`typedef .. T`;
</details>

```
|     | Base Type | Derived Type | Warning | FixItHint |
|-----+-----------+--------------+---------+-----------|
|     | int | int          | -       | -         |
|     | <alias>   | int | +       | +         |
|     | int       | <alias>      | +       | - |
| (*) | <alias>   | <alias>      | Analyze | - |
```

`(*)` **Both types are aliased**: Analyze `BaseT` vs `DerivedT`:

1. Alias names are compatible: (**Warning: No**)
1.1 one of (`BaseT`, `DerivedT`) is implicit
2.1 Same fully-qualified names:`BaseT.getQualifiedNameAsString == DerivedT.getQualifiedNameAsString`


2. Alias names are non-compatible: (**Warning: Yes**)
2.1. Strict check: `TD1.getQualifiedNameAsString != TD2.getQualifiedNameAsString`  (`N1::Type vs N2::Type`)

3. Questinable: (**Warning: ?**)
3.1. chain alias (maybe control with option). If so, should check it before 2.1
```c++
using T1 = int;
using T2 = T1;

// => T1 name is compatible with T2 name
```

This probably belongs to `bugprone` category, something like `inconsistant-alias-names`/`inconsistant-using-typedef` (suggestions are welcome)

Background: PoC version was prepared for internal projects, here I want to check if clang-tidy would be interested in it before publishing PR, and discuss what to warn and if we should emit more fix hints.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMV8lu4zgTfhr6UrAgUY5iH3xw7AjTl8YsAX7MkZLKFqcp0kNScdxP_6NISd7SPW0Esbnoq6qvVgnn5EEjrtnTC3vazUTvW2PXpe2l3yrzjnZWmea83hrtZIMWfIuwN0qZk9QHwA_RHRWyfAOt90fH8g3jJePlwTSVUT4x9sB4-Z3x8p_X5d_1s_tesHTH0g0r0vhXM_5Cf2G3d4T6dj4isHwHUnuWD0fxv_O2rz28CIfAnocjgHdpfS9UfHJvDH0zvgzLD8ZXE8p0U2pPF79oz_iSFjfX2PPuc8E7tPIdGyCL75UYIAfZD5gwaReFPip3I3Xk51qJ39AinBA66XqHjJeddA5q8o3zqD0wvmF8I5QUDrTo0MUNkBqaQfMOfWsaB4wva9MdhcUGvIFKOIxCaiWcAwoL4XtLECvGt3BqZd1CbXrVgEIRHvJW1t_OUPWHgCf2Hi2wIr1zY5IkkyF1K_QhgILQDfhWOpAOhHIGSB8la-HRwVEJqcHjhweHwtZtck3EW4sgGxT0qG-FJ1Kiag16rD24vm4HNkZ9SAVesiL15yM2uA_rgZ2JwvocWe0dgtSD602HUAuHDk7St1AroQ9zL5vzrU4GnBfWQ38MfI0a7U3dOzCacuPq-hy2gejRH0arEW8Of6LvrQbSFOoW62_TycYe-o5c_XB2p4tUqnfeCo-j64IFwmLgWXhZKQqheEjb2niYR8i7NPeiCkk-iMi3DXohlWP567Tl-q4T9szyV4UH1A3Lt4yXl91b21mRhvQJyVKklE422Mx4KW5M3BsLMSTra76SK6QxKX8NbEy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