aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/StringExtras.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/ADT/StringExtras.h')
-rw-r--r--include/llvm/ADT/StringExtras.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h
index f0788a1..b56c183 100644
--- a/include/llvm/ADT/StringExtras.h
+++ b/include/llvm/ADT/StringExtras.h
@@ -15,6 +15,7 @@
#define LLVM_ADT_STRINGEXTRAS_H
#include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/APFloat.h"
#include <cctype>
#include <cstdio>
#include <string>
@@ -92,6 +93,14 @@ static inline std::string ftostr(double V) {
return B;
}
+static inline std::string ftostr(APFloat V) {
+ if (&V.getSemantics() == &APFloat::IEEEsingle)
+ return ftostr(V.convertToDouble());
+ else if (&V.getSemantics() == &APFloat::IEEEdouble)
+ return ftostr((double)V.convertToFloat());
+ return 0; // error
+}
+
static inline std::string LowercaseString(const std::string &S) {
std::string result(S);
for (unsigned i = 0; i < S.length(); ++i)