[clang] [WebKit checkers] Treat function pointers with "Singleton" suffix as singleton. (PR #158012)

Rashmi Mudduluru via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 12 12:11:49 PDT 2025


================
@@ -438,6 +438,17 @@ void use_const_local() {
 
 } // namespace const_global
 
+namespace var_decl_ref_singleton {
+
+static Class initSomeObject() { return nil; }
+static Class (*getSomeObjectClassSingleton)() = initSomeObject;
+
+bool foo(NSString *obj) {
+  return [obj isKindOfClass:getSomeObjectClassSingleton()];
+}
+
+} // namespace var_decl_ref_singleton
+
----------------
t-rasmud wrote:

It was thinking of a member function pointer. I believe using a function pointer in c++ code isn't much different than using it in obj-c code, but I might be wrong.

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


More information about the cfe-commits mailing list