aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-07-16 06:16:59 +0000
committerChris Lattner <sabre@nondot.org>2007-07-16 06:16:59 +0000
commitf66d3e390fac1dce6b0e3ff1a3d0180638e560f6 (patch)
treeb5be9d5fe511590469a336e2a3c308ea5bbf6b6c
parent99e0d7905d1576ac85bb6f969a2d969c4d2e7f82 (diff)
factor a common predicate into a static method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39903 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Lex/Lexer.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h
index eda9608016..4a8965efa2 100644
--- a/include/clang/Lex/Lexer.h
+++ b/include/clang/Lex/Lexer.h
@@ -216,6 +216,13 @@ private:
// trigraphs), knowing that they only are emitted if the character is
// consumed.
+ /// isObviouslySimpleCharacter - Return true if the specified character is
+ /// obviously the same in translation phase 1 and translation phase 3. This
+ /// can return false for characters that end up being the same, but it will
+ /// never return true for something that needs to be mapped.
+ static bool isObviouslySimpleCharacter(char C) {
+ return C != '?' && C != '\\';
+ }
/// getAndAdvanceChar - Read a single 'character' from the specified buffer,
/// advance over it, and return it. This is tricky in several cases. Here we
@@ -224,7 +231,7 @@ private:
inline char getAndAdvanceChar(const char *&Ptr, LexerToken &Tok) {
// If this is not a trigraph and not a UCN or escaped newline, return
// quickly.
- if (Ptr[0] != '?' && Ptr[0] != '\\') return *Ptr++;
+ if (isObviouslySimpleCharacter(Ptr[0])) return *Ptr++;
unsigned Size = 0;
char C = getCharAndSizeSlow(Ptr, Size, &Tok);
@@ -255,7 +262,7 @@ private:
inline char getCharAndSize(const char *Ptr, unsigned &Size) {
// If this is not a trigraph and not a UCN or escaped newline, return
// quickly.
- if (Ptr[0] != '?' && Ptr[0] != '\\') {
+ if (isObviouslySimpleCharacter(Ptr[0])) {
Size = 1;
return *Ptr;
}
@@ -274,7 +281,7 @@ private:
const LangOptions &Features) {
// If this is not a trigraph and not a UCN or escaped newline, return
// quickly.
- if (Ptr[0] != '?' && Ptr[0] != '\\') {
+ if (isObviouslySimpleCharacter(Ptr[0])) {
Size = 1;
return *Ptr;
}