Skip to content

Create modernize-enum-from-macros check #27408

@LegalizeAdulthood

Description

@LegalizeAdulthood
Bugzilla Link 27034
Version unspecified
OS All
CC @EugeneZelenko,@Trass3r

Extended Description

Consider the following code:

#define RED 0
#define GREEN 1
#define BLUE 2

struct RGBColor { /* ... */ };

extern float getChannel(const RGBColor &color, int channel);

RGBColor blue;
float red = getChannel(blue, RED);

The macros are being used as an enumeration. This is best done by explicitly using an enumeration instead of int and a bunch of macros.

Create a check that identifies such macros disguised as enumerations and replaces them with an actual enum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang-tidyconfirmedVerified by a second partyenhancementImproving 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