OSDN Git Service

[Support] Make JSON handle doubles and int64s losslessly
authorSam McCall <sam.mccall@gmail.com>
Mon, 9 Jul 2018 12:16:40 +0000 (12:16 +0000)
committerSam McCall <sam.mccall@gmail.com>
Mon, 9 Jul 2018 12:16:40 +0000 (12:16 +0000)
commit8d164e7fb3d149b462d18965440b7a8cb126e553
tree1fc86e942d1250b29e0303eebcc89254dc2439cf
parent6da02771fb8295bba3e6236b1c2d8994f6d5e13c
[Support] Make JSON handle doubles and int64s losslessly

Summary:
This patch adds a new "integer" ValueType, and renames Number -> Double.
This allows us to preserve the full precision of int64_t when parsing integers
from the wire, or constructing from an integer.
The API is unchanged, other than giving asInteger() a clearer contract.

In addition, always output doubles with enough precision that parsing will
reconstruct the same double.

Reviewers: simon_tatham

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D46209

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336541 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/JSON.h
lib/Support/JSON.cpp
unittests/Support/JSONTest.cpp