diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-01-18 22:33:58 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-01-18 22:33:58 +0000 |
commit | 728bb4c41844b1df98eb35e7fa98eb5ffa9d65a6 (patch) | |
tree | d667de9d8bf230c929113d92951e579f03fa8cfc /lib/Lex/LiteralSupport.cpp | |
parent | cd6bfd0d020c416fbe411678f2f100fde6112b4e (diff) | |
download | clang-728bb4c41844b1df98eb35e7fa98eb5ffa9d65a6.tar.gz clang-728bb4c41844b1df98eb35e7fa98eb5ffa9d65a6.tar.bz2 clang-728bb4c41844b1df98eb35e7fa98eb5ffa9d65a6.tar.xz |
Adopt llvm::hexDigitValue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172861 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/LiteralSupport.cpp')
-rw-r--r-- | lib/Lex/LiteralSupport.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp index f77f80cc9e..362453ecf6 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -21,15 +21,6 @@ #include "llvm/Support/ErrorHandling.h" using namespace clang; -/// HexDigitValue - Return the value of the specified hex digit, or -1 if it's -/// not valid. -static int HexDigitValue(char C) { - if (C >= '0' && C <= '9') return C-'0'; - if (C >= 'a' && C <= 'f') return C-'a'+10; - if (C >= 'A' && C <= 'F') return C-'A'+10; - return -1; -} - static unsigned getCharWidth(tok::TokenKind kind, const TargetInfo &Target) { switch (kind) { default: llvm_unreachable("Unknown token type!"); @@ -147,7 +138,7 @@ static unsigned ProcessCharEscape(const char *ThisTokBegin, // Hex escapes are a maximal series of hex digits. bool Overflow = false; for (; ThisTokBuf != ThisTokEnd; ++ThisTokBuf) { - int CharVal = HexDigitValue(ThisTokBuf[0]); + int CharVal = llvm::hexDigitValue(ThisTokBuf[0]); if (CharVal == -1) break; // About to shift out a digit? Overflow |= (ResultChar & 0xF0000000) ? true : false; @@ -241,7 +232,7 @@ static bool ProcessUCNEscape(const char *ThisTokBegin, const char *&ThisTokBuf, UcnLen = (ThisTokBuf[-1] == 'u' ? 4 : 8); unsigned short UcnLenSave = UcnLen; for (; ThisTokBuf != ThisTokEnd && UcnLenSave; ++ThisTokBuf, UcnLenSave--) { - int CharVal = HexDigitValue(ThisTokBuf[0]); + int CharVal = llvm::hexDigitValue(ThisTokBuf[0]); if (CharVal == -1) break; UcnVal <<= 4; UcnVal |= CharVal; @@ -792,7 +783,7 @@ bool NumericLiteralParser::GetIntegerValue(llvm::APInt &Val) { if (alwaysFitsInto64Bits(radix, NumDigits)) { uint64_t N = 0; for (const char *Ptr = DigitsBegin; Ptr != SuffixBegin; ++Ptr) - N = N * radix + HexDigitValue(*Ptr); + N = N * radix + llvm::hexDigitValue(*Ptr); // This will truncate the value to Val's input width. Simply check // for overflow by comparing. @@ -809,7 +800,7 @@ bool NumericLiteralParser::GetIntegerValue(llvm::APInt &Val) { bool OverflowOccurred = false; while (Ptr < SuffixBegin) { - unsigned C = HexDigitValue(*Ptr++); + unsigned C = llvm::hexDigitValue(*Ptr++); // If this letter is out of bound for this radix, reject it. assert(C < radix && "NumericLiteralParser ctor should have rejected this"); |