[clang] [LifetimeSafety] Avoid adding already present items in sets/maps (PR #159582)
Yitzhak Mandelbaum via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 19 07:45:35 PDT 2025
ymand wrote:
> > Ugh, I wonder if this is unintentional and we should change the implementation of these data structures. I also find this behavior very surprising.
>
> I can try changing the data structure. Let me do that in a separate PR. It would need an extra Value comparison which needs to be done [while inserting the element](https://github.com/llvm/llvm-project/blob/e2467cbfa8fdc440debac1cfb930ee476f3d5e42/llvm/include/llvm/ADT/ImmutableSet.h#L542) and this could be a slight concern for other users. Let me give it a try.
Seems like its a bug, based on the comment for `add`:
```
/// add - ... If
/// the original set already included the value, then the original set is
/// returned and no memory is allocated. ...
```
https://github.com/llvm/llvm-project/pull/159582
More information about the cfe-commits
mailing list