[Lldb-commits] [lldb] [lldb] Fix the semantics of SupportFile equivalence (PR #95606)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 19 00:36:59 PDT 2024


labath wrote:

I think that `operator==` should represent the strictest possible way to compare two objects, and ideally mean "the two objects are interchangable". Interchangeability implies transitivity, and that doesn't hold here because an object with no checksum can match two other objects with different checksums, but those two objects won't match each other directly.

This can have implications for this bug as well. I don't know how we can end up in a different line table here, but if that can happen twice, and the middle line table has no checksum, then it can make a difference in whether you compare to the previous line table, or the initial/starting one. (I don't think this is likely to happen, I'm just using it to illustrate the point.)

With that in mind, I think `IsSameFile` is still slightly better than `operator==` (because it's harder to use it by accident, so you're more likely to look up the definition and see the comment next to it -- which hopefully explains the subtlety), but it still implies some form of interchangability. And fundamentally, I think it's not correct -- without the checksum (and maybe even with it) we can't definitively say whether the two objects describe the same file. (we may decide we're going to treat them as if they were, but I think that's something different)

Unfortunately, I don't know of a concise way to express this difference, maybe because the concept is not concise to begin with. `IsProbablySameFile`, `MayDescribeSameFile`, `PotentiallySameFile` ?

https://github.com/llvm/llvm-project/pull/95606


More information about the lldb-commits mailing list