[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
Mon Feb 27 13:56:07 PST 2023


amurzeau created this revision.
amurzeau added reviewers: njames93, alexfh, kazu, dougpuob, aaron.ballman, carlosgalvezp.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
amurzeau requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

When checking a C file, enum tags are of type `int` instead of the enum
type as in C++.
So the checker was using `i` as the prefix for enum tags instead of main
letters of the enum type name (for example `rt` for `enum REV_TYPE`).

This commit fixes this divergence and makes the behavior the same between
C and C++ files.

For example, `enum REV_TYPE { rtRevValid };` won't be reported as badly
named when in a C file. Previously, it would have proposed a rename to
`iRevValid`.

This commit also add a file to test the hungarian notation checker with C
files.
The test file was made from identifier-naming-hungarian-notation.cpp
with C++-only features removed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144912

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-c-language.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144912.500900.patch
Type: text/x-patch
Size: 31978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230227/b5321079/attachment-0001.bin>


More information about the cfe-commits mailing list