[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

Douglas Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 20 16:38:10 PDT 2020


dougpuob added a comment.

In D86671#2342016 <https://reviews.llvm.org/D86671#2342016>, @njames93 wrote:

> In D86671#2341838 <https://reviews.llvm.org/D86671#2341838>, @dougpuob wrote:
>
>> Hi @njames93,
>>
>> It's a smart idea, the rework for it is worth. There is a special case if lowercase name with Hungarian prefix, it possibly makes variable ambiguous, like the `Case1`. How about separating them and `aNy_CasE` with an underscore, like `Case2` ?
>>
>>   // Case1
>>   bool bRIGHT_LEVEL;     // UPPER_CASE
>>   bool bRightLevel;      // CamelCase
>>   bool bRight_Level;     // Camel_Snake_Case
>>   bool baNy_CasE;        // aNy_CasE
>>   bool bright_level;     // lower_case
>>   bool brightLevel;      // camelBack
>>   bool bright_Level;     // camel_Snake_Back
>>   .....^^^^^^ <-- right? bright?
>>   
>>   // Case2
>>   bool bRIGHT_LEVEL;     // UPPER_CASE
>>   bool bRightLevel;      // CamelCase
>>   bool bRight_Level;     // Camel_Snake_Case
>>   bool b_aNy_CasE;       // aNy_CasE
>>   bool b_right_level;    // lower_case
>>   bool b_rightLevel;     // camelBack
>>   bool b_right_Level;    // camel_Snake_Back
>>   .....^^^^^^^ <-- add an underscore
>
> That still has hidden surprises. Maybe instead of a bool, an enum is used for controlling hungarian prefix (Off|On|...).
> Can't think of a good name for the third option but it would do the inserting of '_' (bright_level ->b_right_level) or capitalising the first word of the identifier (brightLevel -> bRightLevel).

Maybe it doesn't need a new name, how about (`Off|On|lower_case|camelBack`) or (`Off|On|sz_lower_case|szCamelBack`)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671



More information about the cfe-commits mailing list