forked from OSchip/llvm-project
Dump floating-point values as strings when dumping to JSON.
This fixes a bug where we would have an invalid JSON attribute (e.g., "value": inf). It also increases the precision of the values because they're not represented as approximate doubles with the host architecture's floating-point model. llvm-svn: 365900
This commit is contained in:
parent
de54e2c4df
commit
4d08f899e3
|
@ -1349,7 +1349,9 @@ void JSONNodeDumper::VisitFixedPointLiteral(const FixedPointLiteral *FPL) {
|
|||
JOS.attribute("value", FPL->getValueAsString(/*Radix=*/10));
|
||||
}
|
||||
void JSONNodeDumper::VisitFloatingLiteral(const FloatingLiteral *FL) {
|
||||
JOS.attribute("value", FL->getValueAsApproximateDouble());
|
||||
llvm::SmallVector<char, 16> Buffer;
|
||||
FL->getValue().toString(Buffer);
|
||||
JOS.attribute("value", Buffer);
|
||||
}
|
||||
void JSONNodeDumper::VisitStringLiteral(const StringLiteral *SL) {
|
||||
std::string Buffer;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -226,7 +226,7 @@ void MaterializeTemp() {
|
|||
// CHECK-NEXT: "qualType": "double"
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "valueCategory": "rvalue",
|
||||
// CHECK-NEXT: "value": 1
|
||||
// CHECK-NEXT: "value": "1"
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: }
|
||||
|
|
Loading…
Reference in New Issue