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;
}