[cfe-dev] variable value constraints after comparison

McDowell, Raymond C. via cfe-dev cfe-dev at lists.llvm.org
Thu Aug 4 08:52:50 PDT 2016


When analyzing an if statement such as

  if (x < y) {
    ...
  }

the static analyzer will constrain the value of x or y appropriately in the true branch when the value of the other is known at the time of the condition.  For example, if the range of values for x is [8, 8] and the range of values for y is [1, 64] before the if statement, then in the true branch the range for y will be [9, 64].

However, when the value of both variables is unknown, nothing is done.  It seems like it would not be difficult to restrict the ranges for the variables.  For example, if the range of values for x is [8, 100] and the range of values for y is [1, 64] before the if statement, then in the true branch the range for x should be [8, 63] and the range for y should be [9, 64].

Is there any reason not to restrict the ranges in this way?

Ray
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160804/f16d06e1/attachment.html>


More information about the cfe-dev mailing list