This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Function-scoped static variables should not trigger google-objc-global-variable-declaration
ClosedPublic

Authored by benhamilton on Jan 5 2018, 3:09 PM.

Details

Summary

google-objc-global-variable-declaration currently triggers on
valid code like:

  • (void)foo { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ /* ... */ }); }

The Google Objective-C style guide says:

http://google.github.io/styleguide/objcguide.html#common-variable-names

File scope or global variables (as opposed to constants) declared
outside the scope of a method or function should be rare, and should
have the prefix g.

which is meant to insinuate that static variables inside a method or
function don't need a special name.

Test Plan: make -j12 check-clang-tools

Diff Detail

Event Timeline

benhamilton created this revision.Jan 5 2018, 3:09 PM
Wizard accepted this revision.Jan 5 2018, 3:19 PM
This revision is now accepted and ready to land.Jan 5 2018, 3:19 PM
This revision was automatically updated to reflect the committed changes.