clang API Documentation
00001 //===--- Lexer.h - C Language Family Lexer ----------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the Lexer interface. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_CLANG_LEXER_H 00015 #define LLVM_CLANG_LEXER_H 00016 00017 #include "clang/Lex/PreprocessorLexer.h" 00018 #include "clang/Basic/LangOptions.h" 00019 #include "llvm/ADT/SmallVector.h" 00020 #include <string> 00021 #include <cassert> 00022 00023 namespace clang { 00024 class DiagnosticsEngine; 00025 class SourceManager; 00026 class Preprocessor; 00027 class DiagnosticBuilder; 00028 00029 /// ConflictMarkerKind - Kinds of conflict marker which the lexer might be 00030 /// recovering from. 00031 enum ConflictMarkerKind { 00032 /// Not within a conflict marker. 00033 CMK_None, 00034 /// A normal or diff3 conflict marker, initiated by at least 7 <s, 00035 /// separated by at least 7 =s or |s, and terminated by at least 7 >s. 00036 CMK_Normal, 00037 /// A Perforce-style conflict marker, initiated by 4 >s, separated by 4 =s, 00038 /// and terminated by 4 <s. 00039 CMK_Perforce 00040 }; 00041 00042 /// Lexer - This provides a simple interface that turns a text buffer into a 00043 /// stream of tokens. This provides no support for file reading or buffering, 00044 /// or buffering/seeking of tokens, only forward lexing is supported. It relies 00045 /// on the specified Preprocessor object to handle preprocessor directives, etc. 00046 class Lexer : public PreprocessorLexer { 00047 virtual void anchor(); 00048 00049 //===--------------------------------------------------------------------===// 00050 // Constant configuration values for this lexer. 00051 const char *BufferStart; // Start of the buffer. 00052 const char *BufferEnd; // End of the buffer. 00053 SourceLocation FileLoc; // Location for start of file. 00054 LangOptions LangOpts; // LangOpts enabled by this language (cache). 00055 bool Is_PragmaLexer; // True if lexer for _Pragma handling. 00056 00057 //===--------------------------------------------------------------------===// 00058 // Context-specific lexing flags set by the preprocessor. 00059 // 00060 00061 /// ExtendedTokenMode - The lexer can optionally keep comments and whitespace 00062 /// and return them as tokens. This is used for -C and -CC modes, and 00063 /// whitespace preservation can be useful for some clients that want to lex 00064 /// the file in raw mode and get every character from the file. 00065 /// 00066 /// When this is set to 2 it returns comments and whitespace. When set to 1 00067 /// it returns comments, when it is set to 0 it returns normal tokens only. 00068 unsigned char ExtendedTokenMode; 00069 00070 //===--------------------------------------------------------------------===// 00071 // Context that changes as the file is lexed. 00072 // NOTE: any state that mutates when in raw mode must have save/restore code 00073 // in Lexer::isNextPPTokenLParen. 00074 00075 // BufferPtr - Current pointer into the buffer. This is the next character 00076 // to be lexed. 00077 const char *BufferPtr; 00078 00079 // IsAtStartOfLine - True if the next lexed token should get the "start of 00080 // line" flag set on it. 00081 bool IsAtStartOfLine; 00082 00083 // CurrentConflictMarkerState - The kind of conflict marker we are handling. 00084 ConflictMarkerKind CurrentConflictMarkerState; 00085 00086 Lexer(const Lexer&); // DO NOT IMPLEMENT 00087 void operator=(const Lexer&); // DO NOT IMPLEMENT 00088 friend class Preprocessor; 00089 00090 void InitLexer(const char *BufStart, const char *BufPtr, const char *BufEnd); 00091 public: 00092 00093 /// Lexer constructor - Create a new lexer object for the specified buffer 00094 /// with the specified preprocessor managing the lexing process. This lexer 00095 /// assumes that the associated file buffer and Preprocessor objects will 00096 /// outlive it, so it doesn't take ownership of either of them. 00097 Lexer(FileID FID, const llvm::MemoryBuffer *InputBuffer, Preprocessor &PP); 00098 00099 /// Lexer constructor - Create a new raw lexer object. This object is only 00100 /// suitable for calls to 'LexRawToken'. This lexer assumes that the text 00101 /// range will outlive it, so it doesn't take ownership of it. 00102 Lexer(SourceLocation FileLoc, const LangOptions &LangOpts, 00103 const char *BufStart, const char *BufPtr, const char *BufEnd); 00104 00105 /// Lexer constructor - Create a new raw lexer object. This object is only 00106 /// suitable for calls to 'LexRawToken'. This lexer assumes that the text 00107 /// range will outlive it, so it doesn't take ownership of it. 00108 Lexer(FileID FID, const llvm::MemoryBuffer *InputBuffer, 00109 const SourceManager &SM, const LangOptions &LangOpts); 00110 00111 /// Create_PragmaLexer: Lexer constructor - Create a new lexer object for 00112 /// _Pragma expansion. This has a variety of magic semantics that this method 00113 /// sets up. It returns a new'd Lexer that must be delete'd when done. 00114 static Lexer *Create_PragmaLexer(SourceLocation SpellingLoc, 00115 SourceLocation ExpansionLocStart, 00116 SourceLocation ExpansionLocEnd, 00117 unsigned TokLen, Preprocessor &PP); 00118 00119 00120 /// getLangOpts - Return the language features currently enabled. 00121 /// NOTE: this lexer modifies features as a file is parsed! 00122 const LangOptions &getLangOpts() const { return LangOpts; } 00123 00124 /// getFileLoc - Return the File Location for the file we are lexing out of. 00125 /// The physical location encodes the location where the characters come from, 00126 /// the virtual location encodes where we should *claim* the characters came 00127 /// from. Currently this is only used by _Pragma handling. 00128 SourceLocation getFileLoc() const { return FileLoc; } 00129 00130 /// Lex - Return the next token in the file. If this is the end of file, it 00131 /// return the tok::eof token. Return true if an error occurred and 00132 /// compilation should terminate, false if normal. This implicitly involves 00133 /// the preprocessor. 00134 void Lex(Token &Result) { 00135 // Start a new token. 00136 Result.startToken(); 00137 00138 // NOTE, any changes here should also change code after calls to 00139 // Preprocessor::HandleDirective 00140 if (IsAtStartOfLine) { 00141 Result.setFlag(Token::StartOfLine); 00142 IsAtStartOfLine = false; 00143 } 00144 00145 // Get a token. Note that this may delete the current lexer if the end of 00146 // file is reached. 00147 LexTokenInternal(Result); 00148 } 00149 00150 /// isPragmaLexer - Returns true if this Lexer is being used to lex a pragma. 00151 bool isPragmaLexer() const { return Is_PragmaLexer; } 00152 00153 /// IndirectLex - An indirect call to 'Lex' that can be invoked via 00154 /// the PreprocessorLexer interface. 00155 void IndirectLex(Token &Result) { Lex(Result); } 00156 00157 /// LexFromRawLexer - Lex a token from a designated raw lexer (one with no 00158 /// associated preprocessor object. Return true if the 'next character to 00159 /// read' pointer points at the end of the lexer buffer, false otherwise. 00160 bool LexFromRawLexer(Token &Result) { 00161 assert(LexingRawMode && "Not already in raw mode!"); 00162 Lex(Result); 00163 // Note that lexing to the end of the buffer doesn't implicitly delete the 00164 // lexer when in raw mode. 00165 return BufferPtr == BufferEnd; 00166 } 00167 00168 /// isKeepWhitespaceMode - Return true if the lexer should return tokens for 00169 /// every character in the file, including whitespace and comments. This 00170 /// should only be used in raw mode, as the preprocessor is not prepared to 00171 /// deal with the excess tokens. 00172 bool isKeepWhitespaceMode() const { 00173 return ExtendedTokenMode > 1; 00174 } 00175 00176 /// SetKeepWhitespaceMode - This method lets clients enable or disable 00177 /// whitespace retention mode. 00178 void SetKeepWhitespaceMode(bool Val) { 00179 assert((!Val || LexingRawMode) && 00180 "Can only enable whitespace retention in raw mode"); 00181 ExtendedTokenMode = Val ? 2 : 0; 00182 } 00183 00184 /// inKeepCommentMode - Return true if the lexer should return comments as 00185 /// tokens. 00186 bool inKeepCommentMode() const { 00187 return ExtendedTokenMode > 0; 00188 } 00189 00190 /// SetCommentRetentionMode - Change the comment retention mode of the lexer 00191 /// to the specified mode. This is really only useful when lexing in raw 00192 /// mode, because otherwise the lexer needs to manage this. 00193 void SetCommentRetentionState(bool Mode) { 00194 assert(!isKeepWhitespaceMode() && 00195 "Can't play with comment retention state when retaining whitespace"); 00196 ExtendedTokenMode = Mode ? 1 : 0; 00197 } 00198 00199 const char *getBufferStart() const { return BufferStart; } 00200 00201 /// ReadToEndOfLine - Read the rest of the current preprocessor line as an 00202 /// uninterpreted string. This switches the lexer out of directive mode. 00203 void ReadToEndOfLine(SmallVectorImpl<char> *Result = 0); 00204 00205 00206 /// Diag - Forwarding function for diagnostics. This translate a source 00207 /// position in the current buffer into a SourceLocation object for rendering. 00208 DiagnosticBuilder Diag(const char *Loc, unsigned DiagID) const; 00209 00210 /// getSourceLocation - Return a source location identifier for the specified 00211 /// offset in the current file. 00212 SourceLocation getSourceLocation(const char *Loc, unsigned TokLen = 1) const; 00213 00214 /// getSourceLocation - Return a source location for the next character in 00215 /// the current file. 00216 SourceLocation getSourceLocation() { return getSourceLocation(BufferPtr); } 00217 00218 /// \brief Return the current location in the buffer. 00219 const char *getBufferLocation() const { return BufferPtr; } 00220 00221 /// Stringify - Convert the specified string into a C string by escaping '\' 00222 /// and " characters. This does not add surrounding ""'s to the string. 00223 /// If Charify is true, this escapes the ' character instead of ". 00224 static std::string Stringify(const std::string &Str, bool Charify = false); 00225 00226 /// Stringify - Convert the specified string into a C string by escaping '\' 00227 /// and " characters. This does not add surrounding ""'s to the string. 00228 static void Stringify(SmallVectorImpl<char> &Str); 00229 00230 00231 /// getSpelling - This method is used to get the spelling of a token into a 00232 /// preallocated buffer, instead of as an std::string. The caller is required 00233 /// to allocate enough space for the token, which is guaranteed to be at least 00234 /// Tok.getLength() bytes long. The length of the actual result is returned. 00235 /// 00236 /// Note that this method may do two possible things: it may either fill in 00237 /// the buffer specified with characters, or it may *change the input pointer* 00238 /// to point to a constant buffer with the data already in it (avoiding a 00239 /// copy). The caller is not allowed to modify the returned buffer pointer 00240 /// if an internal buffer is returned. 00241 static unsigned getSpelling(const Token &Tok, const char *&Buffer, 00242 const SourceManager &SourceMgr, 00243 const LangOptions &LangOpts, 00244 bool *Invalid = 0); 00245 00246 /// getSpelling() - Return the 'spelling' of the Tok token. The spelling of a 00247 /// token is the characters used to represent the token in the source file 00248 /// after trigraph expansion and escaped-newline folding. In particular, this 00249 /// wants to get the true, uncanonicalized, spelling of things like digraphs 00250 /// UCNs, etc. 00251 static std::string getSpelling(const Token &Tok, 00252 const SourceManager &SourceMgr, 00253 const LangOptions &LangOpts, 00254 bool *Invalid = 0); 00255 00256 /// getSpelling - This method is used to get the spelling of the 00257 /// token at the given source location. If, as is usually true, it 00258 /// is not necessary to copy any data, then the returned string may 00259 /// not point into the provided buffer. 00260 /// 00261 /// This method lexes at the expansion depth of the given 00262 /// location and does not jump to the expansion or spelling 00263 /// location. 00264 static StringRef getSpelling(SourceLocation loc, 00265 SmallVectorImpl<char> &buffer, 00266 const SourceManager &SourceMgr, 00267 const LangOptions &LangOpts, 00268 bool *invalid = 0); 00269 00270 /// MeasureTokenLength - Relex the token at the specified location and return 00271 /// its length in bytes in the input file. If the token needs cleaning (e.g. 00272 /// includes a trigraph or an escaped newline) then this count includes bytes 00273 /// that are part of that. 00274 static unsigned MeasureTokenLength(SourceLocation Loc, 00275 const SourceManager &SM, 00276 const LangOptions &LangOpts); 00277 00278 /// \brief Given a location any where in a source buffer, find the location 00279 /// that corresponds to the beginning of the token in which the original 00280 /// source location lands. 00281 /// 00282 /// \param Loc 00283 static SourceLocation GetBeginningOfToken(SourceLocation Loc, 00284 const SourceManager &SM, 00285 const LangOptions &LangOpts); 00286 00287 /// AdvanceToTokenCharacter - If the current SourceLocation specifies a 00288 /// location at the start of a token, return a new location that specifies a 00289 /// character within the token. This handles trigraphs and escaped newlines. 00290 static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, 00291 unsigned Character, 00292 const SourceManager &SM, 00293 const LangOptions &LangOpts); 00294 00295 /// \brief Computes the source location just past the end of the 00296 /// token at this source location. 00297 /// 00298 /// This routine can be used to produce a source location that 00299 /// points just past the end of the token referenced by \p Loc, and 00300 /// is generally used when a diagnostic needs to point just after a 00301 /// token where it expected something different that it received. If 00302 /// the returned source location would not be meaningful (e.g., if 00303 /// it points into a macro), this routine returns an invalid 00304 /// source location. 00305 /// 00306 /// \param Offset an offset from the end of the token, where the source 00307 /// location should refer to. The default offset (0) produces a source 00308 /// location pointing just past the end of the token; an offset of 1 produces 00309 /// a source location pointing to the last character in the token, etc. 00310 static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, 00311 const SourceManager &SM, 00312 const LangOptions &LangOpts); 00313 00314 /// \brief Returns true if the given MacroID location points at the first 00315 /// token of the macro expansion. 00316 /// 00317 /// \param MacroBegin If non-null and function returns true, it is set to 00318 /// begin location of the macro. 00319 static bool isAtStartOfMacroExpansion(SourceLocation loc, 00320 const SourceManager &SM, 00321 const LangOptions &LangOpts, 00322 SourceLocation *MacroBegin = 0); 00323 00324 /// \brief Returns true if the given MacroID location points at the last 00325 /// token of the macro expansion. 00326 /// 00327 /// \param MacroBegin If non-null and function returns true, it is set to 00328 /// end location of the macro. 00329 static bool isAtEndOfMacroExpansion(SourceLocation loc, 00330 const SourceManager &SM, 00331 const LangOptions &LangOpts, 00332 SourceLocation *MacroEnd = 0); 00333 00334 /// \brief Accepts a range and returns a character range with file locations. 00335 /// 00336 /// Returns a null range if a part of the range resides inside a macro 00337 /// expansion or the range does not reside on the same FileID. 00338 /// 00339 /// This function is trying to deal with macros and return a range based on 00340 /// file locations. The cases where it can successfully handle macros are: 00341 /// 00342 /// -begin or end range lies at the start or end of a macro expansion, in 00343 /// which case the location will be set to the expansion point, e.g: 00344 /// #define M 1 2 00345 /// a M 00346 /// If you have a range [a, 2] (where 2 came from the macro), the function 00347 /// will return a range for "a M" 00348 /// if you have range [a, 1], the function will fail because the range 00349 /// overlaps with only a part of the macro 00350 /// 00351 /// -The macro is a function macro and the range can be mapped to the macro 00352 /// arguments, e.g: 00353 /// #define M 1 2 00354 /// #define FM(x) x 00355 /// FM(a b M) 00356 /// if you have range [b, 2], the function will return the file range "b M" 00357 /// inside the macro arguments. 00358 /// if you have range [a, 2], the function will return the file range 00359 /// "FM(a b M)" since the range includes all of the macro expansion. 00360 static CharSourceRange makeFileCharRange(CharSourceRange Range, 00361 const SourceManager &SM, 00362 const LangOptions &LangOpts); 00363 00364 /// \brief Returns a string for the source that the range encompasses. 00365 static StringRef getSourceText(CharSourceRange Range, 00366 const SourceManager &SM, 00367 const LangOptions &LangOpts, 00368 bool *Invalid = 0); 00369 00370 /// \brief Retrieve the name of the immediate macro expansion. 00371 /// 00372 /// This routine starts from a source location, and finds the name of the macro 00373 /// responsible for its immediate expansion. It looks through any intervening 00374 /// macro argument expansions to compute this. It returns a StringRef which 00375 /// refers to the SourceManager-owned buffer of the source where that macro 00376 /// name is spelled. Thus, the result shouldn't out-live that SourceManager. 00377 static StringRef getImmediateMacroName(SourceLocation Loc, 00378 const SourceManager &SM, 00379 const LangOptions &LangOpts); 00380 00381 /// \brief Compute the preamble of the given file. 00382 /// 00383 /// The preamble of a file contains the initial comments, include directives, 00384 /// and other preprocessor directives that occur before the code in this 00385 /// particular file actually begins. The preamble of the main source file is 00386 /// a potential prefix header. 00387 /// 00388 /// \param Buffer The memory buffer containing the file's contents. 00389 /// 00390 /// \param MaxLines If non-zero, restrict the length of the preamble 00391 /// to fewer than this number of lines. 00392 /// 00393 /// \returns The offset into the file where the preamble ends and the rest 00394 /// of the file begins along with a boolean value indicating whether 00395 /// the preamble ends at the beginning of a new line. 00396 static std::pair<unsigned, bool> 00397 ComputePreamble(const llvm::MemoryBuffer *Buffer, const LangOptions &LangOpts, 00398 unsigned MaxLines = 0); 00399 00400 //===--------------------------------------------------------------------===// 00401 // Internal implementation interfaces. 00402 private: 00403 00404 /// LexTokenInternal - Internal interface to lex a preprocessing token. Called 00405 /// by Lex. 00406 /// 00407 void LexTokenInternal(Token &Result); 00408 00409 /// FormTokenWithChars - When we lex a token, we have identified a span 00410 /// starting at BufferPtr, going to TokEnd that forms the token. This method 00411 /// takes that range and assigns it to the token as its location and size. In 00412 /// addition, since tokens cannot overlap, this also updates BufferPtr to be 00413 /// TokEnd. 00414 void FormTokenWithChars(Token &Result, const char *TokEnd, 00415 tok::TokenKind Kind) { 00416 unsigned TokLen = TokEnd-BufferPtr; 00417 Result.setLength(TokLen); 00418 Result.setLocation(getSourceLocation(BufferPtr, TokLen)); 00419 Result.setKind(Kind); 00420 BufferPtr = TokEnd; 00421 } 00422 00423 /// isNextPPTokenLParen - Return 1 if the next unexpanded token will return a 00424 /// tok::l_paren token, 0 if it is something else and 2 if there are no more 00425 /// tokens in the buffer controlled by this lexer. 00426 unsigned isNextPPTokenLParen(); 00427 00428 //===--------------------------------------------------------------------===// 00429 // Lexer character reading interfaces. 00430 public: 00431 00432 // This lexer is built on two interfaces for reading characters, both of which 00433 // automatically provide phase 1/2 translation. getAndAdvanceChar is used 00434 // when we know that we will be reading a character from the input buffer and 00435 // that this character will be part of the result token. This occurs in (f.e.) 00436 // string processing, because we know we need to read until we find the 00437 // closing '"' character. 00438 // 00439 // The second interface is the combination of getCharAndSize with 00440 // ConsumeChar. getCharAndSize reads a phase 1/2 translated character, 00441 // returning it and its size. If the lexer decides that this character is 00442 // part of the current token, it calls ConsumeChar on it. This two stage 00443 // approach allows us to emit diagnostics for characters (e.g. warnings about 00444 // trigraphs), knowing that they only are emitted if the character is 00445 // consumed. 00446 00447 /// isObviouslySimpleCharacter - Return true if the specified character is 00448 /// obviously the same in translation phase 1 and translation phase 3. This 00449 /// can return false for characters that end up being the same, but it will 00450 /// never return true for something that needs to be mapped. 00451 static bool isObviouslySimpleCharacter(char C) { 00452 return C != '?' && C != '\\'; 00453 } 00454 00455 /// getAndAdvanceChar - Read a single 'character' from the specified buffer, 00456 /// advance over it, and return it. This is tricky in several cases. Here we 00457 /// just handle the trivial case and fall-back to the non-inlined 00458 /// getCharAndSizeSlow method to handle the hard case. 00459 inline char getAndAdvanceChar(const char *&Ptr, Token &Tok) { 00460 // If this is not a trigraph and not a UCN or escaped newline, return 00461 // quickly. 00462 if (isObviouslySimpleCharacter(Ptr[0])) return *Ptr++; 00463 00464 unsigned Size = 0; 00465 char C = getCharAndSizeSlow(Ptr, Size, &Tok); 00466 Ptr += Size; 00467 return C; 00468 } 00469 00470 private: 00471 /// ConsumeChar - When a character (identified by getCharAndSize) is consumed 00472 /// and added to a given token, check to see if there are diagnostics that 00473 /// need to be emitted or flags that need to be set on the token. If so, do 00474 /// it. 00475 const char *ConsumeChar(const char *Ptr, unsigned Size, Token &Tok) { 00476 // Normal case, we consumed exactly one token. Just return it. 00477 if (Size == 1) 00478 return Ptr+Size; 00479 00480 // Otherwise, re-lex the character with a current token, allowing 00481 // diagnostics to be emitted and flags to be set. 00482 Size = 0; 00483 getCharAndSizeSlow(Ptr, Size, &Tok); 00484 return Ptr+Size; 00485 } 00486 00487 /// getCharAndSize - Peek a single 'character' from the specified buffer, 00488 /// get its size, and return it. This is tricky in several cases. Here we 00489 /// just handle the trivial case and fall-back to the non-inlined 00490 /// getCharAndSizeSlow method to handle the hard case. 00491 inline char getCharAndSize(const char *Ptr, unsigned &Size) { 00492 // If this is not a trigraph and not a UCN or escaped newline, return 00493 // quickly. 00494 if (isObviouslySimpleCharacter(Ptr[0])) { 00495 Size = 1; 00496 return *Ptr; 00497 } 00498 00499 Size = 0; 00500 return getCharAndSizeSlow(Ptr, Size); 00501 } 00502 00503 /// getCharAndSizeSlow - Handle the slow/uncommon case of the getCharAndSize 00504 /// method. 00505 char getCharAndSizeSlow(const char *Ptr, unsigned &Size, Token *Tok = 0); 00506 public: 00507 00508 /// getCharAndSizeNoWarn - Like the getCharAndSize method, but does not ever 00509 /// emit a warning. 00510 static inline char getCharAndSizeNoWarn(const char *Ptr, unsigned &Size, 00511 const LangOptions &LangOpts) { 00512 // If this is not a trigraph and not a UCN or escaped newline, return 00513 // quickly. 00514 if (isObviouslySimpleCharacter(Ptr[0])) { 00515 Size = 1; 00516 return *Ptr; 00517 } 00518 00519 Size = 0; 00520 return getCharAndSizeSlowNoWarn(Ptr, Size, LangOpts); 00521 } 00522 00523 /// getEscapedNewLineSize - Return the size of the specified escaped newline, 00524 /// or 0 if it is not an escaped newline. P[-1] is known to be a "\" on entry 00525 /// to this function. 00526 static unsigned getEscapedNewLineSize(const char *P); 00527 00528 /// SkipEscapedNewLines - If P points to an escaped newline (or a series of 00529 /// them), skip over them and return the first non-escaped-newline found, 00530 /// otherwise return P. 00531 static const char *SkipEscapedNewLines(const char *P); 00532 00533 /// \brief Checks that the given token is the first token that occurs after 00534 /// the given location (this excludes comments and whitespace). Returns the 00535 /// location immediately after the specified token. If the token is not found 00536 /// or the location is inside a macro, the returned source location will be 00537 /// invalid. 00538 static SourceLocation findLocationAfterToken(SourceLocation loc, 00539 tok::TokenKind TKind, 00540 const SourceManager &SM, 00541 const LangOptions &LangOpts, 00542 bool SkipTrailingWhitespaceAndNewLine); 00543 00544 private: 00545 00546 /// getCharAndSizeSlowNoWarn - Same as getCharAndSizeSlow, but never emits a 00547 /// diagnostic. 00548 static char getCharAndSizeSlowNoWarn(const char *Ptr, unsigned &Size, 00549 const LangOptions &LangOpts); 00550 00551 //===--------------------------------------------------------------------===// 00552 // Other lexer functions. 00553 00554 void SkipBytes(unsigned Bytes, bool StartOfLine); 00555 00556 const char *LexUDSuffix(Token &Result, const char *CurPtr); 00557 00558 // Helper functions to lex the remainder of a token of the specific type. 00559 void LexIdentifier (Token &Result, const char *CurPtr); 00560 void LexNumericConstant (Token &Result, const char *CurPtr); 00561 void LexStringLiteral (Token &Result, const char *CurPtr, 00562 tok::TokenKind Kind); 00563 void LexRawStringLiteral (Token &Result, const char *CurPtr, 00564 tok::TokenKind Kind); 00565 void LexAngledStringLiteral(Token &Result, const char *CurPtr); 00566 void LexCharConstant (Token &Result, const char *CurPtr, 00567 tok::TokenKind Kind); 00568 bool LexEndOfFile (Token &Result, const char *CurPtr); 00569 00570 bool SkipWhitespace (Token &Result, const char *CurPtr); 00571 bool SkipBCPLComment (Token &Result, const char *CurPtr); 00572 bool SkipBlockComment (Token &Result, const char *CurPtr); 00573 bool SaveBCPLComment (Token &Result, const char *CurPtr); 00574 00575 bool IsStartOfConflictMarker(const char *CurPtr); 00576 bool HandleEndOfConflictMarker(const char *CurPtr); 00577 00578 bool isCodeCompletionPoint(const char *CurPtr) const; 00579 void cutOffLexing() { BufferPtr = BufferEnd; } 00580 }; 00581 00582 00583 } // end namespace clang 00584 00585 #endif