Happens to match our coding style already: 
https://webkit.org/code-style-guidelines/#singleton-static-member

> On Sep 13, 2024, at 2:41 PM, Ryosuke Niwa via webkit-dev 
> <webkit-dev@lists.webkit.org> wrote:
> 
> Hi all,
> 
> TL; DR: Add “Singleton” suffix to a function which returns a singleton to 
> help aid WebKit static analyzers.
> 
> It’s fairly common for some classes to provide a static member function which 
> returns a singleton. Such a function typically holds NeverDestroyed instance 
> of an object and it’s safe to call any mutating member functions on it 
> without locally storing Ref/RefPtr/CheckedRef/CheckedPtr.
> 
> Unfortunately, this poses a challenge for WebKit static analyzers which 
> enforces safe smart pointer usage because the static analyzers can’t 
> differentiate a static function which returns a singleton and a static 
> function which returns a non-singleton instance of an object. For this 
> reason, I suggest we start suffixing the name of each function which returns 
> a singleton with “Singleton” e.g. IOSurfacePool::sharedPoolSingleton instead 
> of IOSurfacePool::sharedPool. This will help aid static analyzers to identify 
> a function which returns a singleton and not generate superfluous warnings 
> for it.
> 
> - R. Niwa
> 
> _______________________________________________
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to