This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage.
ClosedPublic

Authored by mwyman on Sep 26 2019, 5:03 PM.

Details

Summary

Creates a new darwin ClangTidy module and adds the darwin-dispatch-once-nonstatic check that warns about dispatch_once_t variables not in static or global storage. This catches a missing static for local variables in e.g. singleton initialization behavior, and also warns on storing dispatch_once_t values in Objective-C instance variables. C/C++ struct/class instances may potentially live in static/global storage, and are ignored for this check.

The osx.API static analysis checker can find the non-static storage use of dispatch_once_t; I thought it useful to also catch this issue in clang-tidy when possible.

This is a re-land of https://reviews.llvm.org/D67567

Diff Detail

Event Timeline

mwyman created this revision.Sep 26 2019, 5:03 PM
Eugene.Zelenko added inline comments.
clang-tools-extra/docs/ReleaseNotes.rst
85

Please synchronize with first sentence in documentation.

mwyman updated this revision to Diff 222086.Sep 26 2019, 11:50 PM
mwyman marked an inline comment as done.

Tweaked release notes to match first sentence of documentation.

This revision was not accepted when it landed; it landed in state Needs Review.Sep 27 2019, 3:50 AM
This revision was automatically updated to reflect the committed changes.