[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 07:54:11 PDT 2020
dougpuob added a comment.
In D86671#2330689 <https://reviews.llvm.org/D86671#2330689>, @njames93 wrote:
> Is this diff been created incorrectly again?
>
> Taking a step back, Is Hungarian notation really a case style, Seems to me its mainly about the prefix and a user may want `DWORD dwUPPER_CASE`, Right now there is no way of adopting that.
> Maybe extend the options for hungarian type decls to
>
> <Type>Case
> <Type>Prefix
> <Type>Suffix
> <Type>HungarianPrefix
>
> `<Type>HungarianPrefix` would likely be a bool and if enabled, it would be prepended to `<Type>Prefix`
> I could see a situation like this
>
> [Options]
> // VariableCase: UPPER_CASE
> // VariablePrefix: PRE_
> // VariableSuffix: _POST
> // VariableHungarianPrefix: true
>
> DWORD MyVariable; -> DWORD dwPRE_MY_VARIABLE_POST;
>
> This would give users full control of exactly how they want their declarations with no hidden surprises.
>
> Granted this approach would require a little rework but it would satisfy more users.
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
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