[PATCH] D117522: [clang-tidy] Add modernize-macro-to-enum check

Richard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 2 08:49:19 PST 2022


LegalizeAdulthood added a comment.

Oh, I think I misinterpreted what you were saying in the last bit:

In D117522#3290604 <https://reviews.llvm.org/D117522#3290604>, @carlosgalvezp wrote:

> Another point is that macros typically have a different naming
> convention than enums or constants, so users will likely have
> to do manual work anyway, or rely on the
> "readability-identifier-naming" check - how does it play out
> then if 2 checks propose different fixes?

All the checks look at the original version of the source file, so if
you run modernize-macro-to-enum and readability-identifier-naming
checks at the same time, they won't conflict with each other.
You're correct that once a macro has been hoisted to an
anonymous enum, running the identifier naming check on the
transformed result might then complain about the names being
stylized as a macro and not as an enum.  Since the identifier
naming check provides fix-its, I don't see this as a problem.
If you want the was-a-macro-now-is-an-enum name to follow
a different identifier naming convention, it makes sense to run
the one check after the other in order to enforce this.  IMO, it's
better to have small, discrete, well-defined transformation steps
than it is to have a "kitchen sink" transformation that attempts to
do too much.

However, I've seen many coding style guidelines (current workplace
is one example) that explicitly say to name enumerations with the
same identifier convention as are used for macros, so this is style
guide specific.


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

https://reviews.llvm.org/D117522



More information about the cfe-commits mailing list