clang  6.0.0svn
Enumerations | Functions
Lexer.cpp File Reference
#include "clang/Lex/Lexer.h"
#include "UnicodeCharSets.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Lex/LiteralSupport.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/UnicodeCharRanges.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
#include <tuple>
#include <utility>
Include dependency graph for Lexer.cpp:

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. More...
 
static const char * findBeginningOfLine (StringRef Buffer, unsigned Offset)
 Returns the pointer that points to the beginning of line that contains the given offset, or null if the offset if invalid. More...
 
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)
 GetMappedTokenLoc - If lexing out of a 'mapped buffer', where we pretend the lexer buffer was all expanded at a single point, perform the mapping. More...
 
static char GetTrigraphCharForLetter (char Letter)
 GetTrigraphCharForLetter - Given a character that occurs after a ?? pair, return the decoded trigraph letter it corresponds to, or '\0' if nothing. More...
 
static char DecodeTrigraphChar (const char *CP, Lexer *L)
 DecodeTrigraphChar - If the specified character is a legal trigraph when prefixed with ??, emit a trigraph warning. More...
 
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)
 isBlockCommentEndOfEscapedNewLine - Return true if the specified newline character (either \n or \r) is part of an escaped newline sequence. More...
 
static const char * FindConflictEnd (const char *CurPtr, const char *BufferEnd, ConflictMarkerKind CMK)
 Find the end of a version control conflict marker. More...
 
static const char * findPlaceholderEnd (const char *CurPtr, const char *BufferEnd)
 

Enumeration Type Documentation

◆ PreambleDirectiveKind

Definition at line 548 of file Lexer.cpp.

Function Documentation

◆ DecodeTrigraphChar()

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 1152 of file Lexer.cpp.

References clang::Lexer::Diag(), clang::Lexer::getLangOpts(), GetTrigraphCharForLetter(), clang::PreprocessorLexer::isLexingRawMode(), clang::isWhitespace(), and P.

Referenced by clang::Lexer::findLocationAfterToken().

◆ findBeginningOfLine()

static const char* findBeginningOfLine ( StringRef  Buffer,
unsigned  Offset 
)
static

Returns the pointer that points to the beginning of line that contains the given offset, or null if the offset if invalid.

Definition at line 462 of file Lexer.cpp.

◆ FindConflictEnd()

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 2650 of file Lexer.cpp.

References clang::CMK_None, clang::CMK_Normal, clang::CMK_Perforce, clang::Lexer::Diag(), End, and clang::PreprocessorLexer::isLexingRawMode().

◆ findPlaceholderEnd()

static const char* findPlaceholderEnd ( const char *  CurPtr,
const char *  BufferEnd 
)
static

Definition at line 2754 of file Lexer.cpp.

References clang::frontend::After, clang::C, clang::Token::clearFlag(), clang::FixItHint::CreateRemoval(), clang::FixItHint::CreateReplacement(), clang::Lexer::Diag(), End, clang::Preprocessor::getCodeCompletionLoc(), clang::Preprocessor::getDiagnostics(), clang::SourceLocation::getLocWithOffset(), clang::Preprocessor::getPreprocessorOpts(), clang::Token::hasLeadingEmptyMacro(), clang::Token::hasLeadingSpace(), clang::Token::HasUCN, clang::Lexer::inKeepCommentMode(), isAllowedIDChar(), isAllowedInitiallyIDChar(), clang::isASCII(), clang::Token::isAtStartOfLine(), clang::Preprocessor::isCodeCompletionEnabled(), clang::Token::IsEditorPlaceholder, clang::isHorizontalWhitespace(), clang::Lexer::isKeepWhitespaceMode(), clang::PreprocessorLexer::isLexingRawMode(), clang::Preprocessor::isPreprocessedOutput(), clang::Token::LeadingEmptyMacro, clang::Token::LeadingSpace, clang::PreprocessorOptions::LexEditorPlaceholders, clang::PreprocessorLexer::LexingRawMode, clang::Preprocessor::LookUpIdentifierInfo(), makeCharRange(), maybeDiagnoseIDCharCompat(), clang::PreprocessorLexer::MIOpt, clang::Token::NeedsCleaning, clang::PreprocessorLexer::ParsingFilename, clang::PreprocessorLexer::ParsingPreprocessorDirective, clang::MultipleIncludeOpt::ReadToken(), clang::Lexer::resetExtendedTokenMode(), clang::Token::setFlag(), clang::Token::setIdentifierInfo(), clang::Token::setRawIdentifierData(), clang::Token::StartOfLine, clang::Token::startToken(), and UnicodeWhitespaceCharRanges.

◆ getBeginningOfFileToken()

static SourceLocation getBeginningOfFileToken ( SourceLocation  Loc,
const SourceManager SM,
const LangOptions LangOpts 
)
static

◆ GetMappedTokenLoc()

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 1079 of file Lexer.cpp.

References clang::SourceLocation::getLocWithOffset(), clang::Preprocessor::getSourceManager(), clang::SourceLocation::isMacroID(), and SM.

Referenced by clang::Lexer::getSourceLocation().

◆ getSpellingSlow()

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 243 of file Lexer.cpp.

References clang::Token::needsCleaning().

Referenced by clang::Lexer::getSpelling().

◆ GetTrigraphCharForLetter()

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 1133 of file Lexer.cpp.

Referenced by DecodeTrigraphChar(), and clang::Lexer::findLocationAfterToken().

◆ isAllowedIDChar()

static bool isAllowedIDChar ( uint32_t  C,
const LangOptions LangOpts 
)
static

◆ isAllowedInitiallyIDChar()

static bool isAllowedInitiallyIDChar ( uint32_t  C,
const LangOptions LangOpts 
)
static

◆ isEndOfBlockCommentWithEscapedNewLine()

static bool isEndOfBlockCommentWithEscapedNewLine ( const char *  CurPtr,
Lexer L 
)
static

◆ makeCharRange()

static CharSourceRange makeCharRange ( Lexer L,
const char *  Begin,
const char *  End 
)
inlinestatic

◆ makeRangeFromFileLocs()

static CharSourceRange makeRangeFromFileLocs ( CharSourceRange  Range,
const SourceManager SM,
const LangOptions LangOpts 
)
static

◆ maybeDiagnoseIDCharCompat()

static void maybeDiagnoseIDCharCompat ( DiagnosticsEngine Diags,
uint32_t  C,
CharSourceRange  Range,
bool  IsFirst 
)
static