[PATCH] D144912: [clang-tidy] readability-identifier-naming: fix hungarian enum prefix in C

Alexis Murzeau via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 18 09:21:16 PDT 2023


amurzeau added a comment.

In D144912#4203920 <https://reviews.llvm.org/D144912#4203920>, @carlosgalvezp wrote:

> Looks good but I fail to understand what exactly the patch fixes, can you point me to an example in the tests?

The patch fixes these enum tests in C language mode:

  enum REV_TYPE { RevValid };
  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for enum constant 'RevValid' [readability-identifier-naming]
  // CHECK-FIXES: {{^}}enum REV_TYPE { rtRevValid };
  
  enum EnumConstantCase { OneByte, TwoByte };
  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: invalid case style for enum constant 'OneByte' [readability-identifier-naming]
  // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: invalid case style for enum constant 'TwoByte' [readability-identifier-naming]
  // CHECK-FIXES: {{^}}enum EnumConstantCase { eccOneByte, eccTwoByte };

Without this patch, the suggested fix in a C file by clang-tidy is `iRevValid` instead of `rtRevValid`.
This patch makes the behavior on C files the same as C++ files.

In D144912#4203920 <https://reviews.llvm.org/D144912#4203920>, @carlosgalvezp wrote:

> It would be easier to review if the NFC changes had been done in a separate patch.

Ok sorry, will do that next time.
Would the new C test file would have been better in a separate patch too (thus keep only the main change in the checker) ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144912



More information about the cfe-commits mailing list