whisperity added a comment.

The problem with enums is that translating //zero// (0, 0.0, nullptr, etc...) 
to the enum case is not always apparent. A warning **should** always be given. 
And //if// you can find a zero member in the enum, we can report an automated 
suggestion for that.

To give an example

  enum class BaseColour { BLACK, RED, GREEN, BLUE, WHITE };

`BLACK` is the `0`, so we can fix-it. If the `0` is the first member (usually 
in enums that have a well-defined "default" or "None" case...), then, it is 
alright to use that as the automated fix.

However, if there isn't a "zero case" in the enum, for example:

  enum class Something {
    FOO = -2,
    BAR, // This will be -1
    BAZ = 84,
    QUX  // This will be 85
  };

then simply using the first member might not be the best fitting action, so in 
such case, I would opt for //no FixIt//. But, obviously, yes for giving a 
warning.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106431/new/

https://reviews.llvm.org/D106431

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to