diff options
author | Sam McCall <sam.mccall@gmail.com> | 2019-01-25 15:05:33 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2019-01-25 15:05:33 +0000 |
commit | 1e7491ea9c359c01009c6b44a117b03c6469b63f (patch) | |
tree | 6ba6f6a5d93f001dc0f693b0d9e6217e0919c787 /llvm/lib/Support | |
parent | 12430bf60b45a7d3a09583cc3746293771023964 (diff) | |
download | bcm5719-llvm-1e7491ea9c359c01009c6b44a117b03c6469b63f.tar.gz bcm5719-llvm-1e7491ea9c359c01009c6b44a117b03c6469b63f.zip |
[JSON] Work around excess-precision issue when comparing T_Integer numbers.
Reviewers: bkramer
Subscribers: kristina, llvm-commits
Differential Revision: https://reviews.llvm.org/D57237
llvm-svn: 352204
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/JSON.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Support/JSON.cpp b/llvm/lib/Support/JSON.cpp index 4b67536ce4c..790b28f6e31 100644 --- a/llvm/lib/Support/JSON.cpp +++ b/llvm/lib/Support/JSON.cpp @@ -181,6 +181,12 @@ bool operator==(const Value &L, const Value &R) { case Value::Boolean: return *L.getAsBoolean() == *R.getAsBoolean(); case Value::Number: + // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323 + // The same integer must convert to the same double, per the standard. + // However we see 64-vs-80-bit precision comparisons with gcc-7 -O3 -m32. + // So we avoid floating point promotion for exact comparisons. + if (L.Type == Value::T_Integer || R.Type == Value::T_Integer) + return L.getAsInteger() == R.getAsInteger(); return *L.getAsNumber() == *R.getAsNumber(); case Value::String: return *L.getAsString() == *R.getAsString(); |