[PATCH] D30896: [Clang-tidy] add check misc-prefer-switch-for-enums

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 13 15:28:33 PDT 2017


aaron.ballman added a comment.

I'm curious what kind of results you get when running this over a large code base. There are definitely times when using == or != for a specific value is *way* cleaner than using a switch statement, and I worry about this being so chatty that it needs to be disabled by default.

If it turns out to be very chatty, perhaps the check could be relaxed to only consider cases where you have multiple if/else if clauses (tuned via an option) for checking several values? At the very least, the check should not be triggered on an enumeration that has only one enumerator.


Repository:
  rL LLVM

https://reviews.llvm.org/D30896





More information about the cfe-commits mailing list