llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.78k stars 10.97k forks source link

[clang-tidy][request] Flag implicit enum conversion #88519

Open chrchr-github opened 2 months ago

chrchr-github commented 2 months ago

Similar to readability-implicit-bool-conversion:

enum E { E0, E1 };
void f(E e, bool b) {
    if (e > 0) {} // warn here
    if (b > 0) {}
}

https://godbolt.org/z/cfjofjfav

chrchr-github commented 2 months ago

This should be allowed/optional though:

void g(int i) {
    if (i > E0) {}
}