cmath: Skip Libc for integral types in isinf, etc.
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 21 Apr 2017 23:14:55 +0000 (23:14 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 21 Apr 2017 23:14:55 +0000 (23:14 +0000)
commit42f8eee150bbe361eb5f7a9acfa5838e0661177b
tree06748ae24f1552fd4c5f45c8cc3bf00c038abbf9
parente1bd7cceca0b2c2d85d821b5fb7779c697c25469
cmath: Skip Libc for integral types in isinf, etc.

For std::isinf, the standard requires effectively calling isinf as
double from Libc for integral types. But integral types are never
infinite; we don't need to call Libc to return false.

Also short-circuit other functions where Libc won't have interesting
answers: signbit, fpclassify, isfinite, isnan, and isnormal.

I added correctness tests for integral types since we're no longer
deferring to Libc.

In review it was pointed out that in future revisions of the C++
standard we may add more types to std::is_arithmetic (e.g.,
std::is_fixed_point).  I'll leave it to a future commit to hack this to
allow using math functions on those.  We'll need to change things like
__libcpp_fpclassify anyway, so I'm not sure anything here would really
be future-proof.

https://reviews.llvm.org/D31561
rdar://problem/31361223

llvm-svn: 301060
libcxx/include/math.h
libcxx/test/std/numerics/c.math/cmath.pass.cpp