mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 03:24:09 +00:00
Convert some users of ftostr to raw_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94808 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -13,11 +13,11 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/Support/FileUtilities.h"
|
#include "llvm/Support/FileUtilities.h"
|
||||||
#include "llvm/System/Path.h"
|
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
#include "llvm/System/Path.h"
|
||||||
#include "llvm/ADT/OwningPtr.h"
|
#include "llvm/ADT/OwningPtr.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
@ -139,11 +139,11 @@ static bool CompareNumbers(const char *&F1P, const char *&F2P,
|
|||||||
Diff = 0; // Both zero.
|
Diff = 0; // Both zero.
|
||||||
if (Diff > RelTolerance) {
|
if (Diff > RelTolerance) {
|
||||||
if (ErrorMsg) {
|
if (ErrorMsg) {
|
||||||
*ErrorMsg = "Compared: " + ftostr(V1) + " and " + ftostr(V2) + "\n";
|
raw_string_ostream(*ErrorMsg)
|
||||||
*ErrorMsg += "abs. diff = " + ftostr(std::abs(V1-V2)) +
|
<< "Compared: " << V1 << " and " << V2 << '\n'
|
||||||
" rel.diff = " + ftostr(Diff) + "\n";
|
<< "abs. diff = " << std::abs(V1-V2) << " rel.diff = " << Diff << '\n'
|
||||||
*ErrorMsg += "Out of tolerance: rel/abs: " + ftostr(RelTolerance) +
|
<< "Out of tolerance: rel/abs: " << RelTolerance << '/'
|
||||||
"/" + ftostr(AbsTolerance);
|
<< AbsTolerance;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "llvm/ValueSymbolTable.h"
|
#include "llvm/ValueSymbolTable.h"
|
||||||
#include "llvm/TypeSymbolTable.h"
|
#include "llvm/TypeSymbolTable.h"
|
||||||
#include "llvm/ADT/DenseSet.h"
|
#include "llvm/ADT/DenseSet.h"
|
||||||
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
@ -855,7 +856,8 @@ static void WriteConstantInt(raw_ostream &Out, const Constant *CV,
|
|||||||
bool isDouble = &CFP->getValueAPF().getSemantics()==&APFloat::IEEEdouble;
|
bool isDouble = &CFP->getValueAPF().getSemantics()==&APFloat::IEEEdouble;
|
||||||
double Val = isDouble ? CFP->getValueAPF().convertToDouble() :
|
double Val = isDouble ? CFP->getValueAPF().convertToDouble() :
|
||||||
CFP->getValueAPF().convertToFloat();
|
CFP->getValueAPF().convertToFloat();
|
||||||
std::string StrVal = ftostr(CFP->getValueAPF());
|
SmallString<128> StrVal;
|
||||||
|
raw_svector_ostream(StrVal) << Val;
|
||||||
|
|
||||||
// Check to make sure that the stringized number is not some string like
|
// Check to make sure that the stringized number is not some string like
|
||||||
// "Inf" or NaN, that atof will accept, but the lexer will not. Check
|
// "Inf" or NaN, that atof will accept, but the lexer will not. Check
|
||||||
@ -866,7 +868,7 @@ static void WriteConstantInt(raw_ostream &Out, const Constant *CV,
|
|||||||
(StrVal[1] >= '0' && StrVal[1] <= '9'))) {
|
(StrVal[1] >= '0' && StrVal[1] <= '9'))) {
|
||||||
// Reparse stringized version!
|
// Reparse stringized version!
|
||||||
if (atof(StrVal.c_str()) == Val) {
|
if (atof(StrVal.c_str()) == Val) {
|
||||||
Out << StrVal;
|
Out << StrVal.str();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user