Index: clang-tidy/objc/PropertyDeclarationCheck.h =================================================================== --- clang-tidy/objc/PropertyDeclarationCheck.h +++ clang-tidy/objc/PropertyDeclarationCheck.h @@ -35,6 +35,7 @@ private: const std::vector SpecialAcronyms; + const std::vector AdditionalAcronyms; }; } // namespace objc Index: clang-tidy/objc/PropertyDeclarationCheck.cpp =================================================================== --- clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -124,14 +124,22 @@ ClangTidyContext *Context) : ClangTidyCheck(Name, Context), SpecialAcronyms(utils::options::parseStringList( - Options.get("Acronyms", DefaultSpecialAcronyms))) {} + Options.get("Acronyms", DefaultSpecialAcronyms))), + AdditionalAcronyms(utils::options::parseStringList( + Options.get("AdditionalAcronyms", ""))) {} void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) { + std::vector Acronyms; + Acronyms.reserve(SpecialAcronyms.size() + AdditionalAcronyms.size()); + Acronyms.insert(Acronyms.end(), SpecialAcronyms.begin(), + SpecialAcronyms.end()); + Acronyms.insert(Acronyms.end(), AdditionalAcronyms.begin(), + AdditionalAcronyms.end()); Finder->addMatcher( objcPropertyDecl( // the property name should be in Lower Camel Case like // 'lowerCamelCase' - unless(matchesName(validPropertyNameRegex(SpecialAcronyms)))) + unless(matchesName(validPropertyNameRegex(Acronyms)))) .bind("property"), this); } @@ -149,6 +157,8 @@ void PropertyDeclarationCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "Acronyms", utils::options::serializeStringList(SpecialAcronyms)); + Options.store(Opts, "AdditionalAcronyms", + utils::options::serializeStringList(AdditionalAcronyms)); } } // namespace objc Index: docs/clang-tidy/checks/objc-property-declaration.rst =================================================================== --- docs/clang-tidy/checks/objc-property-declaration.rst +++ docs/clang-tidy/checks/objc-property-declaration.rst @@ -41,3 +41,12 @@ or a suffix of property names. If unset, defaults to "ACL;API;ARGB;ASCII;BGRA;CMYK;DNS;FPS;FTP;GIF;GPS;HD;HDR;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;LAN;LZW;MDNS;MIDI;OS;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;ROM;RPC;RTF;RTL;SDK;SSO;TCP;TIFF;TTS;UI;URI;URL;VC;VOIP;VPN;VR;WAN;XML". + + If set, replaces the default list. (If you want to append to the default list, set AdditionalAcronyms instead.) + +.. option:: AdditionalAcronyms + + Semicolon-separated list of additional acronyms that can be used as a prefix + or a suffix of property names. + + Appends to the list in Acronyms. Index: test/clang-tidy/objc-property-declaration-additional.m =================================================================== --- test/clang-tidy/objc-property-declaration-additional.m +++ test/clang-tidy/objc-property-declaration-additional.m @@ -1,6 +1,6 @@ // RUN: %check_clang_tidy %s objc-property-declaration %t \ // RUN: -config='{CheckOptions: \ -// RUN: [{key: objc-property-declaration.Acronyms, value: "ABC;TGIF"}]}' \ +// RUN: [{key: objc-property-declaration.AdditionalAcronyms, value: "ABC;TGIF"}]}' \ // RUN: -- @class NSString; @@ -11,4 +11,5 @@ @property(assign, nonatomic) int ABCCustomPrefix; @property(strong, nonatomic) NSString *ABC_custom_prefix; // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'ABC_custom_prefix' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration] +@property(assign, nonatomic) int GIFShouldIncludeStandardAcronym; @end Index: test/clang-tidy/objc-property-declaration-custom.m =================================================================== --- test/clang-tidy/objc-property-declaration-custom.m +++ test/clang-tidy/objc-property-declaration-custom.m @@ -11,4 +11,6 @@ @property(assign, nonatomic) int ABCCustomPrefix; @property(strong, nonatomic) NSString *ABC_custom_prefix; // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'ABC_custom_prefix' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration] +@property(assign, nonatomic) int GIFIgnoreStandardAcronym; +// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'GIFIgnoreStandardAcronym' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration] @end