Skip to content

[clang-tidy] Enhance modernize-macro-to-enum to recognize constant literal expressions #55055

Closed
@LegalizeAdulthood

Description

Consider the following code:

#define TIF_CZ_LSMINFO 34412 /* 0x866c, Type: TIF_BYTE, Length: 512 */
#define TIF_CZ_LSMINFO_SIZE_RESERVED 90 + 6
#define TIF_CZ_LSMINFO_SIZE 512

The first and third of these macros will be converted to enums, but the second macro will be left in place because it uses a constant integral expression as the value of the macro instead of a simple integral literal.

Enhance modernize-macro-to-enum to recognize macro expansions that are valid initializing expressions for enums. For this issue, only consider macro expansions that are expressions involving integral literals only.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

clang-tidyenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions