Skip to content

Get rvalue bounds for the value of lvalue expressions from the CheckingState #1179

@secure-sw-dev-bot

Description

@secure-sw-dev-bot

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions