llvm-project/clang-tools-extra/clang-tidy
Yan Zhang 2d83647007 [clang-tidy/google] Improve the Objective-C global variable declaration check 🔧
Summary:
The current Objective-C global variable declaration check restricts naming that is permitted by the Google Objective-C style guide.

The Objective-C style guide states the following:
"Global and file scope constants should have an appropriate prefix. [...] Constants may use a lowercase k prefix when appropriate"
http://google.github.io/styleguide/objcguide#constants

This change fixes the check to allow two or more capital letters as an appropriate prefix. This change intentionally avoids making a decision regarding whether to flag constants that use a two letter prefix (two letter prefixes are reserved by Apple¹ but many projects seem to violate this guideline).

This change eliminates an important category of false positives (constants prefixed with '[A-Z]{2,}') at the cost of introducing a less important category of false negatives (constants prefixed with only '[A-Z]'). The false positives are observed in standard recommended code while the false negatives occur in non-standard unrecommended code. The number of eliminated false positives is expected to be significantly larger than the number of exposed false negatives.

❧

(1)
"Two-letter prefixes like these are reserved by Apple for use in framework classes."
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Conventions/Conventions.html

Reviewers: aaron.ballman, Wizard, hokein, benhamilton

Reviewed By: aaron.ballman, Wizard

Subscribers: aaron.ballman, cfe-commits

Differential Revision: https://reviews.llvm.org/D43581

llvm-svn: 326046
2018-02-25 04:11:26 +00:00
..
android [clang-tidy] Kill marco. No functionality change. 2018-02-02 13:39:07 +00:00
boost [tidy] Move private ast matchers into anonymous namespaces to avoid ODR conflicts. 2018-02-18 19:02:35 +00:00
bugprone [tidy] Move private ast matchers into anonymous namespaces to avoid ODR conflicts. 2018-02-18 19:02:35 +00:00
cert [clang-tidy] Fix link error in clang-tidy after the recent check renames. 2017-11-27 15:17:13 +00:00
cppcoreguidelines [tidy] Move private ast matchers into anonymous namespaces to avoid ODR conflicts. 2018-02-18 19:02:35 +00:00
fuchsia [tidy] Move private ast matchers into anonymous namespaces to avoid ODR conflicts. 2018-02-18 19:02:35 +00:00
google [clang-tidy/google] Improve the Objective-C global variable declaration check 🔧 2018-02-25 04:11:26 +00:00
hicpp [tidy] Move private ast matchers into anonymous namespaces to avoid ODR conflicts. 2018-02-18 19:02:35 +00:00
llvm [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used 2017-07-20 12:02:03 +00:00
misc [tidy] Move private ast matchers into anonymous namespaces to avoid ODR conflicts. 2018-02-18 19:02:35 +00:00
modernize [clang-tidy] Replace the usage of std::uncaught_exception with std::uncaught_exceptions 2018-02-20 10:48:38 +00:00
mpi modernize-use-auto NFC fixes 2016-12-14 15:29:23 +00:00
objc Support special acronyms inside property names and allow plural forms 2018-02-06 21:40:38 +00:00
performance [clang-tidy] ObjC ARC objects should not trigger performance-unnecessary-value-param 2018-02-02 15:34:33 +00:00
plugin [clang-tidy ObjC] [1/3] New module `objc` for Objective-C checks 2017-10-26 08:23:20 +00:00
readability [clang-tidy] Add `readability-simd-intrinsics` check. 2018-02-15 17:56:43 +00:00
tool [clang-tidy] Add -vfsoverlay flag 2018-01-23 12:31:06 +00:00
utils [clang-tidy] ObjC ARC objects should not trigger performance-unnecessary-value-param 2018-02-02 15:34:33 +00:00
CMakeLists.txt Add a new clang-tidy module for Fuchsia as an umbrella to diagnose issues with the Fuschia and Zircon coding guidelines (https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md). Adds the first of such checkers, which detects when default arguments are declared in a function declaration or when default arguments are used at call sites. 2017-11-28 21:09:25 +00:00
ClangTidy.cpp [clang-tidy] Add -vfsoverlay flag 2018-01-23 12:31:06 +00:00
ClangTidy.h [clang-tidy] Add -vfsoverlay flag 2018-01-23 12:31:06 +00:00
ClangTidyDiagnosticConsumer.cpp Add support for NOLINT and NOLINTNEXTLINE comments mentioning specific check names. 2017-12-14 16:13:57 +00:00
ClangTidyDiagnosticConsumer.h [clang-tidy] Optimize GlobList::contains 2017-05-18 01:13:51 +00:00
ClangTidyModule.cpp Change getChecksFilter() interface to hide implementation details. 2017-05-17 14:39:47 +00:00
ClangTidyModule.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
ClangTidyModuleRegistry.h Reapply r276973 "Adjust Registry interface to not require plugins to export a registry" 2016-08-05 11:01:08 +00:00
ClangTidyOptions.cpp Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR 2017-06-30 20:57:16 +00:00
ClangTidyOptions.h [clang-tidy] Add FormatStyle configuration option. 2017-04-06 13:41:29 +00:00
add_new_check.py [clang-tidy] New argument --language to add_new_check.py 2018-01-31 21:52:39 +00:00
rename_check.py [clang-tidy] Use a more specific regex 2018-01-30 14:55:39 +00:00