This repo contains a version of clang that is being modified to support Checked C. Checked C is an extension to C that lets programmers write C code that is guaranteed by the compiler to be type-safe.
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 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 theObservedBounds
map in the checking state. If theAbstractSet
containinge
is present inObservedBounds
, then those are the bounds for the value ofe
. Otherwise, the bounds for the value ofe
default to the lvalue target bounds ofe
(or the lvalue bounds ofe
ife
is the subexpression of anArrayToPointerDecay
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 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 theAbstractSet
that contains*p
andp[0]
, sop[0]
is the representative expression for thisAbstractSet
.This PR also includes a minor fix in CanonBounds where
ExtVectorElementExprs
are compared by address. This prevents anllvm_unreachable
that would otherwise occur when creating anAbstractSet
for a member expression that contains anExtVectorElementExpr
.