Issue 173732
Summary clang-tidy: `modernize-use-using` wrongly modifies typedef of referenced array
Labels clang-tidy
Assignees
Reporter e-kwsm
    <!--This is similar to #65055.-->

```console
$ clang-tidy --version
LLVM (http://llvm.org/):
  LLVM version 21.1.6
  Optimized build.
```

Prepare the following file, `/tmp/a.cpp`:

```cpp
typedef char (&refarray)[2];
typedef char &ref;
```

and `/tmp/compile_commands.json`:

```json
[
  {
    "directory": "/tmp",
    "command": "/usr/bin/clang++ -o a.o -c a.cpp",
 "file": "a.cpp",
    "output": "a.o"
  }
]
```

Then run clang-tidy:

```console
$ clang-tidy --checks='-*,modernize-use-using' --fix a.cpp
2 warnings generated.
/tmp/a.cpp:1:1: warning: use 'using' instead of 'typedef' [modernize-use-using]
    1 | typedef char (&refarray)[2];
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      | using refarray = char (&)[2]
/tmp/a.cpp:2:6: warning: use 'using' instead of 'typedef' [modernize-use-using]
    2 | typedef char &ref;
      | ^~~~~~~~~~~~
```

which gives malformed code

```
using refarray = char (&)[2];
typed;
using ref = char &;
```

<https://godbolt.org/z/cxdfnGhEY>
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to