[clang-tools-extra] [clang-tid]fix modernize-use-auto incorrect fix hints for pointer (PR #77943)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 14 23:47:12 PST 2024


================
@@ -0,0 +1,18 @@
+// RUN: %check_clang_tidy -check-suffix=REMOVE %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: {modernize-use-auto.RemoveStars: 'true', modernize-use-auto.MinTypeNameLength: '0'}}"
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: {modernize-use-auto.RemoveStars: 'false', modernize-use-auto.MinTypeNameLength: '0'}}"
+
+void pointerToFunction() {
+  void (*(*(f1)))() = static_cast<void (**)()>(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing
+  // CHECK-FIXES-REMOVE: auto f1 =
+  // CHECK-FIXES: auto *f1 =
+}
+
+void pointerToArray() {
+  int(*a1)[2] = new int[10][2];
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing
+  // CHECK-FIXES-REMOVE: auto a1 =
+  // CHECK-FIXES: auto *a1 =
+}
----------------
PiotrZSL wrote:

Add test with member function pointer.

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


More information about the cfe-commits mailing list