Help with APValue comparisons

Ok, so please ignore my implementation for LValue in my previous post: I'm
not sure exactly what I was thinking, but it was garbage!

Here is a simplified and more correct implementation:

case LValue: {
  LValueBase BaseA = A.getLValueBase();
  LValueBase BaseB = B.getLValueBase();

  // null pointers on either side are not comparable
  if (!BaseA || !BaseB || BaseA.isNull() || BaseB.isNull()) return false;

  // simple comparison checks
  if ((A.getLValueOffset() != B.getLValueOffset()) ||
      (A.getLValueCallIndex() != B.getLValueCallIndex()) ||
      (A.isLValueOnePastTheEnd() != B.isLValueOnePastTheEnd()) ||
      (A.hasLValuePath() != B.hasLValuePath()) ||
      (BaseA.getOpaqueValue() != BaseB.getOpaqueValue()))
    return false;

  // walk the path
  if (A.hasLValuePath()) {
    assert(B.hasLValuePath() && "this should not happen"); // checked above

    ArrayRef<LValuePathEntry> PathA = A.getLValuePath();
    ArrayRef<LValuePathEntry> PathB = B.getLValuePath();
    if (PathA.size() != PathB.size()) return false;

    for (unsigned I = 0, N = PathA.size(); I != N; ++I) {
      if ((PathA[I].BaseOrMember != PathB[I].BaseOrMember) ||
          (PathA[I].ArrayIndex != PathB[I].ArrayIndex))
        return false;
    }
  }

  return true;
}

If /both/ values are null, the answer is "true". Otherwise this does look like how I would write it, minus union support. Someone else more familiar with this should probably take a look, though.

Jordan

We already have some code for comparing pointers in ExprConstant.cpp
(I think in IntExprEvaluator::visitBinaryOperator?); please take a
look at that.

The most obvious issue here is that the code doesn't seem to allow for
the possibility that we can't tell whether two LValues are equal.

-Eli

We already have some code for comparing pointers in ExprConstant.cpp
(I think in IntExprEvaluator::visitBinaryOperator?); please take a
look at that.

Thanks, I'll have a look there.

The most obvious issue here is that the code doesn't seem to allow for
the possibility that we can't tell whether two LValues are equal.

I'm sorry, I don't quite understand what you mean. Do you mean,
the code can't tell whether two independent LValues have equal
values, as opposed to being able to tell that two LValues structures
hold identical data?

Thanks,
Andy

Yes, I mean code can't tell whether two independent LValues have equal values.

-Eli