This issue was copied from checkedc/checkedc-clang#1183
This PR modifies the way that rvalue bounds are determined for the value of a member expression, pointer deference, or array subscript to be consistent with the way that rvalue bounds are determined for the value of a variable. The rvalue bounds for the value of a variable, member expression, pointer dereference, or array subscript expression e are determined by looking at the ObservedBounds map in the checking state. If the AbstractSet containing e is present in ObservedBounds, then those are the bounds for the value of e. Otherwise, the bounds for the value of e default to the lvalue target bounds of e (or the lvalue bounds of e if e is the subexpression of an ArrayToPointerDecay cast.
One consequence of this change is that the order of expressions used to get or create an AbstractSet may differ, which may affect the representative expression for the AbstractSet. For example, consider the assignment *p = p[0] + 1. The rvalue bounds of p[0] are determined before modifying the observed bounds of *p. This means that p[0] is the first expression that is used to create the AbstractSet that contains *p and p[0], so p[0] is the representative expression for this AbstractSet.
This PR also includes a minor fix in CanonBounds where ExtVectorElementExprs are compared by address. This prevents an llvm_unreachable that would otherwise occur when creating an AbstractSet for a member expression that contains an ExtVectorElementExpr.
This issue was copied from checkedc/checkedc-clang#1183
This PR modifies the way that rvalue bounds are determined for the value of a member expression, pointer deference, or array subscript to be consistent with the way that rvalue bounds are determined for the value of a variable. The rvalue bounds for the value of a variable, member expression, pointer dereference, or array subscript expression
eare determined by looking at theObservedBoundsmap in the checking state. If theAbstractSetcontainingeis present inObservedBounds, then those are the bounds for the value ofe. Otherwise, the bounds for the value ofedefault to the lvalue target bounds ofe(or the lvalue bounds ofeifeis the subexpression of anArrayToPointerDecaycast.One consequence of this change is that the order of expressions used to get or create an
AbstractSetmay differ, which may affect the representative expression for theAbstractSet. For example, consider the assignment*p = p[0] + 1. The rvalue bounds ofp[0]are determined before modifying the observed bounds of*p. This means thatp[0]is the first expression that is used to create theAbstractSetthat contains*pandp[0], sop[0]is the representative expression for thisAbstractSet.This PR also includes a minor fix in CanonBounds where
ExtVectorElementExprsare compared by address. This prevents anllvm_unreachablethat would otherwise occur when creating anAbstractSetfor a member expression that contains anExtVectorElementExpr.