Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.
Nearly all of these changes are one-to-one replacements; the few that
aren't have to do with custom identifier validation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174768 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 644fab9..66980a9 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -23,6 +23,7 @@
#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/Builtins.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Lexer.h"
@@ -844,7 +845,7 @@
assert(Char <= 0xff &&
"Characters above 0xff should already have been handled.");
- if (isprint(Char))
+ if (isPrintable(Char))
OS << (char)Char;
else // Output anything hard as an octal escape.
OS << '\\'
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 3214a2b..2ae5a12 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -19,6 +19,7 @@
#include "clang/AST/StmtCXX.h"
#include "clang/AST/StmtObjC.h"
#include "clang/AST/Type.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Token.h"
#include "llvm/ADT/StringExtras.h"
@@ -539,7 +540,7 @@
// Handle %x4 and %x[foo] by capturing x as the modifier character.
char Modifier = '\0';
- if (isalpha(EscapedChar)) {
+ if (isLetter(EscapedChar)) {
if (CurPtr == StrEnd) { // Premature end.
DiagOffs = CurPtr-StrStart-1;
return diag::err_asm_invalid_escape;
@@ -548,12 +549,12 @@
EscapedChar = *CurPtr++;
}
- if (isdigit(EscapedChar)) {
+ if (isDigit(EscapedChar)) {
// %n - Assembler operand n
unsigned N = 0;
--CurPtr;
- while (CurPtr != StrEnd && isdigit(*CurPtr))
+ while (CurPtr != StrEnd && isDigit(*CurPtr))
N = N*10 + ((*CurPtr++)-'0');
unsigned NumOperands =
diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp
index f5dda30..6519340 100644
--- a/lib/AST/TemplateBase.cpp
+++ b/lib/AST/TemplateBase.cpp
@@ -25,7 +25,6 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
-#include <cctype>
using namespace clang;
diff --git a/lib/Analysis/CocoaConventions.cpp b/lib/Analysis/CocoaConventions.cpp
index ac22671..0db3cac 100644
--- a/lib/Analysis/CocoaConventions.cpp
+++ b/lib/Analysis/CocoaConventions.cpp
@@ -15,9 +15,9 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Type.h"
+#include "clang/Basic/CharInfo.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/ErrorHandling.h"
-#include <cctype>
using namespace clang;
using namespace ento;
@@ -106,7 +106,7 @@
char ch = *it;
if (ch == 'C' || ch == 'c') {
// Make sure this isn't something like 'recreate' or 'Scopy'.
- if (ch == 'c' && it != start && isalpha(*(it - 1)))
+ if (ch == 'c' && it != start && isLetter(*(it - 1)))
continue;
++it;
@@ -131,7 +131,7 @@
continue;
}
- if (it == endI || !islower(*it))
+ if (it == endI || !isLowercase(*it))
return true;
// If we matched a lowercase character, it isn't the end of the
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index 6627ad6..2b44805 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -11,6 +11,7 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/IdentifierTable.h"
@@ -19,7 +20,6 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/raw_ostream.h"
-#include <cctype>
using namespace clang;
@@ -457,8 +457,8 @@
// Escaped characters get implicitly skipped here.
// Format specifier.
- if (!isdigit(*I) && !ispunct(*I)) {
- for (I++; I != E && !isdigit(*I) && *I != '{'; I++) ;
+ if (!isDigit(*I) && !isPunctuation(*I)) {
+ for (I++; I != E && !isDigit(*I) && *I != '{'; I++) ;
if (I == E) break;
if (*I == '{')
Depth++;
@@ -682,7 +682,7 @@
OutStr.append(DiagStr, StrEnd);
DiagStr = StrEnd;
continue;
- } else if (ispunct(DiagStr[1])) {
+ } else if (isPunctuation(DiagStr[1])) {
OutStr.push_back(DiagStr[1]); // %% -> %.
DiagStr += 2;
continue;
@@ -700,7 +700,7 @@
unsigned ModifierLen = 0, ArgumentLen = 0;
// Check to see if we have a modifier. If so eat it.
- if (!isdigit(DiagStr[0])) {
+ if (!isDigit(DiagStr[0])) {
Modifier = DiagStr;
while (DiagStr[0] == '-' ||
(DiagStr[0] >= 'a' && DiagStr[0] <= 'z'))
@@ -719,7 +719,7 @@
}
}
- assert(isdigit(*DiagStr) && "Invalid format for argument in diagnostic");
+ assert(isDigit(*DiagStr) && "Invalid format for argument in diagnostic");
unsigned ArgNo = *DiagStr++ - '0';
// Only used for type diffing.
@@ -727,7 +727,7 @@
DiagnosticsEngine::ArgumentKind Kind = getArgKind(ArgNo);
if (ModifierIs(Modifier, ModifierLen, "diff")) {
- assert(*DiagStr == ',' && isdigit(*(DiagStr + 1)) &&
+ assert(*DiagStr == ',' && isDigit(*(DiagStr + 1)) &&
"Invalid format for diff modifier");
++DiagStr; // Comma.
ArgNo2 = *DiagStr++ - '0';
diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp
index ecaaf03..b943472 100644
--- a/lib/Basic/IdentifierTable.cpp
+++ b/lib/Basic/IdentifierTable.cpp
@@ -13,13 +13,13 @@
//===----------------------------------------------------------------------===//
#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
-#include <cctype>
#include <cstdio>
using namespace clang;
@@ -404,9 +404,8 @@
/// given "word", which is assumed to end in a lowercase letter.
static bool startsWithWord(StringRef name, StringRef word) {
if (name.size() < word.size()) return false;
- return ((name.size() == word.size() ||
- !islower(name[word.size()]))
- && name.startswith(word));
+ return ((name.size() == word.size() || !isLowercase(name[word.size()])) &&
+ name.startswith(word));
}
ObjCMethodFamily Selector::getMethodFamilyImpl(Selector sel) {
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp
index fe68a9d..70ea235 100644
--- a/lib/Basic/TargetInfo.cpp
+++ b/lib/Basic/TargetInfo.cpp
@@ -13,11 +13,11 @@
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/AddressSpaces.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ErrorHandling.h"
-#include <cctype>
#include <cstdlib>
using namespace clang;
@@ -223,7 +223,7 @@
getGCCRegNames(Names, NumNames);
// If we have a number it maps to an entry in the register name array.
- if (isdigit(Name[0])) {
+ if (isDigit(Name[0])) {
int n;
if (!Name.getAsInteger(0, n))
return n >= 0 && (unsigned)n < NumNames;
@@ -279,7 +279,7 @@
getGCCRegNames(Names, NumNames);
// First, check if we have a number.
- if (isdigit(Name[0])) {
+ if (isDigit(Name[0])) {
int n;
if (!Name.getAsInteger(0, n)) {
assert(n >= 0 && (unsigned)n < NumNames &&
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 91f22b1..ff26565 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -30,6 +30,7 @@
#include "clang/AST/RecordLayout.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/Builtins.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/SourceManager.h"
@@ -2936,7 +2937,7 @@
const char *Uuidstr = Uuid.data();
for (int i = 0; i < 36; ++i) {
if (i == 8 || i == 13 || i == 18 || i == 23) assert(Uuidstr[i] == '-');
- else assert(isxdigit(Uuidstr[i]));
+ else assert(isHexDigit(Uuidstr[i]));
}
llvm::APInt Field0(32, StringRef(Uuidstr , 8), 16);
diff --git a/lib/Driver/WindowsToolChain.cpp b/lib/Driver/WindowsToolChain.cpp
index 323765a..f640b17 100644
--- a/lib/Driver/WindowsToolChain.cpp
+++ b/lib/Driver/WindowsToolChain.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "ToolChains.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Version.h"
#include "clang/Driver/Arg.h"
#include "clang/Driver/ArgList.h"
@@ -158,12 +159,12 @@
for (index = 0; RegEnumKeyEx(hTopKey, index, keyName, &size, NULL,
NULL, NULL, NULL) == ERROR_SUCCESS; index++) {
const char *sp = keyName;
- while (*sp && !isdigit(*sp))
+ while (*sp && !isDigit(*sp))
sp++;
if (!*sp)
continue;
const char *ep = sp + 1;
- while (*ep && (isdigit(*ep) || (*ep == '.')))
+ while (*ep && (isDigit(*ep) || (*ep == '.')))
ep++;
char numBuf[32];
strncpy(numBuf, sp, sizeof(numBuf) - 1);
diff --git a/lib/Edit/EditedSource.cpp b/lib/Edit/EditedSource.cpp
index 0027767..dd99ca9 100644
--- a/lib/Edit/EditedSource.cpp
+++ b/lib/Edit/EditedSource.cpp
@@ -8,13 +8,13 @@
//===----------------------------------------------------------------------===//
#include "clang/Edit/EditedSource.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Edit/Commit.h"
#include "clang/Edit/EditsReceiver.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Twine.h"
-#include <cctype>
using namespace clang;
using namespace edit;
@@ -240,16 +240,12 @@
return true;
}
-static inline bool isIdentifierChar(char c, const LangOptions &LangOpts) {
- return std::isalnum(c) || c == '_' || (c == '$' && LangOpts.DollarIdents);
-}
-
// \brief Returns true if it is ok to make the two given characters adjacent.
static bool canBeJoined(char left, char right, const LangOptions &LangOpts) {
- // FIXME: Should use the Lexer to make sure we don't allow stuff like
+ // FIXME: Should use TokenConcatenation to make sure we don't allow stuff like
// making two '<' adjacent.
- return !(isIdentifierChar(left, LangOpts) &&
- isIdentifierChar(right, LangOpts));
+ return !(Lexer::isIdentifierBodyChar(left, LangOpts) &&
+ Lexer::isIdentifierBodyChar(right, LangOpts));
}
/// \brief Returns true if it is ok to eliminate the trailing whitespace between
@@ -258,7 +254,7 @@
const LangOptions &LangOpts) {
if (!canBeJoined(left, right, LangOpts))
return false;
- if (std::isspace(left) || std::isspace(right))
+ if (isWhitespace(left) || isWhitespace(right))
return true;
if (canBeJoined(beforeWSpace, right, LangOpts))
return false; // the whitespace was intentional, keep it.
diff --git a/lib/Frontend/LayoutOverrideSource.cpp b/lib/Frontend/LayoutOverrideSource.cpp
index 9309661..924a640 100644
--- a/lib/Frontend/LayoutOverrideSource.cpp
+++ b/lib/Frontend/LayoutOverrideSource.cpp
@@ -8,8 +8,8 @@
//===----------------------------------------------------------------------===//
#include "clang/Frontend/LayoutOverrideSource.h"
#include "clang/AST/Decl.h"
+#include "clang/Basic/CharInfo.h"
#include "llvm/Support/raw_ostream.h"
-#include <cctype>
#include <fstream>
#include <string>
@@ -17,10 +17,11 @@
/// \brief Parse a simple identifier.
static std::string parseName(StringRef S) {
- unsigned Offset = 0;
- while (Offset < S.size() &&
- (isalpha(S[Offset]) || S[Offset] == '_' ||
- (Offset > 0 && isdigit(S[Offset]))))
+ if (S.empty() || !isIdentifierHead(S[0]))
+ return "";
+
+ unsigned Offset = 1;
+ while (Offset < S.size() && isIdentifierBody(S[Offset]))
++Offset;
return S.substr(0, Offset).str();
@@ -128,10 +129,10 @@
continue;
LineStr = LineStr.substr(Pos + strlen("FieldOffsets: ["));
- while (!LineStr.empty() && isdigit(LineStr[0])) {
+ while (!LineStr.empty() && isDigit(LineStr[0])) {
// Parse this offset.
unsigned Idx = 1;
- while (Idx < LineStr.size() && isdigit(LineStr[Idx]))
+ while (Idx < LineStr.size() && isDigit(LineStr[Idx]))
++Idx;
unsigned long long Offset = 0;
@@ -141,7 +142,7 @@
// Skip over this offset, the following comma, and any spaces.
LineStr = LineStr.substr(Idx + 1);
- while (!LineStr.empty() && isspace(LineStr[0]))
+ while (!LineStr.empty() && isWhitespace(LineStr[0]))
LineStr = LineStr.substr(1);
}
}
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp
index e7b6497..4024093 100644
--- a/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Frontend/Utils.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/PreprocessorOutputOptions.h"
@@ -26,7 +27,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
-#include <cctype>
#include <cstdio>
using namespace clang;
@@ -350,7 +350,7 @@
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
unsigned char Char = Str[i];
- if (isprint(Char) && Char != '\\' && Char != '"')
+ if (isPrintable(Char) && Char != '\\' && Char != '"')
OS << (char)Char;
else // Output anything hard as an octal escape.
OS << '\\'
@@ -375,7 +375,7 @@
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
unsigned char Char = Str[i];
- if (isprint(Char) && Char != '\\' && Char != '"')
+ if (isPrintable(Char) && Char != '\\' && Char != '"')
OS << (char)Char;
else // Output anything hard as an octal escape.
OS << '\\'
diff --git a/lib/Frontend/TextDiagnostic.cpp b/lib/Frontend/TextDiagnostic.cpp
index 28c2a39..c972461 100644
--- a/lib/Frontend/TextDiagnostic.cpp
+++ b/lib/Frontend/TextDiagnostic.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Frontend/TextDiagnostic.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
@@ -20,7 +21,6 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
-#include <cctype>
using namespace clang;
@@ -348,11 +348,11 @@
// correctly.
unsigned CaretStart = 0, CaretEnd = CaretLine.size();
for (; CaretStart != CaretEnd; ++CaretStart)
- if (!isspace(static_cast<unsigned char>(CaretLine[CaretStart])))
+ if (!isWhitespace(CaretLine[CaretStart]))
break;
for (; CaretEnd != CaretStart; --CaretEnd)
- if (!isspace(static_cast<unsigned char>(CaretLine[CaretEnd - 1])))
+ if (!isWhitespace(CaretLine[CaretEnd - 1]))
break;
// caret has already been inserted into CaretLine so the above whitespace
@@ -363,11 +363,11 @@
if (!FixItInsertionLine.empty()) {
unsigned FixItStart = 0, FixItEnd = FixItInsertionLine.size();
for (; FixItStart != FixItEnd; ++FixItStart)
- if (!isspace(static_cast<unsigned char>(FixItInsertionLine[FixItStart])))
+ if (!isWhitespace(FixItInsertionLine[FixItStart]))
break;
for (; FixItEnd != FixItStart; --FixItEnd)
- if (!isspace(static_cast<unsigned char>(FixItInsertionLine[FixItEnd - 1])))
+ if (!isWhitespace(FixItInsertionLine[FixItEnd - 1]))
break;
CaretStart = std::min(FixItStart, CaretStart);
@@ -423,14 +423,13 @@
// Skip over any whitespace we see here; we're looking for
// another bit of interesting text.
// FIXME: Detect non-ASCII whitespace characters too.
- while (NewStart &&
- isspace(static_cast<unsigned char>(SourceLine[NewStart])))
+ while (NewStart && isWhitespace(SourceLine[NewStart]))
NewStart = map.startOfPreviousColumn(NewStart);
// Skip over this bit of "interesting" text.
while (NewStart) {
unsigned Prev = map.startOfPreviousColumn(NewStart);
- if (isspace(static_cast<unsigned char>(SourceLine[Prev])))
+ if (isWhitespace(SourceLine[Prev]))
break;
NewStart = Prev;
}
@@ -450,13 +449,11 @@
// Skip over any whitespace we see here; we're looking for
// another bit of interesting text.
// FIXME: Detect non-ASCII whitespace characters too.
- while (NewEnd < SourceLine.size() &&
- isspace(static_cast<unsigned char>(SourceLine[NewEnd])))
+ while (NewEnd < SourceLine.size() && isWhitespace(SourceLine[NewEnd]))
NewEnd = map.startOfNextColumn(NewEnd);
// Skip over this bit of "interesting" text.
- while (NewEnd < SourceLine.size() &&
- !isspace(static_cast<unsigned char>(SourceLine[NewEnd])))
+ while (NewEnd < SourceLine.size() && isWhitespace(SourceLine[NewEnd]))
NewEnd = map.startOfNextColumn(NewEnd);
assert(map.byteToColumn(NewEnd) != -1);
@@ -517,7 +514,7 @@
/// greater than or equal to Idx or, if no such character exists,
/// returns the end of the string.
static unsigned skipWhitespace(unsigned Idx, StringRef Str, unsigned Length) {
- while (Idx < Length && isspace(Str[Idx]))
+ while (Idx < Length && isWhitespace(Str[Idx]))
++Idx;
return Idx;
}
@@ -562,7 +559,7 @@
char EndPunct = findMatchingPunctuation(Str[Start]);
if (!EndPunct) {
// This is a normal word. Just find the first space character.
- while (End < Length && !isspace(Str[End]))
+ while (End < Length && !isWhitespace(Str[End]))
++End;
return End;
}
@@ -581,7 +578,7 @@
}
// Find the first space character after the punctuation ended.
- while (End < Length && !isspace(Str[End]))
+ while (End < Length && !isWhitespace(Str[End]))
++End;
unsigned PunctWordLength = End - Start;
diff --git a/lib/Frontend/VerifyDiagnosticConsumer.cpp b/lib/Frontend/VerifyDiagnosticConsumer.cpp
index b4b51f3..82f6e91 100644
--- a/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Frontend/VerifyDiagnosticConsumer.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/FileManager.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/TextDiagnosticBuffer.h"
@@ -20,7 +21,6 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/raw_ostream.h"
-#include <cctype>
using namespace clang;
typedef VerifyDiagnosticConsumer::Directive Directive;
@@ -234,7 +234,7 @@
break;
if (!EnsureStartOfWord
// Check if string literal starts a new word.
- || P == Begin || isspace(P[-1])
+ || P == Begin || isWhitespace(P[-1])
// Or it could be preceeded by the start of a comment.
|| (P > (Begin + 1) && (P[-1] == '/' || P[-1] == '*')
&& P[-2] == '/'))
@@ -253,7 +253,7 @@
// Skip zero or more whitespace.
void SkipWhitespace() {
- for (; C < End && isspace(*C); ++C)
+ for (; C < End && isWhitespace(*C); ++C)
;
}
diff --git a/lib/Lex/HeaderMap.cpp b/lib/Lex/HeaderMap.cpp
index 7dc0491..9be7b03 100644
--- a/lib/Lex/HeaderMap.cpp
+++ b/lib/Lex/HeaderMap.cpp
@@ -18,7 +18,6 @@
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
-#include <cctype>
#include <cstdio>
using namespace clang;
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp
index b6cc599..91da822 100644
--- a/lib/Lex/LiteralSupport.cpp
+++ b/lib/Lex/LiteralSupport.cpp
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Lex/LiteralSupport.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Lex/Preprocessor.h"
@@ -128,7 +129,7 @@
break;
case 'x': { // Hex escape.
ResultChar = 0;
- if (ThisTokBuf == ThisTokEnd || !isxdigit(*ThisTokBuf)) {
+ if (ThisTokBuf == ThisTokEnd || !isHexDigit(*ThisTokBuf)) {
if (Diags)
Diag(Diags, Features, Loc, ThisTokBegin, EscapeBegin, ThisTokBuf,
diag::err_hex_escape_no_digits) << "x";
@@ -197,7 +198,7 @@
if (Diags == 0)
break;
- if (isgraph(ResultChar))
+ if (isPrintable(ResultChar))
Diag(Diags, Features, Loc, ThisTokBegin, EscapeBegin, ThisTokBuf,
diag::ext_unknown_escape)
<< std::string(1, ResultChar);
@@ -224,7 +225,7 @@
// Skip the '\u' char's.
ThisTokBuf += 2;
- if (ThisTokBuf == ThisTokEnd || !isxdigit(*ThisTokBuf)) {
+ if (ThisTokBuf == ThisTokEnd || !isHexDigit(*ThisTokBuf)) {
if (Diags)
Diag(Diags, Features, Loc, ThisTokBegin, UcnBegin, ThisTokBuf,
diag::err_hex_escape_no_digits) << StringRef(&ThisTokBuf[-1], 1);
@@ -459,8 +460,7 @@
// and FP constants (specifically, the 'pp-number' regex), and assumes that
// the byte at "*end" is both valid and not part of the regex. Because of
// this, it doesn't have to check for 'overscan' in various places.
- assert(!isalnum(*ThisTokEnd) && *ThisTokEnd != '.' && *ThisTokEnd != '_' &&
- "Lexer didn't maximally munch?");
+ assert(!isPreprocessingNumberBody(*ThisTokEnd) && "didn't maximally munch?");
s = DigitsBegin = ThisTokBegin;
saw_exponent = false;
@@ -483,7 +483,7 @@
s = SkipDigits(s);
if (s == ThisTokEnd) {
// Done.
- } else if (isxdigit(*s) && !(*s == 'e' || *s == 'E')) {
+ } else if (isHexDigit(*s) && !(*s == 'e' || *s == 'E')) {
PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin),
diag::err_invalid_decimal_digit) << StringRef(s, 1);
hadError = true;
@@ -635,7 +635,7 @@
s++;
// Handle a hex number like 0x1234.
- if ((*s == 'x' || *s == 'X') && (isxdigit(s[1]) || s[1] == '.')) {
+ if ((*s == 'x' || *s == 'X') && (isHexDigit(s[1]) || s[1] == '.')) {
s++;
radix = 16;
DigitsBegin = s;
@@ -694,7 +694,7 @@
s = SkipBinaryDigits(s);
if (s == ThisTokEnd) {
// Done.
- } else if (isxdigit(*s)) {
+ } else if (isHexDigit(*s)) {
PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
diag::err_invalid_binary_digit) << StringRef(s, 1);
hadError = true;
@@ -714,7 +714,7 @@
// If we have some other non-octal digit that *is* a decimal digit, see if
// this is part of a floating point number like 094.123 or 09e1.
- if (isdigit(*s)) {
+ if (isDigit(*s)) {
const char *EndDecimal = SkipDigits(s);
if (EndDecimal[0] == '.' || EndDecimal[0] == 'e' || EndDecimal[0] == 'E') {
s = EndDecimal;
@@ -724,7 +724,7 @@
// If we have a hex digit other than 'e' (which denotes a FP exponent) then
// the code is using an incorrect base.
- if (isxdigit(*s) && *s != 'e' && *s != 'E') {
+ if (isHexDigit(*s) && *s != 'e' && *s != 'E') {
PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
diag::err_invalid_octal_digit) << StringRef(s, 1);
hadError = true;
diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp
index 2f40e24..1ceed54 100644
--- a/lib/Lex/ModuleMap.cpp
+++ b/lib/Lex/ModuleMap.cpp
@@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//
#include "clang/Lex/ModuleMap.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/FileManager.h"
@@ -107,26 +108,15 @@
if (Name.empty())
return Name;
- // Check whether the filename is already an identifier; this is the common
- // case.
- bool isIdentifier = true;
- for (unsigned I = 0, N = Name.size(); I != N; ++I) {
- if (isalpha(Name[I]) || Name[I] == '_' || (isdigit(Name[I]) && I > 0))
- continue;
-
- isIdentifier = false;
- break;
- }
-
- if (!isIdentifier) {
+ if (!isValidIdentifier(Name)) {
// If we don't already have something with the form of an identifier,
// create a buffer with the sanitized name.
Buffer.clear();
- if (isdigit(Name[0]))
+ if (isDigit(Name[0]))
Buffer.push_back('_');
Buffer.reserve(Buffer.size() + Name.size());
for (unsigned I = 0, N = Name.size(); I != N; ++I) {
- if (isalnum(Name[I]) || isspace(Name[I]))
+ if (isIdentifierBody(Name[I]))
Buffer.push_back(Name[I]);
else
Buffer.push_back('_');
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 3356637..c8e1f4f 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -790,7 +790,7 @@
// here.
Val = 0;
for (unsigned i = 0; i != ActualLength; ++i) {
- if (!isdigit(DigitTokBegin[i])) {
+ if (!isDigit(DigitTokBegin[i])) {
PP.Diag(PP.AdvanceToTokenCharacter(DigitTok.getLocation(), i),
diag::err_pp_line_digit_sequence);
PP.DiscardUntilEndOfDirective();
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 14fd581..c5e4144 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -14,6 +14,7 @@
#include "clang/Parse/Parser.h"
#include "RAIIObjectsForParser.h"
#include "clang/Basic/AddressSpaces.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/OpenCL.h"
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Sema/Lookup.h"
@@ -570,7 +571,7 @@
// Parse the major version.
unsigned AfterMajor = 0;
unsigned Major = 0;
- while (AfterMajor < ActualLength && isdigit(ThisTokBegin[AfterMajor])) {
+ while (AfterMajor < ActualLength && isDigit(ThisTokBegin[AfterMajor])) {
Major = Major * 10 + ThisTokBegin[AfterMajor] - '0';
++AfterMajor;
}
@@ -602,7 +603,7 @@
// Parse the minor version.
unsigned AfterMinor = AfterMajor + 1;
unsigned Minor = 0;
- while (AfterMinor < ActualLength && isdigit(ThisTokBegin[AfterMinor])) {
+ while (AfterMinor < ActualLength && isDigit(ThisTokBegin[AfterMinor])) {
Minor = Minor * 10 + ThisTokBegin[AfterMinor] - '0';
++AfterMinor;
}
@@ -629,7 +630,7 @@
// Parse the subminor version.
unsigned AfterSubminor = AfterMinor + 1;
unsigned Subminor = 0;
- while (AfterSubminor < ActualLength && isdigit(ThisTokBegin[AfterSubminor])) {
+ while (AfterSubminor < ActualLength && isDigit(ThisTokBegin[AfterSubminor])) {
Subminor = Subminor * 10 + ThisTokBegin[AfterSubminor] - '0';
++AfterSubminor;
}
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index 4956c10..1a1eeb9 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -13,6 +13,7 @@
#include "clang/Parse/Parser.h"
#include "RAIIObjectsForParser.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/OperatorKinds.h"
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Sema/DeclSpec.h"
@@ -3032,7 +3033,7 @@
// starts with an alphabetical character.
SmallString<8> SpellingBuf;
StringRef Spelling = PP.getSpelling(Tok.getLocation(), SpellingBuf);
- if (std::isalpha(Spelling[0])) {
+ if (isLetter(Spelling[0])) {
Loc = ConsumeToken();
return &PP.getIdentifierTable().get(Spelling);
}
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index b331def..ec4fd82 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -13,6 +13,7 @@
#include "clang/Parse/Parser.h"
#include "RAIIObjectsForParser.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Sema/DeclSpec.h"
#include "clang/Sema/PrettyDeclStackTrace.h"
@@ -690,7 +691,7 @@
case tok::caret:
case tok::caretequal: {
std::string ThisTok(PP.getSpelling(Tok));
- if (isalpha(ThisTok[0])) {
+ if (isLetter(ThisTok[0])) {
IdentifierInfo *II = &PP.getIdentifierTable().get(ThisTok.data());
Tok.setKind(tok::identifier);
SelectorLoc = ConsumeToken();
diff --git a/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/lib/Rewrite/Frontend/RewriteModernObjC.cpp
index ba5d669..34ffd22 100644
--- a/lib/Rewrite/Frontend/RewriteModernObjC.cpp
+++ b/lib/Rewrite/Frontend/RewriteModernObjC.cpp
@@ -16,6 +16,7 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/Attr.h"
#include "clang/AST/ParentMap.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceManager.h"
@@ -2608,7 +2609,7 @@
for (i=0; i < tmpName.length(); i++) {
char c = tmpName.at(i);
// replace any non alphanumeric characters with '_'.
- if (!isalpha(c) && (c < '0' || c > '9'))
+ if (!isAlphanumeric(c))
tmpName[i] = '_';
}
S += tmpName;
diff --git a/lib/Rewrite/Frontend/RewriteObjC.cpp b/lib/Rewrite/Frontend/RewriteObjC.cpp
index 18b7575..b5d9f0c 100644
--- a/lib/Rewrite/Frontend/RewriteObjC.cpp
+++ b/lib/Rewrite/Frontend/RewriteObjC.cpp
@@ -16,6 +16,7 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/Attr.h"
#include "clang/AST/ParentMap.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceManager.h"
@@ -2529,7 +2530,7 @@
for (i=0; i < tmpName.length(); i++) {
char c = tmpName.at(i);
// replace any non alphanumeric characters with '_'.
- if (!isalpha(c) && (c < '0' || c > '9'))
+ if (!isAlphanumeric(c))
tmpName[i] = '_';
}
S += tmpName;
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 800f64c..17ce614 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -24,6 +24,7 @@
#include "clang/AST/StmtCXX.h"
#include "clang/AST/StmtObjC.h"
#include "clang/Analysis/Analyses/FormatString.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Preprocessor.h"
@@ -6172,7 +6173,7 @@
return false;
if (str.empty()) return true;
- return !islower(str.front());
+ return !isLowercase(str.front());
}
/// Check a message send to see if it's likely to cause a retain cycle.
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 8aedaf7..4c8d098 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -19,6 +19,7 @@
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Sema/DeclSpec.h"
@@ -4478,7 +4479,7 @@
S.Diag(Attr.getLoc(), diag::err_attribute_uuid_malformed_guid);
return;
}
- } else if (!isxdigit(*I)) {
+ } else if (!isHexDigit(*I)) {
S.Diag(Attr.getLoc(), diag::err_attribute_uuid_malformed_guid);
return;
}
diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp
index bf3b82b..5770675 100644
--- a/lib/Sema/SemaPseudoObject.cpp
+++ b/lib/Sema/SemaPseudoObject.cpp
@@ -32,6 +32,7 @@
#include "clang/Sema/SemaInternal.h"
#include "clang/AST/ExprObjC.h"
+#include "clang/Basic/CharInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/ScopeInfo.h"
@@ -562,8 +563,9 @@
if (const ObjCInterfaceDecl *IFace =
dyn_cast<ObjCInterfaceDecl>(setter->getDeclContext())) {
const StringRef thisPropertyName(prop->getName());
+ // Try flipping the case of the first character.
char front = thisPropertyName.front();
- front = islower(front) ? toupper(front) : tolower(front);
+ front = isLowercase(front) ? toUppercase(front) : toLowercase(front);
SmallString<100> PropertyName = thisPropertyName;
PropertyName[0] = front;
IdentifierInfo *AltMember = &S.PP.getIdentifierTable().get(PropertyName);