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

Dmitri Gribenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 18 10:40:11 PDT 2019


gribozavr accepted this revision.
gribozavr added a comment.
This revision is now accepted and ready to land.

FWIW, I like this approach better than the one in Static Analyzer because it warns on the variable declaration -- that's where the root of the issue is, not at the call to `dispatch_once()`. Like, what can you in principle do with a local `dispatch_once_t`? not much -- therefore produce a warning right there.



================
Comment at: clang-tools-extra/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst:10
+
+It is a common paradigm to have functions initialize internal static or global
+data once when the function runs, but programmers have been known to miss the
----------------
s/paradigm/pattern/


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

https://reviews.llvm.org/D67567





More information about the cfe-commits mailing list