clang API Documentation
#include "clang/Lex/Lexer.h"
#include "UnicodeCharSets.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/CodeCompletionHandler.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Lex/LiteralSupport.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/MemoryBuffer.h"
#include <cstring>
Go to the source code of this file.
Enumerations | |
enum | PreambleDirectiveKind |
Functions | |
static size_t | getSpellingSlow (const Token &Tok, const char *BufPtr, const LangOptions &LangOpts, char *Spelling) |
Slow case of getSpelling. Extract the characters comprising the spelling of this token from the provided input buffer. | |
static SourceLocation | getBeginningOfFileToken (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts) |
static CharSourceRange | makeRangeFromFileLocs (CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts) |
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 | isAllowedIDChar (uint32_t C, const LangOptions &LangOpts) |
static bool | isAllowedInitiallyIDChar (uint32_t C, const LangOptions &LangOpts) |
static CharSourceRange | makeCharRange (Lexer &L, const char *Begin, const char *End) |
static void | maybeDiagnoseIDCharCompat (DiagnosticsEngine &Diags, uint32_t C, CharSourceRange Range, bool IsFirst) |
static bool | isEndOfBlockCommentWithEscapedNewLine (const char *CurPtr, Lexer *L) |
static const char * | FindConflictEnd (const char *CurPtr, const char *BufferEnd, ConflictMarkerKind CMK) |
Find the end of a version control conflict marker. |
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 1097 of file Lexer.cpp.
References clang::Lexer::Diag(), clang::Lexer::getLangOpts(), GetTrigraphCharForLetter(), and clang::PreprocessorLexer::isLexingRawMode().
static const char* FindConflictEnd | ( | const char * | CurPtr, |
const char * | BufferEnd, | ||
ConflictMarkerKind | CMK | ||
) | [static] |
Find the end of a version control conflict marker.
Definition at line 2583 of file Lexer.cpp.
References clang::CMK_Perforce.
static SourceLocation getBeginningOfFileToken | ( | SourceLocation | Loc, |
const SourceManager & | SM, | ||
const LangOptions & | LangOpts | ||
) | [static] |
Definition at line 455 of file Lexer.cpp.
References clang::comments::tok::eof, 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 1024 of file Lexer.cpp.
References clang::SourceLocation::getLocWithOffset(), clang::Preprocessor::getSourceManager(), clang::SourceLocation::isMacroID(), and SM.
Referenced by clang::Lexer::getSourceLocation().
static size_t getSpellingSlow | ( | const Token & | Tok, |
const char * | BufPtr, | ||
const LangOptions & | LangOpts, | ||
char * | Spelling | ||
) | [static] |
Slow case of getSpelling. Extract the characters comprising the spelling of this token from the provided input buffer.
Definition at line 237 of file Lexer.cpp.
References clang::Lexer::getCharAndSizeNoWarn(), clang::Token::getLength(), clang::Token::is(), and clang::Token::needsCleaning().
Referenced by clang::Lexer::getSpelling().
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 1078 of file Lexer.cpp.
Referenced by DecodeTrigraphChar().
static bool isAllowedIDChar | ( | uint32_t | C, |
const LangOptions & | LangOpts | ||
) | [static] |
Definition at line 1362 of file Lexer.cpp.
References C11AllowedIDCharRanges, C99AllowedIDCharRanges, and CXX03AllowedIDCharRanges.
Referenced by isAllowedInitiallyIDChar().
static bool isAllowedInitiallyIDChar | ( | uint32_t | C, |
const LangOptions & | LangOpts | ||
) | [static] |
Definition at line 1378 of file Lexer.cpp.
References C11DisallowedInitialIDCharRanges, C99DisallowedInitialIDCharRanges, and isAllowedIDChar().
static bool isEndOfBlockCommentWithEscapedNewLine | ( | const char * | CurPtr, |
Lexer * | L | ||
) | [static] |
isBlockCommentEndOfEscapedNewLine - Return true if the specified newline character (either \n or \r) 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 2184 of file Lexer.cpp.
References clang::Lexer::Diag(), clang::Lexer::getLangOpts(), clang::isHorizontalWhitespace(), and clang::PreprocessorLexer::isLexingRawMode().
static CharSourceRange makeCharRange | ( | Lexer & | L, |
const char * | Begin, | ||
const char * | End | ||
) | [inline, static] |
Definition at line 1393 of file Lexer.cpp.
References clang::CharSourceRange::getCharRange(), and clang::Lexer::getSourceLocation().
static CharSourceRange makeRangeFromFileLocs | ( | CharSourceRange | Range, |
const SourceManager & | SM, | ||
const LangOptions & | LangOpts | ||
) | [static] |
Definition at line 835 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().
static void maybeDiagnoseIDCharCompat | ( | DiagnosticsEngine & | Diags, |
uint32_t | C, | ||
CharSourceRange | Range, | ||
bool | IsFirst | ||
) | [static] |
Definition at line 1399 of file Lexer.cpp.
References C99AllowedIDCharRanges, C99DisallowedInitialIDCharRanges, CXX03AllowedIDCharRanges, clang::CharSourceRange::getBegin(), clang::DiagnosticsEngine::isIgnored(), and clang::DiagnosticsEngine::Report().