diff options
Diffstat (limited to 'lib/Frontend/LayoutOverrideSource.cpp')
-rw-r--r-- | lib/Frontend/LayoutOverrideSource.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/Frontend/LayoutOverrideSource.cpp b/lib/Frontend/LayoutOverrideSource.cpp index 9309661972..924a64068f 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 @@ using namespace clang; /// \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 @@ LayoutOverrideSource::LayoutOverrideSource(StringRef Filename) { 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 @@ LayoutOverrideSource::LayoutOverrideSource(StringRef Filename) { // 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); } } |