[clang] [analyzer] Move alpha checker EnumCastOutOfRange to optin (PR #67157)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 9 16:27:26 PDT 2023


Xazax-hun wrote:

How well does this check work with bitwise enums? 

People often write code like:
```
enum AnimalFlags
{
    HasClaws   = 1,
    CanFly     = 2,
    EatsFish   = 4,
    Endangered = 8
};

AnimalFlags operator|(AnimalFlags a, AnimalFlags b)
{
    return static_cast<AnimalFlags>(static_cast<int>(a) | static_cast<int>(b));
}

auto flags = HasClaws | CanFly;
```

Would this warning emit false positives for these patterns? If yes, can/should we suppress them?

https://github.com/llvm/llvm-project/pull/67157


More information about the cfe-commits mailing list