llvm.org GIT mirror llvm / 29eefd2
Merging r352204: ------------------------------------------------------------------------ r352204 | sammccall | 2019-01-25 16:05:33 +0100 (Fri, 25 Jan 2019) | 7 lines [JSON] Work around excess-precision issue when comparing T_Integer numbers. Reviewers: bkramer Subscribers: kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D57237 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_80@352233 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 1 year, 10 months ago
2 changed file(s) with 7 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
480480 mutable llvm::AlignedCharArrayUnion
481481 std::string, json::Array, json::Object>
482482 Union;
483 friend bool operator==(const Value &, const Value &);
483484 };
484485
485486 bool operator==(const Value &, const Value &);
181181 case Value::Boolean:
182182 return *L.getAsBoolean() == *R.getAsBoolean();
183183 case Value::Number:
184 // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
185 // The same integer must convert to the same double, per the standard.
186 // However we see 64-vs-80-bit precision comparisons with gcc-7 -O3 -m32.
187 // So we avoid floating point promotion for exact comparisons.
188 if (L.Type == Value::T_Integer || R.Type == Value::T_Integer)
189 return L.getAsInteger() == R.getAsInteger();
184190 return *L.getAsNumber() == *R.getAsNumber();
185191 case Value::String:
186192 return *L.getAsString() == *R.getAsString();