[cfe-dev] variable value constraints after comparison

McDowell, Raymond C. via cfe-dev cfe-dev at lists.llvm.org
Tue Aug 16 08:38:58 PDT 2016


Does a checker have access to the value constraints on a variable?  If so, how?

I'm implementing an integer overflow checker and I'm trying to eliminate some of the false positives.

Thanks!

From: McDowell, Raymond C.
Sent: Thursday, August 04, 2016 5:13 PM
To: 'cfe-dev at lists.llvm.org'
Subject: RE: variable value constraints after comparison

Similarly, if the range of values for x is [1,8] and the range of values for y is [64,100], the Static Analyzer doesn't recognize that "x < y" will always be true.

From: McDowell, Raymond C.
Sent: Thursday, August 04, 2016 11:53 AM
To: 'cfe-dev at lists.llvm.org'
Subject: variable value constraints after comparison

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/20160816/6429a16c/attachment.html>


More information about the cfe-dev mailing list