[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

Stephane Moore via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 17:05:04 PDT 2019


stephanemoore added a comment.

In D67567#1670144 <https://reviews.llvm.org/D67567#1670144>, @mwyman wrote:

> In D67567#1670035 <https://reviews.llvm.org/D67567#1670035>, @lebedev.ri wrote:
>
> > In D67567#1670017 <https://reviews.llvm.org/D67567#1670017>, @mwyman wrote:
> >
> > > In D67567#1669866 <https://reviews.llvm.org/D67567#1669866>, @lebedev.ri wrote:
> > >
> > > > 2. Is `dispatch_once_t` OSX-specific thing? Should those checks be in `osx` module?
> > >
> >
> >
> >
> >
> > > 2. I don't see an `osx` module—am I somehow missing seeing it?
> >
> > One can be added.
> >
> > > `dispatch_once_t` is something from `libdispatch`which is an Apple-created API, but is OSS and available outside Apple. It's also a C API, which is why I didn't feel `objc` was an appropriate module either. I'm open to a better home module for this check, it's just not clear to me where that might be.
> >
> > No opinion on my question, just thought it should be asked,
>
>
> As Ben commented, I don't feel this should be in an `osx` module, as libdispatch is highly used on iOS and other Apple platforms. I know it's available elsewhere, but it may be so seldom used that I think a `darwin`module might be reasonable. I looked at the process for creating a new module, and can do that if we'd like, but should that be part of this same review?


As alluded to, //technically// Grand Central Dispatch is documented to support FreeBSD. With that said, I would be okay with putting this in a `darwin` module because GCD is most prevalent on Darwin platforms.



================
Comment at: clang-tools-extra/test/clang-tidy/darwin-dispatch-once-nonstatic.mm:45
+  dispatch_once_t _once;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dispatch_once_t variables must have static or global storage duration and cannot be Objective-C instance variables [darwin-dispatch-once-nonstatic]
+}
----------------
Maybe add a `CHECK-FIXES` to make sure that no fix was recommended?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67567/new/

https://reviews.llvm.org/D67567





More information about the cfe-commits mailing list