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 fixes a bug with the way equivalent expressions were being recorded in RecordEqualityWithTarget.
In an assignment such as x++, x += 1, x = x + 1, etc., SameValue is empty after calling UpdateSameValueAfterAssignment (since the RHS x + 1 of the assignment uses the value of the LHS x). This meant that SrcAllowedInEquivExprs was false in RecordEqualityWithTarget, so the mapping x => x + 1 was added to TargetSrcEquality. The information in TargetSrcEquality is added to EquivExprs in ValidateBoundsContext, so EquivExprs would contain a set that contained both x and x + 1 only while checking bounds after the current top-level statement.
This PR adds an AllowTempEquality argument to RecordEqualityWithTarget that controls whether the mapping Target => Src is permitted to be added to TargetSrcEquality. UpdateSameValueAfterAssignment now returns true if State.SameValue was unchanged by the assignment (if the RHS of the assignment uses the value of the LHS, then at least one expression will be removed from State.SameValue if State.SameValue was initially nonempty). If State.SameValue was unchanged by the assignment, then temporary equality is allowed to be recorded between Target and Src.
This PR fixes a bug with the way equivalent expressions were being recorded in
RecordEqualityWithTarget
.In an assignment such as
x++
,x += 1
,x = x + 1
, etc.,SameValue
is empty after callingUpdateSameValueAfterAssignment
(since the RHSx + 1
of the assignment uses the value of the LHSx
). This meant thatSrcAllowedInEquivExprs
wasfalse
inRecordEqualityWithTarget
, so the mappingx => x + 1
was added toTargetSrcEquality
. The information inTargetSrcEquality
is added toEquivExprs
inValidateBoundsContext
, soEquivExprs
would contain a set that contained bothx
andx + 1
only while checking bounds after the current top-level statement.This PR adds an
AllowTempEquality
argument toRecordEqualityWithTarget
that controls whether the mappingTarget => Src
is permitted to be added toTargetSrcEquality
.UpdateSameValueAfterAssignment
now returnstrue
ifState.SameValue
was unchanged by the assignment (if the RHS of the assignment uses the value of the LHS, then at least one expression will be removed fromState.SameValue
ifState.SameValue
was initially nonempty). IfState.SameValue
was unchanged by the assignment, then temporary equality is allowed to be recorded betweenTarget
andSrc
.