[clang-tools-extra] [clang-tidy] Fix insertion location for certain function pointers in `cppcoreguidelines-init-variables` (PR #162218)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 7 08:18:41 PDT 2025


================
@@ -148,3 +148,19 @@ namespace gh112089 {
     }
 } // namespace gh112089
 
+namespace gh161978 {
+  void test() {
+    bool (*fp1)(int);
+    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'fp1' is not initialized [cppcoreguidelines-init-variables]
+    // CHECK-FIXES: bool (*fp1)(int) = nullptr;
+    bool (*fp2)(int, int);
+    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'fp2' is not initialized [cppcoreguidelines-init-variables]
+    // CHECK-FIXES: bool (*fp2)(int, int) = nullptr;
+    bool (*fp3)(int, int, int);
+    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'fp3' is not initialized [cppcoreguidelines-init-variables]
+    // CHECK-FIXES: bool (*fp3)(int, int, int) = nullptr;
+    bool (*fp4)(int, int, int, ...);
+    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'fp4' is not initialized [cppcoreguidelines-init-variables]
+    // CHECK-FIXES: bool (*fp4)(int, int, int, ...) = nullptr;
+  }
----------------
flovent wrote:

Added in new commit, thanks for written the whole thing so i can copy-paste!

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


More information about the cfe-commits mailing list