From 78ed86a7e53af159034024dd259331c73a075e66 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 18 Jan 2013 22:33:58 +0000 Subject: [PATCH] Adopt llvm::hexDigitValue. llvm-svn: 172861 --- clang/lib/Lex/LiteralSupport.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index f77f80cc9eda..362453ecf6de 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/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");