[clang-tools-extra] [clang-tidy] Correct fix-it range for function pointer-like typedef in `modernize-use-using` (PR #173751)

via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 27 21:41:06 PST 2025


================
@@ -205,8 +208,7 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
   }
 
   if (!ReplaceRange.getEnd().isMacroID()) {
-    const SourceLocation::IntTy Offset =
-        MatchedDecl->getFunctionType() ? 0 : Name.size();
+    const SourceLocation::IntTy Offset = FunctionPointerCase ? 0 : Name.size();
----------------
flovent wrote:

Using `getLocForEndOfToken` will use get the loc of `,` as the beginning of replace for second typedef in this case comparing to the old way, which makes two fixs' ranges will not overlap and being able to provide a fix, although it's wrong.

It seems not very trivial make multi function pointer case work, because their type is mixed up together.
For single typedef:
```
  typedef char (&refArray)[2];
```
We actually put `char (&`(type loc begin to name begin) and `)[2]`(name end to type loc end) together to get its type string.

But when there are multi alias types, their share the same type begin, that's why `ptrArray` will get `char (&refArray)[2], (*` for the first part.


https://github.com/llvm/llvm-project/pull/173751


More information about the cfe-commits mailing list