=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrc...@protonmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/89...@github.com>


================
@@ -132,11 +157,11 @@ size_t 
TaggedUnionMemberCountCheck::getNumberOfValidEnumValues(
   // 3. The value of the counting enum constant is the largest out of every 
enum
   //    constant.
----------------
isuckatcs wrote:

So, if I understand it correctly, what we really care about is whether the 
value of the last enumerator equals to the number of the other enumerators.

E.g.:
```c++
enum tag_with_counter {
  tag1 = 100,
  tag2 = 200,
  tag_count = 2
};
```
In this example `tag_count` is still a counter, but point 3. doesn't apply, so 
the heuristics doesn't find it.

```c++
enum tag_with_counter {
  tag1 = 2,
  tag2 = 3,
  tag_count = 2
};
```
In this other example, the last enumerator is still a counter, but point 1. 
doesn't apply (?).

```c++
enum tag_with_counter {
  tag1,
  tag2,
  tag3
};
```
In this last example however all points apply, so the heuristics detects the 
last enumerator as a counter, when it's not one.

If you really want this heuristics, I suggest replacing this function with a 
simple check for the value of the last enumerator being equal to the number of 
the other enumerators. You use the name of the enumerator to determine whether 
it's a counter anyway.

https://github.com/llvm/llvm-project/pull/89925
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to