diff options
Diffstat (limited to 'include/clang/Lex/Lexer.h')
-rw-r--r-- | include/clang/Lex/Lexer.h | 91 |
1 files changed, 42 insertions, 49 deletions
diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h index ca233de..407b644 100644 --- a/include/clang/Lex/Lexer.h +++ b/include/clang/Lex/Lexer.h @@ -31,11 +31,11 @@ class DiagnosticBuilder; enum ConflictMarkerKind { /// Not within a conflict marker. CMK_None, - /// A normal or diff3 conflict marker, initiated by at least 7 <s, - /// separated by at least 7 =s or |s, and terminated by at least 7 >s. + /// A normal or diff3 conflict marker, initiated by at least 7 "<"s, + /// separated by at least 7 "="s or "|"s, and terminated by at least 7 ">"s. CMK_Normal, - /// A Perforce-style conflict marker, initiated by 4 >s, separated by 4 =s, - /// and terminated by 4 <s. + /// A Perforce-style conflict marker, initiated by 4 ">"s, + /// separated by 4 "="s, and terminated by 4 "<"s. CMK_Perforce }; @@ -83,8 +83,8 @@ class Lexer : public PreprocessorLexer { // CurrentConflictMarkerState - The kind of conflict marker we are handling. ConflictMarkerKind CurrentConflictMarkerState; - Lexer(const Lexer&); // DO NOT IMPLEMENT - void operator=(const Lexer&); // DO NOT IMPLEMENT + Lexer(const Lexer &) LLVM_DELETED_FUNCTION; + void operator=(const Lexer &) LLVM_DELETED_FUNCTION; friend class Preprocessor; void InitLexer(const char *BufStart, const char *BufPtr, const char *BufEnd); @@ -128,9 +128,7 @@ public: SourceLocation getFileLoc() const { return FileLoc; } /// Lex - Return the next token in the file. If this is the end of file, it - /// return the tok::eof token. Return true if an error occurred and - /// compilation should terminate, false if normal. This implicitly involves - /// the preprocessor. + /// return the tok::eof token. This implicitly involves the preprocessor. void Lex(Token &Result) { // Start a new token. Result.startToken(); @@ -278,8 +276,6 @@ public: /// \brief Given a location any where in a source buffer, find the location /// that corresponds to the beginning of the token in which the original /// source location lands. - /// - /// \param Loc static SourceLocation GetBeginningOfToken(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts); @@ -324,7 +320,7 @@ public: /// \brief Returns true if the given MacroID location points at the last /// token of the macro expansion. /// - /// \param MacroBegin If non-null and function returns true, it is set to + /// \param MacroEnd If non-null and function returns true, it is set to /// end location of the macro. static bool isAtEndOfMacroExpansion(SourceLocation loc, const SourceManager &SM, @@ -396,7 +392,36 @@ public: static std::pair<unsigned, bool> ComputePreamble(const llvm::MemoryBuffer *Buffer, const LangOptions &LangOpts, unsigned MaxLines = 0); - + + /// \brief Checks that the given token is the first token that occurs after + /// the given location (this excludes comments and whitespace). Returns the + /// location immediately after the specified token. If the token is not found + /// or the location is inside a macro, the returned source location will be + /// invalid. + static SourceLocation findLocationAfterToken(SourceLocation loc, + tok::TokenKind TKind, + const SourceManager &SM, + const LangOptions &LangOpts, + bool SkipTrailingWhitespaceAndNewLine); + + /// \brief Returns true if the given character could appear in an identifier. + static bool isIdentifierBodyChar(char c, const LangOptions &LangOpts); + + /// getCharAndSizeNoWarn - Like the getCharAndSize method, but does not ever + /// emit a warning. + static inline char getCharAndSizeNoWarn(const char *Ptr, unsigned &Size, + const LangOptions &LangOpts) { + // If this is not a trigraph and not a UCN or escaped newline, return + // quickly. + if (isObviouslySimpleCharacter(Ptr[0])) { + Size = 1; + return *Ptr; + } + + Size = 0; + return getCharAndSizeSlowNoWarn(Ptr, Size, LangOpts); + } + //===--------------------------------------------------------------------===// // Internal implementation interfaces. private: @@ -427,7 +452,6 @@ private: //===--------------------------------------------------------------------===// // Lexer character reading interfaces. -public: // This lexer is built on two interfaces for reading characters, both of which // automatically provide phase 1/2 translation. getAndAdvanceChar is used @@ -467,7 +491,6 @@ public: return C; } -private: /// ConsumeChar - When a character (identified by getCharAndSize) is consumed /// and added to a given token, check to see if there are diagnostics that /// need to be emitted or flags that need to be set on the token. If so, do @@ -503,22 +526,6 @@ private: /// getCharAndSizeSlow - Handle the slow/uncommon case of the getCharAndSize /// method. char getCharAndSizeSlow(const char *Ptr, unsigned &Size, Token *Tok = 0); -public: - - /// getCharAndSizeNoWarn - Like the getCharAndSize method, but does not ever - /// emit a warning. - static inline char getCharAndSizeNoWarn(const char *Ptr, unsigned &Size, - const LangOptions &LangOpts) { - // If this is not a trigraph and not a UCN or escaped newline, return - // quickly. - if (isObviouslySimpleCharacter(Ptr[0])) { - Size = 1; - return *Ptr; - } - - Size = 0; - return getCharAndSizeSlowNoWarn(Ptr, Size, LangOpts); - } /// getEscapedNewLineSize - Return the size of the specified escaped newline, /// or 0 if it is not an escaped newline. P[-1] is known to be a "\" on entry @@ -530,22 +537,6 @@ public: /// otherwise return P. static const char *SkipEscapedNewLines(const char *P); - /// \brief Checks that the given token is the first token that occurs after - /// the given location (this excludes comments and whitespace). Returns the - /// location immediately after the specified token. If the token is not found - /// or the location is inside a macro, the returned source location will be - /// invalid. - static SourceLocation findLocationAfterToken(SourceLocation loc, - tok::TokenKind TKind, - const SourceManager &SM, - const LangOptions &LangOpts, - bool SkipTrailingWhitespaceAndNewLine); - - /// \brief Returns true if the given character could appear in an identifier. - static bool isIdentifierBodyChar(char c, const LangOptions &LangOpts); - -private: - /// getCharAndSizeSlowNoWarn - Same as getCharAndSizeSlow, but never emits a /// diagnostic. static char getCharAndSizeSlowNoWarn(const char *Ptr, unsigned &Size, @@ -571,15 +562,17 @@ private: bool LexEndOfFile (Token &Result, const char *CurPtr); bool SkipWhitespace (Token &Result, const char *CurPtr); - bool SkipBCPLComment (Token &Result, const char *CurPtr); + bool SkipLineComment (Token &Result, const char *CurPtr); bool SkipBlockComment (Token &Result, const char *CurPtr); - bool SaveBCPLComment (Token &Result, const char *CurPtr); + bool SaveLineComment (Token &Result, const char *CurPtr); bool IsStartOfConflictMarker(const char *CurPtr); bool HandleEndOfConflictMarker(const char *CurPtr); bool isCodeCompletionPoint(const char *CurPtr) const; void cutOffLexing() { BufferPtr = BufferEnd; } + + bool isHexaLiteral(const char *Start, const LangOptions &LangOpts); }; |