Skip to content

[clang-tidy] modernize-macro-to-enum should ignore macros used as arguments to other macros #54948

@LegalizeAdulthood

Description

@LegalizeAdulthood

Consider:

#define INSIDE7 7
#define INSIDE8 8

#define CONCAT(n_, s_) n_##s_
#define FN_NAME(n_, s_) CONCAT(n_, s_)

extern void FN_NAME(g, INSIDE7)();

void gg()
{
    g7();
}

If the macro INSIDE7 is converted to an enum, this code fails to build properly.

Macros that are used as arguments to other macros, or that appear in the expansion of other function like macros, should be excluded from conversion to enums.

Metadata

Metadata

Labels

bugIndicates an unexpected problem or unintended behaviorclang-tidy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions