r227956 - Add some overloads so that floating point literals can be AST matched properly.
Kim Gräsman
kim.grasman at gmail.com
Tue Feb 3 09:41:40 PST 2015
Hi Daniel,
On Tue, Feb 3, 2015 at 10:45 AM, Daniel Jasper <djasper at google.com> wrote:
> Author: djasper
> Date: Tue Feb 3 03:45:52 2015
> New Revision: 227956
>
> URL: http://llvm.org/viewvc/llvm-project?rev=227956&view=rev
> Log:
> Add some overloads so that floating point literals can be AST matched properly.
>
> I am not entirely sure whether the implemented sematics are ideal. In
> particular, should floatLiteral(equals(0.5)) match "0.5f" and should
> floatLiteral(equals(0.5f)) match "0.5". With the overloads in this
> patch, the answer to both questions is yes, but I am happy to change
> that.
This looks scary to me given the general difficulties in comparing floats:
https://randomascii.wordpress.com/2013/07/16/floating-point-determinism/
Or is it safe because they're both fixed literals and not the result
of a calculation? Then again, nothing prevents me from doing;
floatLiteral(equals(sqrt(AnArgument)))
- Kim
More information about the cfe-commits
mailing list