clang API Documentation
#include "clang/Lex/Lexer.h"#include "clang/Lex/Preprocessor.h"#include "clang/Lex/LexDiagnostic.h"#include "clang/Lex/CodeCompletionHandler.h"#include "clang/Basic/SourceManager.h"#include "llvm/ADT/StringSwitch.h"#include "llvm/ADT/STLExtras.h"#include "llvm/Support/Compiler.h"#include "llvm/Support/MemoryBuffer.h"#include <cstring>
Go to the source code of this file.
Enumerations | |
| enum | PreambleDirectiveKind |
| enum | { CHAR_HORZ_WS = 0x01, CHAR_VERT_WS = 0x02, CHAR_LETTER = 0x04, CHAR_NUMBER = 0x08, CHAR_UNDER = 0x10, CHAR_PERIOD = 0x20, CHAR_RAWDEL = 0x40 } |
Functions | |
| static void | InitCharacterInfo () |
| static bool | isWhitespace (unsigned char c) |
| static SourceLocation | getBeginningOfFileToken (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts) |
| static CharSourceRange | makeRangeFromFileLocs (CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts) |
| static bool | isIdentifierBody (unsigned char c) |
| static bool | isHorizontalWhitespace (unsigned char c) |
| static bool | isVerticalWhitespace (unsigned char c) |
| static bool | isNumberBody (unsigned char c) |
| static bool | isRawStringDelimBody (unsigned char c) |
| static LLVM_ATTRIBUTE_NOINLINE SourceLocation | GetMappedTokenLoc (Preprocessor &PP, SourceLocation FileLoc, unsigned CharNo, unsigned TokLen) |
| static char | GetTrigraphCharForLetter (char Letter) |
| static char | DecodeTrigraphChar (const char *CP, Lexer *L) |
| static bool | isHexaLiteral (const char *Start, const LangOptions &Features) |
| static bool | isEndOfBlockCommentWithEscapedNewLine (const char *CurPtr, Lexer *L) |
| static const char * | FindConflictEnd (const char *CurPtr, const char *BufferEnd, ConflictMarkerKind CMK) |
| FindConflictEnd - Find the end of a version control conflict marker. | |
Variables | |
| static const unsigned char | CharInfo [256] |
| characters that terminate the comment Note that we don t bother decoding trigraphs or escaped newlines in block | comments |
| characters that terminate the comment Note that we don t bother decoding trigraphs or escaped newlines in block because they cannot cause the comment to end The only thing that can happen is the comment could end with an escaped newline between the *end of comment If we re in KeepCommentMode or any CommentHandler has inserted some | tokens |
| anonymous enum |
| static char DecodeTrigraphChar | ( | const char * | CP, |
| Lexer * | L | ||
| ) | [static] |
DecodeTrigraphChar - If the specified character is a legal trigraph when prefixed with ??, emit a trigraph warning. If trigraphs are enabled, return the result character. Finally, emit a warning about trigraph use whether trigraphs are enabled or not.
Definition at line 1205 of file Lexer.cpp.
References clang::Lexer::Diag(), clang::Lexer::getFeatures(), GetTrigraphCharForLetter(), and clang::PreprocessorLexer::isLexingRawMode().
| static const char* FindConflictEnd | ( | const char * | CurPtr, |
| const char * | BufferEnd, | ||
| ConflictMarkerKind | CMK | ||
| ) | [static] |
FindConflictEnd - Find the end of a version control conflict marker.
Definition at line 2363 of file Lexer.cpp.
References clang::CMK_Perforce.
| static SourceLocation getBeginningOfFileToken | ( | SourceLocation | Loc, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts | ||
| ) | [static] |
Definition at line 421 of file Lexer.cpp.
References clang::SourceManager::getBufferData(), clang::SourceManager::getDecomposedLoc(), clang::Token::getKind(), clang::Token::getLength(), clang::Token::getLocation(), clang::SourceLocation::getLocWithOffset(), clang::SourceLocation::isFileID(), and clang::Lexer::SetCommentRetentionState().
Referenced by clang::Lexer::GetBeginningOfToken().
| static SourceLocation GetMappedTokenLoc | ( | Preprocessor & | PP, |
| SourceLocation | FileLoc, | ||
| unsigned | CharNo, | ||
| unsigned | TokLen | ||
| ) | [static] |
GetMappedTokenLoc - If lexing out of a 'mapped buffer', where we pretend the lexer buffer was all expanded at a single point, perform the mapping. This is currently only used for _Pragma implementation, so it is the slow path of the hot getSourceLocation method. Do not allow it to be inlined.
Definition at line 1132 of file Lexer.cpp.
References clang::SourceLocation::getLocWithOffset(), clang::Preprocessor::getSourceManager(), and clang::SourceLocation::isMacroID().
Referenced by clang::Lexer::getSourceLocation().
| static char GetTrigraphCharForLetter | ( | char | Letter | ) | [static] |
GetTrigraphCharForLetter - Given a character that occurs after a ?? pair, return the decoded trigraph letter it corresponds to, or '\0' if nothing.
Definition at line 1186 of file Lexer.cpp.
Referenced by DecodeTrigraphChar().
| static void InitCharacterInfo | ( | ) | [static] |
Definition at line 1058 of file Lexer.cpp.
References CHAR_HORZ_WS, CHAR_LETTER, CHAR_NUMBER, CHAR_PERIOD, CHAR_UNDER, CHAR_VERT_WS, and CharInfo.
| static bool isEndOfBlockCommentWithEscapedNewLine | ( | const char * | CurPtr, |
| Lexer * | L | ||
| ) | [static] |
isBlockCommentEndOfEscapedNewLine - Return true if the specified newline character (either
or ) is part of an escaped newline sequence. Issue a diagnostic if so. We know that the newline is inside of a block comment.
Definition at line 1990 of file Lexer.cpp.
References clang::Lexer::Diag(), clang::Lexer::getFeatures(), isHorizontalWhitespace(), and clang::PreprocessorLexer::isLexingRawMode().
| static bool isHexaLiteral | ( | const char * | Start, |
| const LangOptions & | Features | ||
| ) | [static] |
isHexaLiteral - Return true if Start points to a hex constant. in microsoft mode (where this is supposed to be several different tokens).
Definition at line 1530 of file Lexer.cpp.
References clang::Lexer::getCharAndSizeNoWarn().
| static bool isHorizontalWhitespace | ( | unsigned char | c | ) | [inline, static] |
isHorizontalWhitespace - Return true if this character is horizontal whitespace: ' ', '', '', ''. Note that this returns false for '\0'.
Definition at line 1089 of file Lexer.cpp.
References CHAR_HORZ_WS, and CharInfo.
Referenced by clang::Lexer::findLocationAfterToken(), and isEndOfBlockCommentWithEscapedNewLine().
| static bool isIdentifierBody | ( | unsigned char | c | ) | [inline, static] |
isIdentifierBody - Return true if this is the body character of an identifier, which is [a-zA-Z0-9_].
Definition at line 1083 of file Lexer.cpp.
References CHAR_LETTER, CHAR_NUMBER, CHAR_UNDER, and CharInfo.
| static bool isNumberBody | ( | unsigned char | c | ) | [inline, static] |
isNumberBody - Return true if this is the body character of an preprocessing number, which is [a-zA-Z0-9_.].
Definition at line 1108 of file Lexer.cpp.
References CHAR_LETTER, CHAR_NUMBER, CHAR_PERIOD, CHAR_UNDER, and CharInfo.
| static bool isRawStringDelimBody | ( | unsigned char | c | ) | [inline, static] |
isRawStringDelimBody - Return true if this is the body character of a raw string delimiter.
Definition at line 1115 of file Lexer.cpp.
References CHAR_LETTER, CHAR_NUMBER, CHAR_PERIOD, CHAR_RAWDEL, CHAR_UNDER, and CharInfo.
| static bool isVerticalWhitespace | ( | unsigned char | c | ) | [inline, static] |
isVerticalWhitespace - Return true if this character is vertical whitespace: '
', ''. Note that this returns false for '\0'.
Definition at line 1095 of file Lexer.cpp.
References CHAR_VERT_WS, and CharInfo.
Referenced by clang::Lexer::findLocationAfterToken().
| static bool isWhitespace | ( | unsigned char | c | ) | [inline, static] |
isWhitespace - Return true if this character is horizontal or vertical whitespace: ' ', '', '', '', '
', ''. Note that this returns false for '\0'.
Definition at line 1102 of file Lexer.cpp.
References CHAR_HORZ_WS, CHAR_VERT_WS, and CharInfo.
Referenced by clang::Lexer::getEscapedNewLineSize(), and clang::Lexer::MeasureTokenLength().
| static CharSourceRange makeRangeFromFileLocs | ( | CharSourceRange | Range, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts | ||
| ) | [static] |
Definition at line 796 of file Lexer.cpp.
References clang::CharSourceRange::getBegin(), clang::CharSourceRange::getCharRange(), clang::SourceManager::getDecomposedLoc(), clang::CharSourceRange::getEnd(), clang::Lexer::getLocForEndOfToken(), clang::SourceLocation::isFileID(), clang::SourceManager::isInFileID(), clang::FileID::isInvalid(), clang::SourceLocation::isInvalid(), and clang::CharSourceRange::isTokenRange().
Referenced by clang::Lexer::makeFileCharRange().
const unsigned char CharInfo[256] [static] |
Definition at line 990 of file Lexer.cpp.
Referenced by InitCharacterInfo(), isHorizontalWhitespace(), isIdentifierBody(), isNumberBody(), isRawStringDelimBody(), isVerticalWhitespace(), and isWhitespace().
| characters that terminate the comment Note that we don t bother decoding trigraphs or escaped newlines in block comments |
| characters that terminate the comment Note that we don t bother decoding trigraphs or escaped newlines in block because they cannot cause the comment to end The only thing that can happen is the comment could end with an escaped newline between the* end of comment If we re in KeepCommentMode or any CommentHandler has inserted some tokens |