summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/StringExtras.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-07 08:36:19 +0000
committerChris Lattner <sabre@nondot.org>2002-04-07 08:36:19 +0000
commit35c15b4bfe2de7205bbb35790a3418d7d3288156 (patch)
tree363175b963080860bef14973ae6566a2c17981c6 /include/llvm/ADT/StringExtras.h
parentb55679d427615c969477f002bccb9c6aeafce6c8 (diff)
downloadllvm-35c15b4bfe2de7205bbb35790a3418d7d3288156.tar.gz
llvm-35c15b4bfe2de7205bbb35790a3418d7d3288156.tar.bz2
llvm-35c15b4bfe2de7205bbb35790a3418d7d3288156.tar.xz
Add new function utohexstr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2140 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringExtras.h')
-rw-r--r--include/llvm/ADT/StringExtras.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h
index 46e2c5aaf0..529d86caa2 100644
--- a/include/llvm/ADT/StringExtras.h
+++ b/include/llvm/ADT/StringExtras.h
@@ -11,6 +11,24 @@
#include <string>
#include <stdio.h>
+static inline std::string utohexstr(uint64_t X) {
+ char Buffer[40];
+ char *BufPtr = Buffer+39;
+
+ *BufPtr = 0; // Null terminate buffer...
+ if (X == 0) *--BufPtr = '0'; // Handle special case...
+
+ while (X) {
+ unsigned Mod = X & 15;
+ if (Mod < 10)
+ *--BufPtr = '0' + Mod;
+ else
+ *--BufPtr = 'A' + Mod-10;
+ X >>= 4;
+ }
+ return std::string(BufPtr);
+}
+
static inline std::string utostr(uint64_t X, bool isNeg = false) {
char Buffer[40];
char *BufPtr = Buffer+39;