[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 20:32:01 PST 2025


================
@@ -437,3 +437,22 @@ namespace GH97009 {
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef' [modernize-use-using]
 // CHECK-FIXES: using Function = bool (*)(PointType, PointType);
 }
+
+namespace GH173732 {
+  // reference to array
+  typedef char (&refarray)[2];
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef' [modernize-use-using]
+  // CHECK-FIXES: using refarray = char (&)[2];
+  typedef char &ref;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef' [modernize-use-using]
+  // CHECK-FIXES: using ref = char &;
+
+
----------------
flovent wrote:

Added, this check can generate two warnings for this code, but it can't get a correct fix-it due to `this fix will not be applied because it overlaps with another fix`.

Same things happens for multi function typedef too:
```
   typedef int(*name)(int arg1, int arg2), (*aname)();
```

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


More information about the cfe-commits mailing list