llvm.org GIT mirror llvm / 74cb271
ADT: Surface LowerCase argument for utohexstr The underlying function. utohex_buffer, already supports an argument for deciding if the hex characters should be upper or lower case. Expose an identical argument for utohexstr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212991 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 5 years ago
1 changed file(s) with 4 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
5252 /// This should only be used with unsigned types.
5353 ///
5454 template
55 static inline char *utohex_buffer(IntTy X, char *BufferEnd) {
55 static inline char *utohex_buffer(IntTy X, char *BufferEnd, bool LowerCase = false) {
5656 char *BufPtr = BufferEnd;
5757 *--BufPtr = 0; // Null terminate buffer.
5858 if (X == 0) {
6262
6363 while (X) {
6464 unsigned char Mod = static_cast(X) & 15;
65 *--BufPtr = hexdigit(Mod);
65 *--BufPtr = hexdigit(Mod, LowerCase);
6666 X >>= 4;
6767 }
6868 return BufPtr;
6969 }
7070
71 static inline std::string utohexstr(uint64_t X) {
71 static inline std::string utohexstr(uint64_t X, bool LowerCase = false) {
7272 char Buffer[17];
73 return utohex_buffer(X, Buffer+17);
73 return utohex_buffer(X, Buffer+17, LowerCase);
7474 }
7575
7676 static inline std::string utostr_32(uint32_t X, bool isNeg = false) {