class Preprocessor

Declaration

class Preprocessor { /* full declaration omitted */ };

Description

Engages in a tight little dance with the lexer to efficiently preprocess tokens. Lexers know only about tokens within a single source file, and don't know anything about preprocessor-level issues like the # include stack, token expansion, etc.

Declared at: clang/include/clang/Lex/Preprocessor.h:129

Member Variables

private llvm::unique_function<void(const clang::Token&)> OnToken
private std::shared_ptr<PreprocessorOptions> PPOpts
private clang::DiagnosticsEngine* Diags
private clang::LangOptions& LangOpts
private const clang::TargetInfo* Target = nullptr
private const clang::TargetInfo* AuxTarget = nullptr
private clang::FileManager& FileMgr
private clang::SourceManager& SourceMgr
private std::unique_ptr<ScratchBuffer> ScratchBuf
private clang::HeaderSearch& HeaderInfo
private clang::ModuleLoader& TheModuleLoader
private clang::ExternalPreprocessorSource* ExternalSource
External source of macros.
private llvm::BumpPtrAllocator BP
A BumpPtrAllocator object used to quickly allocate and release objects internal to the Preprocessor.
private clang::IdentifierInfo* Ident__LINE__
Identifiers for builtin macros and other builtins.
private clang::IdentifierInfo* Ident__FILE__
Identifiers for builtin macros and other builtins.
private clang::IdentifierInfo* Ident__DATE__
private clang::IdentifierInfo* Ident__TIME__
private clang::IdentifierInfo* Ident__INCLUDE_LEVEL__
private clang::IdentifierInfo* Ident__BASE_FILE__
private clang::IdentifierInfo* Ident__FILE_NAME__
private clang::IdentifierInfo* Ident__TIMESTAMP__
private clang::IdentifierInfo* Ident__COUNTER__
private clang::IdentifierInfo* Ident_Pragma
private clang::IdentifierInfo* Ident__pragma
private clang::IdentifierInfo* Ident__identifier
private clang::IdentifierInfo* Ident__VA_ARGS__
private clang::IdentifierInfo* Ident__VA_OPT__
private clang::IdentifierInfo* Ident__has_feature
private clang::IdentifierInfo* Ident__has_extension
private clang::IdentifierInfo* Ident__has_builtin
private clang::IdentifierInfo* Ident__has_attribute
private clang::IdentifierInfo* Ident__has_include
private clang::IdentifierInfo* Ident__has_include_next
private clang::IdentifierInfo* Ident__has_warning
private clang::IdentifierInfo* Ident__is_identifier
private clang::IdentifierInfo* Ident__building_module
private clang::IdentifierInfo* Ident__MODULE__
private clang::IdentifierInfo* Ident__has_cpp_attribute
private clang::IdentifierInfo* Ident__has_c_attribute
private clang::IdentifierInfo* Ident__has_declspec
private clang::IdentifierInfo* Ident__is_target_arch
private clang::IdentifierInfo* Ident__is_target_vendor
private clang::IdentifierInfo* Ident__is_target_os
private clang::IdentifierInfo* Ident__is_target_environment
private clang::IdentifierInfo* Ident__is_target_variant_os
private clang::IdentifierInfo* Ident__is_target_variant_environment
private clang::IdentifierInfo* Ident__FLT_EVAL_METHOD__
private clang::Token* ArgMacro
private clang::SourceLocation DATELoc
private clang::SourceLocation TIMELoc
private LangOptions::FPEvalMethodKind CurrentFPEvalMethod = LangOptions::FPEvalMethodKind::FEM_UnsetOnCommandLine
private LangOptions::FPEvalMethodKind LastFPEvalMethod = LangOptions::FPEvalMethodKind::FEM_UnsetOnCommandLine
private clang::SourceLocation LastFPEvalPragmaLocation
private LangOptions::FPEvalMethodKind TUFPEvalMethod = LangOptions::FPEvalMethodKind::FEM_UnsetOnCommandLine
private unsigned int CounterValue = 0
private bool KeepComments
private bool KeepMacroComments
private bool SuppressIncludeNotFoundError
private bool InMacroArgs
private bool OwnsHeaderSearch
Whether the preprocessor owns the header search object.
private bool DisableMacroExpansion
True if macro expansion is disabled.
private bool MacroExpansionInDirectivesOverride
Temporarily disables DisableMacroExpansion (i.e. enables expansion) when parsing preprocessor directives.
private bool ReadMacrosFromExternalSource
Whether we have already loaded macros from the external source.
private bool PragmasEnabled
True if pragmas are enabled.
private bool PreprocessedOutput
True if the current build action is a preprocessing action.
private bool ParsingIfOrElifDirective
True if we are currently preprocessing a #if or #elif directive
private bool InMacroArgPreExpansion
True if we are pre-expanding macro arguments.
private clang::IdentifierTable Identifiers
Mapping/lookup information for all identifiers in the program, including program keywords.
private clang::SelectorTable Selectors
FIXME: Make sure the lifetime of Identifiers/Selectors *isn't* tied to the lifetime of the preprocessor.
private std::unique_ptr<Builtin::Context> BuiltinInfo
Information about builtins.
private std::unique_ptr<PragmaNamespace> PragmaHandlers
Tracks all of the pragmas that the client registered with this preprocessor.
private std::unique_ptr<PragmaNamespace> PragmaHandlersBackup
Pragma handlers of the original source is stored here during the parsing of a model file.
private std::vector<CommentHandler*> CommentHandlers
Tracks all of the comment handlers that the client registered with this preprocessor.
private clang::EmptylineHandler* Emptyline = nullptr
Empty line handler.
private bool IncrementalProcessing = false
True if we want to ignore EOF token and continue later on (thus avoid tearing the Lexer and etc. down).
public const clang::TranslationUnitKind TUKind
The kind of translation unit we are processing.
private clang::CodeCompletionHandler* CodeComplete = nullptr
The code-completion handler.
private const clang::FileEntry* CodeCompletionFile = nullptr
The file that we're performing code-completion for, if any.
private unsigned int CodeCompletionOffset = 0
The offset in file for the code-completion point.
private clang::SourceLocation CodeCompletionLoc
The location for the code-completion point. This gets instantiated when the CodeCompletionFile gets # include'ed for preprocessing.
private clang::SourceLocation CodeCompletionFileLoc
This gets instantiated when the CodeCompletionFile gets # include'ed for preprocessing.
private clang::SourceLocation ModuleImportLoc
The source location of the \c import contextual keyword we just lexed, if any.
private SmallVector< std::pair<IdentifierInfo*, SourceLocation>, 2> ModuleImportPath
The module import path that we're currently processing.
private bool LastTokenWasAt = false
Whether the last token we lexed was an ' @ '.
private clang::Preprocessor::ImportSeq ImportSeqState = ImportSeq::AfterTopLevelTokenSeq
Our current position within a C++20 import-seq.
private clang::Preprocessor::TrackGMF TrackGMFState = TrackGMF::BeforeGMFIntroducer
private bool ModuleImportExpectsIdentifier = false
Whether the module import expects an identifier next. Otherwise, it expects a '.' or ';'.
private std::pair<IdentifierInfo*, SourceLocation> PragmaARCCFCodeAuditedInfo
The identifier and source location of the currently-active # pragma clang arc_cf_code_audited begin.
private clang::SourceLocation PragmaAssumeNonNullLoc
The source location of the currently-active # pragma clang assume_nonnull begin.
private clang::SourceLocation PreambleRecordedPragmaAssumeNonNullLoc
When the preamble is loaded into the main file, `PragmaAssumeNonNullLoc` will be set to this to replay the unterminated assume_nonnull.
private bool CodeCompletionReached = false
True if we hit the code-completion point.
private clang::IdentifierInfo* CodeCompletionII = nullptr
The code completion token containing the information on the stem that is to be code completed.
private clang::SourceRange CodeCompletionTokenRange
Range for the code completion token.
private const clang::DirectoryEntry* MainFileDir = nullptr
The directory that the main file should be considered to occupy, if it does not correspond to a real file (as happens when building a module).
private std::pair<int, bool> SkipMainFilePreamble
This is used when loading a precompiled preamble.
private bool HasReachedMaxIncludeDepth = false
Whether we hit an error due to reaching max allowed include depth. Allows to avoid hitting the same error over and over again.
private unsigned int LexLevel = 0
Lex is reentrant, and asking for an (end-of-phase-4) token can often require asking for multiple additional tokens. This counter makes it possible for Lex to detect whether it's producing a token for the end of phase 4 of translation or for some other situation.
private unsigned int TokenCount = 0
The number of (LexLevel 0) preprocessor tokens.
private bool PreprocessToken = false
Preprocess every token regardless of LexLevel.
private unsigned int MaxTokens = 0
The maximum number of (LexLevel 0) tokens before issuing a -Wmax-tokens warning, or zero for unlimited.
private clang::SourceLocation MaxTokensOverrideLoc
private class PreambleConditionalStackStore PreambleConditionalStack
private std::unique_ptr<Lexer> CurLexer
Only one of CurLexer, or CurTokenLexer will be non-null.
private clang::PreprocessorLexer* CurPPLexer = nullptr
This is an alias for CurLexer.
private clang::ConstSearchDirIterator CurDirLookup = nullptr
This allows us to implement # include_next and find directory-specific properties.
private std::unique_ptr<TokenLexer> CurTokenLexer
One of CurLexer and CurTokenLexer must be null.
private enum CurLexerKind CurLexerKind = CLK_Lexer
private clang::Module* CurLexerSubmodule = nullptr
If the current lexer is for a submodule that is being built, this is that submodule.
private std::vector<IncludeStackInfo> IncludeMacroStack
private std::unique_ptr<PPCallbacks> Callbacks
Actions invoked when some preprocessor activity is encountered (e.g. a file is # included, etc).
private SmallVector<clang::Preprocessor::MacroExpandsInfo, 2> DelayedMacroExpandsCallbacks
private SmallVector< clang::Preprocessor::BuildingSubmoduleInfo, 8> BuildingSubmoduleStack
private std::map<Module*, SubmoduleState> Submodules
private clang::Preprocessor::SubmoduleState NullSubmoduleState
The preprocessor state for preprocessing outside of any submodule.
private clang::Preprocessor::SubmoduleState* CurSubmoduleState
The current submodule state. Will be \p NullSubmoduleState if we're not in a submodule.
private clang::Preprocessor::IncludedFilesSet IncludedFiles
The files that have been included.
private llvm::FoldingSet<ModuleMacro> ModuleMacros
The set of known macros exported from modules.
private llvm::SmallVector<const IdentifierInfo*, 32> PendingModuleMacroNames
The names of potential module macros that we've not yet processed.
private llvm::DenseMap<const IdentifierInfo*, llvm::TinyPtrVector<ModuleMacro*>> LeafModuleMacros
The list of module macros, for each identifier, that are not overridden by any other module macro.
private clang::Preprocessor::WarnUnusedMacroLocsTy WarnUnusedMacroLocs
private llvm::DenseMap<const IdentifierInfo*, MacroAnnotations> AnnotationInfos
Warning information for macro annotations.
private clang::MacroArgs* MacroArgCache = nullptr
A "freelist" of MacroArg objects that can be reused for quick allocation.
private llvm::DenseMap<IdentifierInfo*, std::vector<MacroInfo*>> PragmaPushMacroInfo
For each IdentifierInfo used in a # pragma push_macro directive, we keep a MacroInfo stack used to restore the previous macro value.
private unsigned int NumDirectives = 0
private unsigned int NumDefined = 0
private unsigned int NumUndefined = 0
private unsigned int NumPragma = 0
private unsigned int NumIf = 0
private unsigned int NumElse = 0
private unsigned int NumEndif = 0
private unsigned int NumEnteredSourceFiles = 0
private unsigned int MaxIncludeStackDepth = 0
private unsigned int NumMacroExpanded = 0
private unsigned int NumFnMacroExpanded = 0
private unsigned int NumBuiltinMacroExpanded = 0
private unsigned int NumFastMacroExpanded = 0
private unsigned int NumTokenPaste = 0
private unsigned int NumFastTokenPaste = 0
private unsigned int NumSkipped = 0
private std::string Predefines
The predefined macros that preprocessor should use from the command line etc.
private clang::FileID PredefinesFileID
The file ID for the preprocessor predefines.
private clang::FileID PCHThroughHeaderFileID
The file ID for the PCH through header.
private bool SkippingUntilPragmaHdrStop = false
Whether tokens are being skipped until a #pragma hdrstop is seen.
private bool SkippingUntilPCHThroughHeader = false
Whether tokens are being skipped until the through header is seen.
private unsigned int NumCachedTokenLexers
private std::unique_ptr<TokenLexer>[8] TokenLexerCache
private SmallVector<clang::Token, 16> MacroExpandedTokens
Works like a stack; a TokenLexer adds the macro expanded tokens that is going to lex in the cache and when it finishes the tokens are removed from the end of the cache.
private std::vector<std::pair<TokenLexer*, size_t>> MacroExpandingLexersStack
private clang::PreprocessingRecord* Record = nullptr
This is an optional side structure that can be enabled with\c createPreprocessingRecord() prior to preprocessing.
private clang::Preprocessor::CachedTokensTy CachedTokens
Cached tokens are stored here when we do backtracking or lookahead. They are "lexed" by the CachingLex() method.
private CachedTokensTy::size_type CachedLexPos = 0
If it points beyond the CachedTokens vector, it means that a normal Lex() should be invoked.
private std::vector<CachedTokensTy::size_type> BacktrackPositions
The EnableBacktrackAtThisPos() method pushes a position to indicate where CachedLexPos should be set when the BackTrack() method is invoked (at which point the last position is popped).
private clang::Preprocessor::MacroInfoChain* MIChainHead = nullptr
MacroInfos are managed as a chain for easy disposal. This is the head of that list.
private bool SkippingExcludedConditionalBlock = false
See comments at the use-site for more context about why it is needed.
private llvm::DenseMap<const char*, unsigned int> RecordedSkippedRanges
Keeps track of skipped range mappings that were recorded while skipping excluded conditional directives. It maps the source buffer pointer at the beginning of a skipped block, to the number of bytes that should be skipped.
private llvm::DenseMap<IdentifierInfo*, unsigned int> PoisonReasons
private clang::IdentifierInfo* Ident__exception_code
Identifiers used for SEH handling in Borland. These are only allowed in particular circumstances
private clang::IdentifierInfo* Ident___exception_code
Identifiers used for SEH handling in Borland. These are only allowed in particular circumstances
private clang::IdentifierInfo* Ident_GetExceptionCode
Identifiers used for SEH handling in Borland. These are only allowed in particular circumstances
private clang::IdentifierInfo* Ident__exception_info
private clang::IdentifierInfo* Ident___exception_info
private clang::IdentifierInfo* Ident_GetExceptionInfo
private clang::IdentifierInfo* Ident__abnormal_termination
private clang::IdentifierInfo* Ident___abnormal_termination
private clang::IdentifierInfo* Ident_AbnormalTermination

Method Overview

Methods

void AddPragmaHandler(
    clang::PragmaHandler* Handler)

Declared at: clang/include/clang/Lex/Preprocessor.h:1379

Parameters

clang::PragmaHandler* Handler

void AddPragmaHandler(
    llvm::StringRef Namespace,
    clang::PragmaHandler* Handler)

Description

Add the specified pragma handler to this preprocessor. If \p Namespace is non-null, then it is a token required to exist on the pragma line before the pragma string starts, e.g. "STDC" or "GCC".

Declared at: clang/include/clang/Lex/Preprocessor.h:1378

Parameters

llvm::StringRef Namespace
clang::PragmaHandler* Handler

clang::SourceLocation AdvanceToTokenCharacter(
    clang::SourceLocation TokStart,
    unsigned int Char) const

Description

Given a location that specifies the start of a token, return a new location that specifies a character within the token.

Declared at: clang/include/clang/Lex/Preprocessor.h:2043

Parameters

clang::SourceLocation TokStart
unsigned int Char

clang::DefMacroDirective*
AllocateDefMacroDirective(
    clang::MacroInfo* MI,
    clang::SourceLocation Loc)

Declared at: clang/include/clang/Lex/Preprocessor.h:2284

Parameters

clang::MacroInfo* MI
clang::SourceLocation Loc

clang::MacroInfo* AllocateMacroInfo(
    clang::SourceLocation L)

Description

Allocate a new MacroInfo object with the provided SourceLocation.

Declared at: clang/include/clang/Lex/Preprocessor.h:2215

Parameters

clang::SourceLocation L

clang::UndefMacroDirective*
AllocateUndefMacroDirective(
    clang::SourceLocation UndefLoc)

Declared at: clang/include/clang/Lex/Preprocessor.h:2286

Parameters

clang::SourceLocation UndefLoc

clang::VisibilityMacroDirective*
AllocateVisibilityMacroDirective(
    clang::SourceLocation Loc,
    bool isPublic)

Declared at: clang/include/clang/Lex/Preprocessor.h:2287

Parameters

clang::SourceLocation Loc
bool isPublic

void AnnotateCachedTokens(const clang::Token& Tok)

Description

We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should replace the most recent cached tokens with the given annotation token. This function has no effect if backtracking is not enabled. Note that the use of this function is just for optimization, so that the cached tokens doesn't get re-parsed and re-resolved after a backtrack is invoked.

Declared at: clang/include/clang/Lex/Preprocessor.h:1707

Parameters

const clang::Token& Tok

void AnnotatePreviousCachedTokens(
    const clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2465

Parameters

const clang::Token& Tok

void Backtrack()

Description

Make Preprocessor re-lex the tokens that were lexed since EnableBacktrackAtThisPos() was previously called.

Declared at: clang/include/clang/Lex/Preprocessor.h:1567

void CachingLex(clang::Token& Result)

Declared at: clang/include/clang/Lex/Preprocessor.h:2448

Parameters

clang::Token& Result

clang::SourceLocation CheckEndOfDirective(
    const char* DirType,
    bool EnableMacros = false)

Description

Ensure that the next token is a tok::eod token. If not, emit a diagnostic and consume up until the eod. If \p EnableMacros is true, then we consider macros that expand to zero tokens as being ok.

Declared at: clang/include/clang/Lex/Preprocessor.h:2156

Parameters

const char* DirType
bool EnableMacros = false

Returns

The location of the end of the directive (the terminating newline).

bool CheckMacroName(clang::Token& MacroNameTok,
                    clang::MacroUse isDefineUndef,
                    bool* ShadowFlag = nullptr)

Declared at: clang/include/clang/Lex/Preprocessor.h:2247

Parameters

clang::Token& MacroNameTok
clang::MacroUse isDefineUndef
bool* ShadowFlag = nullptr

void CodeCompleteIncludedFile(llvm::StringRef Dir,
                              bool IsAngled)

Description

Hook used by the lexer to invoke the "included file" code completion point.

Declared at: clang/include/clang/Lex/Preprocessor.h:1426

Parameters

llvm::StringRef Dir
bool IsAngled

void CodeCompleteNaturalLanguage()

Description

Hook used by the lexer to invoke the "natural language" code completion point.

Declared at: clang/include/clang/Lex/Preprocessor.h:1430

void CollectPpImportSuffix(
    SmallVectorImpl<clang::Token>& Toks)

Declared at: clang/include/clang/Lex/Preprocessor.h:1580

Parameters

SmallVectorImpl<clang::Token>& Toks

void CommitBacktrackedTokens()

Description

Disable the last EnableBacktrackAtThisPos call.

Declared at: clang/include/clang/Lex/Preprocessor.h:1563

void CreateString(
    llvm::StringRef Str,
    clang::Token& Tok,
    clang::SourceLocation ExpansionLocStart =
        clang::SourceLocation(),
    clang::SourceLocation ExpansionLocEnd =
        clang::SourceLocation())

Description

Plop the specified string into a scratch buffer and set the specified token's location and length to it. If specified, the source location provides a location of the expansion point of the token.

Declared at: clang/include/clang/Lex/Preprocessor.h:1986

Parameters

llvm::StringRef Str
clang::Token& Tok
clang::SourceLocation ExpansionLocStart = clang::SourceLocation()
clang::SourceLocation ExpansionLocEnd = clang::SourceLocation()

clang::DiagnosticBuilder Diag(
    clang::SourceLocation Loc,
    unsigned int DiagID) const

Description

Forwarding function for diagnostics. This emits a diagnostic at the specified Token's location, translating the token's start position in the current buffer into a SourcePosition object for rendering.

Declared at: clang/include/clang/Lex/Preprocessor.h:1886

Parameters

clang::SourceLocation Loc
unsigned int DiagID

clang::DiagnosticBuilder Diag(
    const clang::Token& Tok,
    unsigned int DiagID) const

Declared at: clang/include/clang/Lex/Preprocessor.h:1890

Parameters

const clang::Token& Tok
unsigned int DiagID

clang::SourceRange DiscardUntilEndOfDirective()

Description

Read and discard all tokens remaining on the current line until the tok::eod token is found. Returns the range of the skipped tokens.

Declared at: clang/include/clang/Lex/Preprocessor.h:2161

void DumpLocation(clang::SourceLocation Loc) const

Declared at: clang/include/clang/Lex/Preprocessor.h:2037

Parameters

clang::SourceLocation Loc

void DumpMacro(const clang::MacroInfo& MI) const

Declared at: clang/include/clang/Lex/Preprocessor.h:2038

Parameters

const clang::MacroInfo& MI

void DumpToken(const clang::Token& Tok,
               bool DumpFlags = false) const

Description

Print the token to stderr, used for debugging.

Declared at: clang/include/clang/Lex/Preprocessor.h:2036

Parameters

const clang::Token& Tok
bool DumpFlags = false

void EnableBacktrackAtThisPos()

Description

From the point that this method is called, and until CommitBacktrackedTokens() or Backtrack() is called, the Preprocessor keeps track of the lexed tokens so that a subsequent Backtrack() call will make the Preprocessor re-lex the same tokens. Nested backtracks are allowed, meaning that EnableBacktrackAtThisPos can be called multiple times and CommitBacktrackedTokens/Backtrack calls will be combined with the EnableBacktrackAtThisPos calls in reverse order. NOTE: *DO NOT* forget to call either CommitBacktrackedTokens or Backtrack at some point after EnableBacktrackAtThisPos. If you don't, caching of tokens will continue indefinitely.

Declared at: clang/include/clang/Lex/Preprocessor.h:1560

void EndSourceFile()

Description

Inform the preprocessor callbacks that processing is complete.

Declared at: clang/include/clang/Lex/Preprocessor.h:1491

void EnterAnnotationToken(
    clang::SourceRange Range,
    tok::TokenKind Kind,
    void* AnnotationVal)

Description

Enter an annotation token into the token stream.

Declared at: clang/include/clang/Lex/Preprocessor.h:1746

Parameters

clang::SourceRange Range
tok::TokenKind Kind
void* AnnotationVal

void EnterCachingLexMode()

Declared at: clang/include/clang/Lex/Preprocessor.h:2456

void EnterCachingLexModeUnchecked()

Declared at: clang/include/clang/Lex/Preprocessor.h:2457

void EnterMacro(clang::Token& Tok,
                clang::SourceLocation ILEnd,
                clang::MacroInfo* Macro,
                clang::MacroArgs* Args)

Description

Add a Macro to the top of the include stack and start lexing tokens from it instead of the current buffer.

Declared at: clang/include/clang/Lex/Preprocessor.h:1506

Parameters

clang::Token& Tok
clang::SourceLocation ILEnd
specifies the location of the ')' for a function-like macro or the identifier for an object-like macro.
clang::MacroInfo* Macro
clang::MacroArgs* Args
specifies the tokens input to a function-like macro.

void EnterMainSourceFile()

Description

Enter the specified FileID as the main source file, which implicitly adds the builtin defines etc.

Declared at: clang/include/clang/Lex/Preprocessor.h:1488

bool EnterSourceFile(
    clang::FileID FID,
    clang::ConstSearchDirIterator Dir,
    clang::SourceLocation Loc,
    bool IsFirstIncludeOfFile = true)

Description

Add a source file to the top of the include stack and start lexing tokens from it instead of the current buffer. Emits a diagnostic, doesn't enter the file, and returns true on error.

Declared at: clang/include/clang/Lex/Preprocessor.h:1497

Parameters

clang::FileID FID
clang::ConstSearchDirIterator Dir
clang::SourceLocation Loc
bool IsFirstIncludeOfFile = true

void EnterSourceFileWithLexer(
    clang::Lexer* TheLexer,
    clang::ConstSearchDirIterator Dir)

Description

Add a lexer to the top of the include stack and start lexing tokens from it instead of the current buffer.

Declared at: clang/include/clang/Lex/Preprocessor.h:2421

Parameters

clang::Lexer* TheLexer
clang::ConstSearchDirIterator Dir

void EnterSubmodule(
    clang::Module* M,
    clang::SourceLocation ImportLoc,
    bool ForPragma)

Declared at: clang/include/clang/Lex/Preprocessor.h:2250

Parameters

clang::Module* M
clang::SourceLocation ImportLoc
bool ForPragma

void EnterToken(const clang::Token& Tok,
                bool IsReinject)

Description

Enters a token in the token stream to be lexed next. If BackTrack() is called afterwards, the token will remain at the insertion point. If \p IsReinject is true, resulting token will have Token::IsReinjected flag set. See the flag documentation for details.

Declared at: clang/include/clang/Lex/Preprocessor.h:1685

Parameters

const clang::Token& Tok
bool IsReinject

void EnterTokenStream(const clang::Token* Toks,
                      unsigned int NumToks,
                      bool DisableMacroExpansion,
                      bool OwnsTokens,
                      bool IsReinject)

Description

Add a "macro" context to the top of the include stack, which will cause the lexer to start returning the specified tokens. If \p DisableMacroExpansion is true, tokens lexed from the token stream will not be subject to further macro expansion. Otherwise, these tokens will be re-macro-expanded when/if expansion is enabled. If \p OwnsTokens is false, this method assumes that the specified stream of tokens has a permanent owner somewhere, so they do not need to be copied. If it is true, it assumes the array of tokens is allocated with\c new[] and the Preprocessor will delete[] it. If \p IsReinject the resulting tokens will have Token::IsReinjected flag set, see the flag documentation for details.

Declared at: clang/include/clang/Lex/Preprocessor.h:1524

Parameters

const clang::Token* Toks
unsigned int NumToks
bool DisableMacroExpansion
bool OwnsTokens
bool IsReinject

void EnterTokenStream(ArrayRef<clang::Token> Toks,
                      bool DisableMacroExpansion,
                      bool IsReinject)

Declared at: clang/include/clang/Lex/Preprocessor.h:1535

Parameters

ArrayRef<clang::Token> Toks
bool DisableMacroExpansion
bool IsReinject

void EnterTokenStream(
    std::unique_ptr<Token[]> Toks,
    unsigned int NumToks,
    bool DisableMacroExpansion,
    bool IsReinject)

Declared at: clang/include/clang/Lex/Preprocessor.h:1529

Parameters

std::unique_ptr<Token[]> Toks
unsigned int NumToks
bool DisableMacroExpansion
bool IsReinject

clang::Preprocessor::DirectiveEvalResult
EvaluateDirectiveExpression(
    clang::IdentifierInfo*& IfNDefMacro)

Description

Evaluate an integer constant expression that may occur after a # if or # elif directive and return a \p DirectiveEvalResult object. If the expression is equivalent to "!defined(X)" return X in IfNDefMacro.

Declared at: clang/include/clang/Lex/Preprocessor.h:2358

Parameters

clang::IdentifierInfo*& IfNDefMacro

bool EvaluateHasInclude(clang::Token& Tok,
                        clang::IdentifierInfo* II)

Description

Process a '__has_include("path")' expression. Returns true if successful.

Declared at: clang/include/clang/Lex/Preprocessor.h:2363

Parameters

clang::Token& Tok
clang::IdentifierInfo* II

bool EvaluateHasIncludeNext(
    clang::Token& Tok,
    clang::IdentifierInfo* II)

Description

Process '__has_include_next("path")' expression. Returns true if successful.

Declared at: clang/include/clang/Lex/Preprocessor.h:2368

Parameters

clang::Token& Tok
clang::IdentifierInfo* II

void ExitCachingLexMode()

Declared at: clang/include/clang/Lex/Preprocessor.h:2459

void ExpandBuiltinMacro(clang::Token& Tok)

Description

If an identifier token is read that is to be expanded as a builtin macro, handle it and return the next token as 'Tok'.

Declared at: clang/include/clang/Lex/Preprocessor.h:2408

Parameters

clang::Token& Tok

void FinalizeForModelFile()

Description

Cleanup after model file parsing

Declared at: clang/include/clang/Lex/Preprocessor.h:1060

bool FinishLexStringLiteral(
    clang::Token& Result,
    std::string& String,
    const char* DiagnosticTag,
    bool AllowMacroExpansion)

Description

Complete the lexing of a string literal where the first token has already been lexed (see LexStringLiteral).

Declared at: clang/include/clang/Lex/Preprocessor.h:1603

Parameters

clang::Token& Result
std::string& String
const char* DiagnosticTag
bool AllowMacroExpansion

bool GetIncludeFilenameSpelling(
    clang::SourceLocation Loc,
    llvm::StringRef& Buffer)

Description

Turn the specified lexer token into a fully checked and spelled filename, e.g. as an operand of # include. The caller is expected to provide a buffer that is large enough to hold the spelling of the filename, but is also expected to handle the case when this method decides to use a different buffer.

Declared at: clang/include/clang/Lex/Preprocessor.h:2226

Parameters

clang::SourceLocation Loc
llvm::StringRef& Buffer

Returns

true if the input filename was in < >'s or false if it was in ""'s.

bool GetSuppressIncludeNotFoundError()

Declared at: clang/include/clang/Lex/Preprocessor.h:1123

bool HandleComment(clang::Token& result,
                   clang::SourceRange Comment)

Declared at: clang/include/clang/Lex/Preprocessor.h:2616

Parameters

clang::Token& result
clang::SourceRange Comment

void HandleDefineDirective(
    clang::Token& Tok,
    bool ImmediatelyAfterHeaderGuard)

Declared at: clang/include/clang/Lex/Preprocessor.h:2585

Parameters

clang::Token& Tok
bool ImmediatelyAfterHeaderGuard

void HandleDigitDirective(clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2472

Parameters

clang::Token& Tok

void HandleDirective(clang::Token& Result)

Description

Callback invoked when the lexer sees a # token at the start of a line. This consumes the directive, modifies the lexer/preprocessor state, and advances the lexer(s) so that the next token read is the correct one.

Declared at: clang/include/clang/Lex/Preprocessor.h:2146

Parameters

clang::Token& Result

void HandleElifFamilyDirective(
    clang::Token& ElifToken,
    const clang::Token& HashToken,
    tok::PPKeywordKind Kind)

Declared at: clang/include/clang/Lex/Preprocessor.h:2595

Parameters

clang::Token& ElifToken
const clang::Token& HashToken
tok::PPKeywordKind Kind

void HandleElseDirective(
    clang::Token& Result,
    const clang::Token& HashToken)

Declared at: clang/include/clang/Lex/Preprocessor.h:2594

Parameters

clang::Token& Result
const clang::Token& HashToken

bool HandleEndOfFile(clang::Token& Result,
                     bool isEndOfMacro = false)

Description

Callback invoked when the lexer hits the end of the current file. This either returns the EOF token and returns true, or pops a level off the include stack and returns false, at which point the client should call lex again.

Declared at: clang/include/clang/Lex/Preprocessor.h:2135

Parameters

clang::Token& Result
bool isEndOfMacro = false

bool HandleEndOfTokenLexer(clang::Token& Result)

Description

Callback invoked when the current TokenLexer hits the end of its token stream.

Declared at: clang/include/clang/Lex/Preprocessor.h:2139

Parameters

clang::Token& Result

void HandleEndifDirective(
    clang::Token& EndifToken)

Declared at: clang/include/clang/Lex/Preprocessor.h:2593

Parameters

clang::Token& EndifToken

clang::Preprocessor::ImportAction
HandleHeaderIncludeOrImport(
    clang::SourceLocation HashLoc,
    clang::Token& IncludeTok,
    clang::Token& FilenameTok,
    clang::SourceLocation EndLoc,
    clang::ConstSearchDirIterator LookupFrom =
        nullptr,
    const clang::FileEntry* LookupFromFile =
        nullptr)

Declared at: clang/include/clang/Lex/Preprocessor.h:2512

Parameters

clang::SourceLocation HashLoc
clang::Token& IncludeTok
clang::Token& FilenameTok
clang::SourceLocation EndLoc
clang::ConstSearchDirIterator LookupFrom = nullptr
const clang::FileEntry* LookupFromFile = nullptr

void HandleIdentSCCSDirective(clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2474

Parameters

clang::Token& Tok

bool HandleIdentifier(clang::Token& Identifier)

Description

Callback invoked when the lexer reads an identifier and has filled in the tokens IdentifierInfo member. This callback potentially macro expands it or turns it into a named token (like 'for').

Declared at: clang/include/clang/Lex/Preprocessor.h:2128

Parameters

clang::Token& Identifier

Returns

true if we actually computed a token, false if we need to lex again.

void HandleIfDirective(
    clang::Token& IfToken,
    const clang::Token& HashToken,
    bool ReadAnyTokensBeforeDirective)

Declared at: clang/include/clang/Lex/Preprocessor.h:2591

Parameters

clang::Token& IfToken
const clang::Token& HashToken
bool ReadAnyTokensBeforeDirective

void HandleIfdefDirective(
    clang::Token& Result,
    const clang::Token& HashToken,
    bool isIfndef,
    bool ReadAnyTokensBeforeDirective)

Declared at: clang/include/clang/Lex/Preprocessor.h:2589

Parameters

clang::Token& Result
const clang::Token& HashToken
bool isIfndef
bool ReadAnyTokensBeforeDirective

void HandleImportDirective(
    clang::SourceLocation HashLoc,
    clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2518

Parameters

clang::SourceLocation HashLoc
clang::Token& Tok

void HandleIncludeDirective(
    clang::SourceLocation HashLoc,
    clang::Token& Tok,
    clang::ConstSearchDirIterator LookupFrom =
        nullptr,
    const clang::FileEntry* LookupFromFile =
        nullptr)

Declared at: clang/include/clang/Lex/Preprocessor.h:2508

Parameters

clang::SourceLocation HashLoc
clang::Token& Tok
clang::ConstSearchDirIterator LookupFrom = nullptr
const clang::FileEntry* LookupFromFile = nullptr

void HandleIncludeMacrosDirective(
    clang::SourceLocation HashLoc,
    clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2517

Parameters

clang::SourceLocation HashLoc
clang::Token& Tok

void HandleIncludeNextDirective(
    clang::SourceLocation HashLoc,
    clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2516

Parameters

clang::SourceLocation HashLoc
clang::Token& Tok

void HandleLineDirective()

Description

Handle*Directive - implement the various preprocessor directives. These should side-effect the current preprocessor object so that the next call to Lex() will return the appropriate token next.

Declared at: clang/include/clang/Lex/Preprocessor.h:2471

bool HandleMacroExpandedIdentifier(
    clang::Token& Identifier,
    const clang::MacroDefinition& MD)

Description

If an identifier token is read that is to be expanded as a macro, handle it and return the next token as 'Tok'. If we lexed a token, return true; otherwise the caller should lex again.

Declared at: clang/include/clang/Lex/Preprocessor.h:2384

Parameters

clang::Token& Identifier
const clang::MacroDefinition& MD

void HandleMacroPrivateDirective()

Declared at: clang/include/clang/Lex/Preprocessor.h:2476

void HandleMacroPublicDirective(clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2475

Parameters

clang::Token& Tok

void HandleMicrosoftCommentPaste(
    clang::Token& Tok)

Description

When the macro expander pastes together a comment (/##/) in Microsoft mode, this method handles updating the current state, returning the token on the next source line.

Declared at: clang/include/clang/Lex/Preprocessor.h:2066

Parameters

clang::Token& Tok

void HandleMicrosoftImportDirective(
    clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2519

Parameters

clang::Token& Tok

void HandleMicrosoft__pragma(clang::Token& Tok)

Description

Like Handle_Pragma except the pragma text is not enclosed within a string literal.

Declared at: clang/include/clang/Lex/Preprocessor.h:2417

Parameters

clang::Token& Tok

void HandlePoisonedIdentifier(
    clang::Token& Identifier)

Description

Display reason for poisoned identifier.

Declared at: clang/include/clang/Lex/Preprocessor.h:2088

Parameters

clang::Token& Identifier

void HandlePragmaDependency(
    clang::Token& DependencyTok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2606

Parameters

clang::Token& DependencyTok

void HandlePragmaDirective(
    clang::PragmaIntroducer Introducer)

Declared at: clang/include/clang/Lex/Preprocessor.h:2599

Parameters

clang::PragmaIntroducer Introducer

void HandlePragmaHdrstop(clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2611

Parameters

clang::Token& Tok

void HandlePragmaIncludeAlias(clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2609

Parameters

clang::Token& Tok

void HandlePragmaMark(clang::Token& MarkTok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2603

Parameters

clang::Token& MarkTok

void HandlePragmaModuleBuild(clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2610

Parameters

clang::Token& Tok

void HandlePragmaOnce(clang::Token& OnceTok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2602

Parameters

clang::Token& OnceTok

void HandlePragmaPoison()

Declared at: clang/include/clang/Lex/Preprocessor.h:2604

void HandlePragmaPopMacro(clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2608

Parameters

clang::Token& Tok

void HandlePragmaPushMacro(clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2607

Parameters

clang::Token& Tok

void HandlePragmaSystemHeader(
    clang::Token& SysHeaderTok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2605

Parameters

clang::Token& SysHeaderTok

void HandleSkippedDirectiveWhileUsingPCH(
    clang::Token& Result,
    clang::SourceLocation HashLoc)

Description

Process directives while skipping until the through header or #pragma hdrstop is found.

Declared at: clang/include/clang/Lex/Preprocessor.h:1483

Parameters

clang::Token& Result
clang::SourceLocation HashLoc

void HandleUndefDirective()

Declared at: clang/include/clang/Lex/Preprocessor.h:2586

void HandleUserDiagnosticDirective(
    clang::Token& Tok,
    bool isWarning)

Declared at: clang/include/clang/Lex/Preprocessor.h:2473

Parameters

clang::Token& Tok
bool isWarning

void Handle_Pragma(clang::Token& Tok)

Description

Read a \c _Pragma directive, slice it up, process it, then return the first token after the directive. This assumes that the \c _Pragma token has just been read into \p Tok.

Declared at: clang/include/clang/Lex/Preprocessor.h:2413

Parameters

clang::Token& Tok

void IgnorePragmas()

Description

Install empty handlers for all pragmas (making them ignored).

Declared at: clang/include/clang/Lex/Preprocessor.h:1394

bool InCachingLexMode() const

Declared at: clang/include/clang/Lex/Preprocessor.h:2450

void IncrementPasteCounter(bool isFast)

Description

Increment the counters for the number of token paste operations performed. If fast was specified, this is a 'fast paste' case we handled.

Declared at: clang/include/clang/Lex/Preprocessor.h:2052

Parameters

bool isFast

void Initialize(
    const clang::TargetInfo& Target,
    const clang::TargetInfo* AuxTarget = nullptr)

Description

Initialize the preprocessor using information about the target.

Declared at: clang/include/clang/Lex/Preprocessor.h:1048

Parameters

const clang::TargetInfo& Target
is owned by the caller and must remain valid for the lifetime of the preprocessor.
const clang::TargetInfo* AuxTarget = nullptr
is owned by the caller and must remain valid for the lifetime of the preprocessor.

void InitializeForModelFile()

Description

Initialize the preprocessor to parse a model file To parse model files the preprocessor of the original source is reused to preserver the identifier table. However to avoid some duplicate information in the preprocessor some cleanup is needed before it is used to parse model files. This method does that cleanup.

Declared at: clang/include/clang/Lex/Preprocessor.h:1057

bool IsFileLexer() const

Declared at: clang/include/clang/Lex/Preprocessor.h:2442

static bool IsFileLexer(
    const clang::Lexer* L,
    const clang::PreprocessorLexer* P)

Description

Returns true if we are lexing from a file and not a pragma or a macro.

Declared at: clang/include/clang/Lex/Preprocessor.h:2434

Parameters

const clang::Lexer* L
const clang::PreprocessorLexer* P

static bool IsFileLexer(
    const clang::Preprocessor::IncludeStackInfo&
        I)

Declared at: clang/include/clang/Lex/Preprocessor.h:2438

Parameters

const clang::Preprocessor::IncludeStackInfo& I

bool IsPreviousCachedToken(
    const clang::Token& Tok) const

Description

Whether \p Tok is the most recent token (`CachedLexPos - 1`) in CachedTokens.

Declared at: clang/include/clang/Lex/Preprocessor.h:1722

Parameters

const clang::Token& Tok

clang::Module* LeaveSubmodule(bool ForPragma)

Declared at: clang/include/clang/Lex/Preprocessor.h:2251

Parameters

bool ForPragma

void Lex(clang::Token& Result)

Description

Lex the next token for this preprocessor.

Declared at: clang/include/clang/Lex/Preprocessor.h:1574

Parameters

clang::Token& Result

bool LexAfterModuleImport(clang::Token& Result)

Declared at: clang/include/clang/Lex/Preprocessor.h:1579

Parameters

clang::Token& Result

bool LexHeaderName(
    clang::Token& Result,
    bool AllowMacroExpansion = true)

Description

Lex a token, forming a header-name token if possible.

Declared at: clang/include/clang/Lex/Preprocessor.h:1577

Parameters

clang::Token& Result
bool AllowMacroExpansion = true

void LexNonComment(clang::Token& Result)

Description

Lex a token. If it's a comment, keep lexing until we get something not a comment. This is useful in -E -C mode where comments would foul up preprocessor directive handling.

Declared at: clang/include/clang/Lex/Preprocessor.h:1612

Parameters

clang::Token& Result

bool LexOnOffSwitch(tok::OnOffSwitch& Result)

Description

Lex an on-off-switch (C99 6.10.6p2) and verify that it is followed by EOD. Return true if the token is not a valid on-off-switch.

Declared at: clang/include/clang/Lex/Preprocessor.h:2245

Parameters

tok::OnOffSwitch& Result

bool LexStringLiteral(clang::Token& Result,
                      std::string& String,
                      const char* DiagnosticTag,
                      bool AllowMacroExpansion)

Description

Lex a string literal, which may be the concatenation of multiple string literals and may even come from macro expansion.

Declared at: clang/include/clang/Lex/Preprocessor.h:1591

Parameters

clang::Token& Result
std::string& String
const char* DiagnosticTag
bool AllowMacroExpansion

Returns

true on success, false if a error diagnostic has been generated.

void LexUnexpandedNonComment(clang::Token& Result)

Description

Like LexNonComment, but this disables macro expansion of identifier tokens.

Declared at: clang/include/clang/Lex/Preprocessor.h:1632

Parameters

clang::Token& Result

void LexUnexpandedToken(clang::Token& Result)

Description

Just like Lex, but disables macro expansion of identifier tokens.

Declared at: clang/include/clang/Lex/Preprocessor.h:1619

Parameters

clang::Token& Result

const clang::Token& LookAhead(unsigned int N)

Description

Peeks ahead N tokens and returns that token without consuming any tokens. LookAhead(0) returns the next token that would be returned by Lex(), LookAhead(1) returns the token after it, etc. This returns normal tokens after phase 5. As such, it is equivalent to using 'Lex', not 'LexUnexpandedToken'.

Declared at: clang/include/clang/Lex/Preprocessor.h:1656

Parameters

unsigned int N

clang::IdentifierInfo* LookUpIdentifierInfo(
    clang::Token& Identifier) const

Description

Given a tok::raw_identifier token, look up the identifier information for the token and install it into the token, updating the token kind accordingly.

Declared at: clang/include/clang/Lex/Preprocessor.h:2075

Parameters

clang::Token& Identifier

Optional<clang::FileEntryRef> LookupFile(
    clang::SourceLocation FilenameLoc,
    llvm::StringRef Filename,
    bool isAngled,
    clang::ConstSearchDirIterator FromDir,
    const clang::FileEntry* FromFile,
    clang::ConstSearchDirIterator* CurDir,
    SmallVectorImpl<char>* SearchPath,
    SmallVectorImpl<char>* RelativePath,
    ModuleMap::KnownHeader* SuggestedModule,
    bool* IsMapped,
    bool* IsFrameworkFound,
    bool SkipCache = false)

Description

Given a "foo" or < foo> reference, look up the indicated file. Returns None on failure. \p isAngled indicates whether the file reference is for system # include's or not (i.e. using < > instead of "").

Declared at: clang/include/clang/Lex/Preprocessor.h:2233

Parameters

clang::SourceLocation FilenameLoc
llvm::StringRef Filename
bool isAngled
clang::ConstSearchDirIterator FromDir
const clang::FileEntry* FromFile
clang::ConstSearchDirIterator* CurDir
SmallVectorImpl<char>* SearchPath
SmallVectorImpl<char>* RelativePath
ModuleMap::KnownHeader* SuggestedModule
bool* IsMapped
bool* IsFrameworkFound
bool SkipCache = false

Optional<clang::FileEntryRef>
LookupHeaderIncludeOrImport(
    clang::ConstSearchDirIterator* CurDir,
    llvm::StringRef& Filename,
    clang::SourceLocation FilenameLoc,
    clang::CharSourceRange FilenameRange,
    const clang::Token& FilenameTok,
    bool& IsFrameworkFound,
    bool IsImportDecl,
    bool& IsMapped,
    clang::ConstSearchDirIterator LookupFrom,
    const clang::FileEntry* LookupFromFile,
    llvm::StringRef& LookupFilename,
    SmallVectorImpl<char>& RelativePath,
    SmallVectorImpl<char>& SearchPath,
    ModuleMap::KnownHeader& SuggestedModule,
    bool isAngled)

Declared at: clang/include/clang/Lex/Preprocessor.h:2498

Parameters

clang::ConstSearchDirIterator* CurDir
llvm::StringRef& Filename
clang::SourceLocation FilenameLoc
clang::CharSourceRange FilenameRange
const clang::Token& FilenameTok
bool& IsFrameworkFound
bool IsImportDecl
bool& IsMapped
clang::ConstSearchDirIterator LookupFrom
const clang::FileEntry* LookupFromFile
llvm::StringRef& LookupFilename
SmallVectorImpl<char>& RelativePath
SmallVectorImpl<char>& SearchPath
ModuleMap::KnownHeader& SuggestedModule
bool isAngled

void MaybeHandlePoisonedIdentifier(
    clang::Token& Identifier)

Declared at: clang/include/clang/Lex/Preprocessor.h:2090

Parameters

clang::Token& Identifier

clang::IdentifierInfo* ParsePragmaPushOrPopMacro(
    clang::Token& Tok)

Declared at: clang/include/clang/Lex/Preprocessor.h:2612

Parameters

clang::Token& Tok

const clang::Token& PeekAhead(unsigned int N)

Declared at: clang/include/clang/Lex/Preprocessor.h:2464

Parameters

unsigned int N

void PoisonSEHIdentifiers(bool Poison = true)

Declared at: clang/include/clang/Lex/Preprocessor.h:2118

Parameters

bool Poison = true

void PopIncludeMacroStack()

Declared at: clang/include/clang/Lex/Preprocessor.h:2264

Preprocessor(
    std::shared_ptr<PreprocessorOptions> PPOpts,
    clang::DiagnosticsEngine& diags,
    clang::LangOptions& opts,
    clang::SourceManager& SM,
    clang::HeaderSearch& Headers,
    clang::ModuleLoader& TheModuleLoader,
    clang::IdentifierInfoLookup* IILookup =
        nullptr,
    bool OwnsHeaderSearch = false,
    clang::TranslationUnitKind TUKind =
        TU_Complete)

Declared at: clang/include/clang/Lex/Preprocessor.h:1033

Parameters

std::shared_ptr<PreprocessorOptions> PPOpts
clang::DiagnosticsEngine& diags
clang::LangOptions& opts
clang::SourceManager& SM
clang::HeaderSearch& Headers
clang::ModuleLoader& TheModuleLoader
clang::IdentifierInfoLookup* IILookup = nullptr
bool OwnsHeaderSearch = false
clang::TranslationUnitKind TUKind = TU_Complete

void PrintStats()

Declared at: clang/include/clang/Lex/Preprocessor.h:2059

void PropagateLineStartLeadingSpaceInfo(
    clang::Token& Result)

Declared at: clang/include/clang/Lex/Preprocessor.h:2274

Parameters

clang::Token& Result

void PushIncludeMacroStack()

Declared at: clang/include/clang/Lex/Preprocessor.h:2256

clang::MacroArgs* ReadMacroCallArgumentList(
    clang::Token& MacroName,
    clang::MacroInfo* MI,
    clang::SourceLocation& MacroEnd)

Description

After reading "MACRO(", this method is invoked to read all of the formal arguments specified for the macro invocation. Returns null on error.

Declared at: clang/include/clang/Lex/Preprocessor.h:2403

Parameters

clang::Token& MacroName
clang::MacroInfo* MI
clang::SourceLocation& MacroEnd

void ReadMacroName(
    clang::Token& MacroNameTok,
    clang::MacroUse IsDefineUndef = MU_Other,
    bool* ShadowFlag = nullptr)

Description

Lex and validate a macro name, which occurs after a # define or # undef. This emits a diagnostic, sets the token kind to eod, and discards the rest of the macro line if the macro name is invalid.

Declared at: clang/include/clang/Lex/Preprocessor.h:2300

Parameters

clang::Token& MacroNameTok
Token that represents the name defined or undefined.
clang::MacroUse IsDefineUndef = MU_Other
Kind if preprocessor directive.
bool* ShadowFlag = nullptr
Points to flag that is set if macro name shadows a keyword.

bool ReadMacroParameterList(clang::MacroInfo* MI,
                            clang::Token& LastTok)

Description

The ( starting an argument list of a macro definition has just been read. Lex the rest of the parameters and the closing ), updating \p MI with what we learn and saving in \p LastTok the last token read. Return true if an error occurs parsing the arg list.

Declared at: clang/include/clang/Lex/Preprocessor.h:2319

Parameters

clang::MacroInfo* MI
clang::Token& LastTok

clang::MacroInfo*
ReadOptionalMacroParameterListAndBody(
    const clang::Token& MacroNameTok,
    bool ImmediatelyAfterHeaderGuard)

Description

ReadOptionalMacroParameterListAndBody - This consumes all (i.e. the entire line) of the macro's tokens and adds them to MacroInfo, and while doing so performs certain validity checks including (but not limited to): - # (stringization) is followed by a macro parameter Either returns a pointer to a MacroInfo object OR emits a diagnostic and returns a nullptr if an invalid sequence of tokens is encountered.

Declared at: clang/include/clang/Lex/Preprocessor.h:2312

Parameters

const clang::Token& MacroNameTok
- Token that represents the macro name
bool ImmediatelyAfterHeaderGuard
- Macro follows an #ifdef header guard

void RegisterBuiltinMacros()

Description

Register builtin macros such as __LINE__ with the identifier table.

Declared at: clang/include/clang/Lex/Preprocessor.h:2379

void RegisterBuiltinPragmas()

Description

Install the standard preprocessor pragmas: # pragma GCC poison/system_header/dependency and # pragma once.

Declared at: clang/include/clang/Lex/Preprocessor.h:2376

void RemovePragmaHandler(
    clang::PragmaHandler* Handler)

Declared at: clang/include/clang/Lex/Preprocessor.h:1389

Parameters

clang::PragmaHandler* Handler

void RemovePragmaHandler(
    llvm::StringRef Namespace,
    clang::PragmaHandler* Handler)

Description

Remove the specific pragma handler from this preprocessor. If \p Namespace is non-null, then it should be the namespace that\p Handler was added to. It is an error to remove a handler that has not been registered.

Declared at: clang/include/clang/Lex/Preprocessor.h:1388

Parameters

llvm::StringRef Namespace
clang::PragmaHandler* Handler

void RemoveTopOfLexerStack()

Description

Pop the current lexer/macro exp off the top of the lexer stack. This should only be used in situations where the current state of the top-of-stack lexer is known.

Declared at: clang/include/clang/Lex/Preprocessor.h:1545

void ReplaceLastTokenWithAnnotation(
    const clang::Token& Tok)

Description

Replace the last token with an annotation token. Like AnnotateCachedTokens(), this routine replaces an already-parsed (and resolved) token with an annotation token. However, this routine only replaces the last token with the annotation token; it does not affect any other cached tokens. This function has no effect if backtracking is not enabled.

Declared at: clang/include/clang/Lex/Preprocessor.h:1739

Parameters

const clang::Token& Tok

void ReplacePreviousCachedToken(
    ArrayRef<clang::Token> NewToks)

Description

Replace token in `CachedLexPos - 1` in CachedTokens by the tokens in \p NewToks. Useful when a token needs to be split in smaller ones and CachedTokens most recent token must to be updated to reflect that.

Declared at: clang/include/clang/Lex/Preprocessor.h:1729

Parameters

ArrayRef<clang::Token> NewToks

void RevertCachedTokens(unsigned int N)

Description

When backtracking is enabled and tokens are cached, this allows to revert a specific number of tokens. Note that the number of tokens being reverted should be up to the last backtrack position, not more.

Declared at: clang/include/clang/Lex/Preprocessor.h:1669

Parameters

unsigned int N

bool SawDateOrTime() const

Description

Returns true if the preprocessor has seen a use of __DATE__ or __TIME__ in the file so far.

Declared at: clang/include/clang/Lex/Preprocessor.h:2165

bool SetCodeCompletionPoint(
    const clang::FileEntry* File,
    unsigned int Line,
    unsigned int Column)

Description

Specify the point at which code-completion will be performed.

Declared at: clang/include/clang/Lex/Preprocessor.h:1789

Parameters

const clang::FileEntry* File
the file in which code completion should occur. If this file is included multiple times, code-completion will perform completion the first time it is included. If NULL, this function clears out the code-completion point.
unsigned int Line
the line at which code completion should occur (1-based).
unsigned int Column
the column at which code completion should occur (1-based).

Returns

true if an error occurred, false otherwise.

void SetCommentRetentionState(
    bool KeepComments,
    bool KeepMacroComments)

Description

Control whether the preprocessor retains comments in output.

Declared at: clang/include/clang/Lex/Preprocessor.h:1109

Parameters

bool KeepComments
bool KeepMacroComments

void SetMacroExpansionOnlyInDirectives()

Description

Disables macro expansion everywhere except for preprocessor directives.

Declared at: clang/include/clang/Lex/Preprocessor.h:1644

void SetPoisonReason(clang::IdentifierInfo* II,
                     unsigned int DiagID)

Description

Specifies the reason for poisoning an identifier. If that identifier is accessed while poisoned, then this reason will be used instead of the default "poisoned" diagnostic.

Declared at: clang/include/clang/Lex/Preprocessor.h:2085

Parameters

clang::IdentifierInfo* II
unsigned int DiagID

void SetSuppressIncludeNotFoundError(
    bool Suppress)

Declared at: clang/include/clang/Lex/Preprocessor.h:1119

Parameters

bool Suppress

void SkipExcludedConditionalBlock(
    clang::SourceLocation HashTokenLoc,
    clang::SourceLocation IfTokenLoc,
    bool FoundNonSkipPortion,
    bool FoundElse,
    clang::SourceLocation ElseLoc =
        clang::SourceLocation())

Description

We just read a # if or related directive and decided that the subsequent tokens are in the # if'd out portion of the file. Lex the rest of the file, until we see an # endif. If \p FoundNonSkipPortion is true, then we have already emitted code for part of this # if directive, so # else/ # elif blocks should never be entered. If\p FoundElse is false, then # else directives are ok, if not, then we have already seen one so a # else directive is a duplicate. When this returns, the caller can lex the first valid token.

Declared at: clang/include/clang/Lex/Preprocessor.h:2336

Parameters

clang::SourceLocation HashTokenLoc
clang::SourceLocation IfTokenLoc
bool FoundNonSkipPortion
bool FoundElse
clang::SourceLocation ElseLoc = clang::SourceLocation()

void SkipTokensWhileUsingPCH()

Description

Skip tokens until after the #include of the through header or until after a #pragma hdrstop.

Declared at: clang/include/clang/Lex/Preprocessor.h:1479

clang::SourceLocation SplitToken(
    clang::SourceLocation TokLoc,
    unsigned int Length)

Description

Split the first Length characters out of the token starting at TokLoc and return a location pointing to the split token. Re-lexing from the split token will return the split token rather than the original.

Declared at: clang/include/clang/Lex/Preprocessor.h:1993

Parameters

clang::SourceLocation TokLoc
unsigned int Length

void SuggestTypoedDirective(
    const clang::Token& Tok,
    llvm::StringRef Directive) const

Description

Provide a suggestion for a typoed directive. If there is no typo, then just skip suggesting.

Declared at: clang/include/clang/Lex/Preprocessor.h:2326

Parameters

const clang::Token& Tok
- Token that represents the directive
llvm::StringRef Directive
- String reference for the directive name

void TypoCorrectToken(const clang::Token& Tok)

Description

Update the current token to represent the provided identifier, in order to cache an action performed by typo correction.

Declared at: clang/include/clang/Lex/Preprocessor.h:1757

Parameters

const clang::Token& Tok

void addCommentHandler(
    clang::CommentHandler* Handler)

Description

Add the specified comment handler to the preprocessor.

Declared at: clang/include/clang/Lex/Preprocessor.h:1402

Parameters

clang::CommentHandler* Handler

void addFinalLoc(
    const clang::IdentifierInfo* II,
    clang::SourceLocation AnnotationLoc)

Declared at: clang/include/clang/Lex/Preprocessor.h:2646

Parameters

const clang::IdentifierInfo* II
clang::SourceLocation AnnotationLoc

void addMacroDeprecationMsg(
    const clang::IdentifierInfo* II,
    std::string Msg,
    clang::SourceLocation AnnotationLoc)

Declared at: clang/include/clang/Lex/Preprocessor.h:2622

Parameters

const clang::IdentifierInfo* II
std::string Msg
clang::SourceLocation AnnotationLoc

clang::ModuleMacro* addModuleMacro(
    clang::Module* Mod,
    clang::IdentifierInfo* II,
    clang::MacroInfo* Macro,
    ArrayRef<clang::ModuleMacro*> Overrides,
    bool& IsNew)

Description

Register an exported macro for a module and identifier.

Declared at: clang/include/clang/Lex/Preprocessor.h:1299

Parameters

clang::Module* Mod
clang::IdentifierInfo* II
clang::MacroInfo* Macro
ArrayRef<clang::ModuleMacro*> Overrides
bool& IsNew

void addPPCallbacks(
    std::unique_ptr<PPCallbacks> C)

Declared at: clang/include/clang/Lex/Preprocessor.h:1167

Parameters

std::unique_ptr<PPCallbacks> C

void addRestrictExpansionMsg(
    const clang::IdentifierInfo* II,
    std::string Msg,
    clang::SourceLocation AnnotationLoc)

Declared at: clang/include/clang/Lex/Preprocessor.h:2634

Parameters

const clang::IdentifierInfo* II
std::string Msg
clang::SourceLocation AnnotationLoc

bool alreadyIncluded(
    const clang::FileEntry* File) const

Description

Return true if this header has already been included.

Declared at: clang/include/clang/Lex/Preprocessor.h:1344

Parameters

const clang::FileEntry* File

clang::DefMacroDirective* appendDefMacroDirective(
    clang::IdentifierInfo* II,
    clang::MacroInfo* MI)

Declared at: clang/include/clang/Lex/Preprocessor.h:1289

Parameters

clang::IdentifierInfo* II
clang::MacroInfo* MI

clang::DefMacroDirective* appendDefMacroDirective(
    clang::IdentifierInfo* II,
    clang::MacroInfo* MI,
    clang::SourceLocation Loc)

Declared at: clang/include/clang/Lex/Preprocessor.h:1283

Parameters

clang::IdentifierInfo* II
clang::MacroInfo* MI
clang::SourceLocation Loc

void appendMacroDirective(
    clang::IdentifierInfo* II,
    clang::MacroDirective* MD)

Description

Add a directive to the macro directive history for this identifier.

Declared at: clang/include/clang/Lex/Preprocessor.h:1282

Parameters

clang::IdentifierInfo* II
clang::MacroDirective* MD

clang::Token* cacheMacroExpandedTokens(
    clang::TokenLexer* tokLexer,
    ArrayRef<clang::Token> tokens)

Description

Works like a stack; a TokenLexer adds the macro expanded tokens that is going to lex in the cache and when it finishes the tokens are removed from the end of the cache.

Declared at: clang/include/clang/Lex/Preprocessor.h:2391

Parameters

clang::TokenLexer* tokLexer
ArrayRef<clang::Token> tokens

static bool checkModuleIsAvailable(
    const clang::LangOptions& LangOpts,
    const clang::TargetInfo& TargetInfo,
    clang::DiagnosticsEngine& Diags,
    clang::Module* M)

Description

Check that the given module is available, producing a diagnostic if not.

Declared at: clang/include/clang/Lex/Preprocessor.h:2525

Parameters

const clang::LangOptions& LangOpts
const clang::TargetInfo& TargetInfo
clang::DiagnosticsEngine& Diags
clang::Module* M

Returns

\c true if the check failed (because the module is not available).\c false if the module appears to be usable.

void clearCodeCompletionHandler()

Description

Clear out the code completion handler.

Declared at: clang/include/clang/Lex/Preprocessor.h:1420

void createPreprocessingRecord()

Description

Create a new preprocessing record, which will keep track of all macro expansions, macro definitions, etc.

Declared at: clang/include/clang/Lex/Preprocessor.h:1460

bool creatingPCHWithPragmaHdrStop()

Description

True if creating a PCH with a #pragma hdrstop.

Declared at: clang/include/clang/Lex/Preprocessor.h:1472

bool creatingPCHWithThroughHeader()

Description

True if creating a PCH with a through header.

Declared at: clang/include/clang/Lex/Preprocessor.h:1466

void diagnoseMissingHeaderInUmbrellaDir(
    const clang::Module& Mod)

Declared at: clang/include/clang/Lex/Preprocessor.h:2115

Parameters

const clang::Module& Mod

void dumpMacroInfo(
    const clang::IdentifierInfo* II)

Declared at: clang/include/clang/Lex/Preprocessor.h:2039

Parameters

const clang::IdentifierInfo* II

void emitFinalMacroWarning(
    const clang::Token& Identifier,
    bool IsUndef) const

Declared at: clang/include/clang/Lex/Preprocessor.h:2675

Parameters

const clang::Token& Identifier
bool IsUndef

void emitMacroDeprecationWarning(
    const clang::Token& Identifier) const

Declared at: clang/include/clang/Lex/Preprocessor.h:2673

Parameters

const clang::Token& Identifier

void emitMacroExpansionWarnings(
    const clang::Token& Identifier) const

Declared at: clang/include/clang/Lex/Preprocessor.h:2659

Parameters

const clang::Token& Identifier

void emitRestrictExpansionWarning(
    const clang::Token& Identifier) const

Declared at: clang/include/clang/Lex/Preprocessor.h:2674

Parameters

const clang::Token& Identifier

void enableIncrementalProcessing(
    bool value = true)

Description

Enables the incremental processing

Declared at: clang/include/clang/Lex/Preprocessor.h:1771

Parameters

bool value = true

const clang::TargetInfo* getAuxTargetInfo() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1071

ArrayRef<
    clang::Preprocessor::BuildingSubmoduleInfo>
getBuildingSubmodules() const

Description

Get the list of submodules that we're currently building.

Declared at: clang/include/clang/Lex/Preprocessor.h:1314

Builtin::Context& getBuiltinInfo()

Declared at: clang/include/clang/Lex/Preprocessor.h:1079

clang::SourceLocation getCodeCompletionFileLoc()
    const

Description

Returns the start location of the file of code-completion point. Returns an invalid location if code-completion is not enabled or the file containing the code-completion point has not been lexed yet.

Declared at: clang/include/clang/Lex/Preprocessor.h:1805

llvm::StringRef getCodeCompletionFilter()

Description

Get the code completion token for filtering purposes.

Declared at: clang/include/clang/Lex/Preprocessor.h:1448

clang::CodeCompletionHandler*
getCodeCompletionHandler() const

Description

Retrieve the current code-completion handler.

Declared at: clang/include/clang/Lex/Preprocessor.h:1415

clang::SourceLocation getCodeCompletionLoc() const

Description

Returns the location of the code-completion point. Returns an invalid location if code-completion is not enabled or the file containing the code-completion point has not been lexed yet.

Declared at: clang/include/clang/Lex/Preprocessor.h:1799

clang::SourceRange getCodeCompletionTokenRange()
    const

Declared at: clang/include/clang/Lex/Preprocessor.h:1443

bool getCommentRetentionState() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1114

unsigned int getCounterValue() const

Declared at: clang/include/clang/Lex/Preprocessor.h:2168

const char* getCurLexerEndPos()

Declared at: clang/include/clang/Lex/Preprocessor.h:2114

LangOptions::FPEvalMethodKind
getCurrentFPEvalMethod() const

Declared at: clang/include/clang/Lex/Preprocessor.h:2171

clang::PreprocessorLexer* getCurrentFileLexer()
    const

Description

Return the current file lexer being lexed from. Note that this ignores any potentially active macro expansions and _Pragma expansions going on at the time.

Declared at: clang/include/clang/Lex/Preprocessor.h:1152

clang::PreprocessorLexer* getCurrentLexer() const

Description

Return the current lexer being lexed from. Note that this ignores any potentially active macro expansions and _Pragma expansions going on at the time.

Declared at: clang/include/clang/Lex/Preprocessor.h:1146

clang::Module* getCurrentLexerSubmodule() const

Description

Return the submodule owning the file being lexed. This may not be the current module if we have changed modules since entering the file.

Declared at: clang/include/clang/Lex/Preprocessor.h:1156

clang::Module* getCurrentModule()

Description

Retrieves the module that we're currently building, if any.

Declared at: clang/include/clang/Lex/Preprocessor.h:2212

clang::DiagnosticsEngine& getDiagnostics() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1066

clang::EmptylineHandler* getEmptylineHandler()
    const

Declared at: clang/include/clang/Lex/Preprocessor.h:1399

clang::ExternalPreprocessorSource*
getExternalSource() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1086

clang::FileManager& getFileManager() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1072

clang::HeaderSearch& getHeaderSearchInfo() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1074

const clang::FileEntry*
getHeaderToIncludeForDiagnostics(
    clang::SourceLocation IncLoc,
    clang::SourceLocation MLoc)

Description

We want to produce a diagnostic at location IncLoc concerning an unreachable effect at location MLoc (eg, where a desired entity was declared or defined). Determine whether the right way to make MLoc reachable is by #include, and if so, what header should be included. This is not necessarily fast, and might load unexpected module maps, so should only be called by code that intends to produce an error.

Declared at: clang/include/clang/Lex/Preprocessor.h:2549

Parameters

clang::SourceLocation IncLoc
The location at which the missing effect was detected.
clang::SourceLocation MLoc
A location within an unimported module at which the desired effect occurred.

Returns

A file that can be #included to provide the desired effect. Null if no such file could be determined or if a #include is not appropriate (eg, if a module should be imported instead).

clang::IdentifierInfo* getIdentifierInfo(
    llvm::StringRef Name) const

Description

Return information about the specified preprocessor identifier token.

Declared at: clang/include/clang/Lex/Preprocessor.h:1370

Parameters

llvm::StringRef Name

clang::IdentifierTable& getIdentifierTable()

Declared at: clang/include/clang/Lex/Preprocessor.h:1076

const clang::IdentifierTable& getIdentifierTable()
    const

Declared at: clang/include/clang/Lex/Preprocessor.h:1077

llvm::StringRef getImmediateMacroName(
    clang::SourceLocation Loc)

Description

Retrieve the name of the immediate macro expansion. This routine starts from a source location, and finds the name of the macro responsible for its immediate expansion. It looks through any intervening macro argument expansions to compute this. It returns a StringRef that refers to the SourceManager-owned buffer of the source where that macro name is spelled. Thus, the result shouldn't out-live the SourceManager.

Declared at: clang/include/clang/Lex/Preprocessor.h:1977

Parameters

clang::SourceLocation Loc

std::pair<ConstSearchDirIterator,
          const FileEntry*>
getIncludeNextStart(
    const clang::Token& IncludeNextTok) const

Description

Get the directory and file from which to start # include_next lookup.

Declared at: clang/include/clang/Lex/Preprocessor.h:2372

Parameters

const clang::Token& IncludeNextTok

const clang::Preprocessor::IncludedFilesSet&
getIncludedFiles() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1350

clang::Preprocessor::IncludedFilesSet&
getIncludedFiles()

Description

Get the set of included files.

Declared at: clang/include/clang/Lex/Preprocessor.h:1349

const clang::LangOptions& getLangOpts() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1069

clang::SourceLocation getLastCachedTokenLocation()
    const

Description

Get the location of the last cached token, suitable for setting the end location of an annotation token.

Declared at: clang/include/clang/Lex/Preprocessor.h:1715

LangOptions::FPEvalMethodKind
getLastFPEvalMethod() const

Declared at: clang/include/clang/Lex/Preprocessor.h:2186

clang::SourceLocation
getLastFPEvalPragmaLocation() const

Declared at: clang/include/clang/Lex/Preprocessor.h:2182

llvm::StringRef getLastMacroWithSpelling(
    clang::SourceLocation Loc,
    ArrayRef<clang::TokenValue> Tokens) const

Description

Return the name of the macro defined before \p Loc that has spelling \p Tokens. If there are multiple macros with same spelling, return the last one defined.

Declared at: clang/include/clang/Lex/Preprocessor.h:1355

Parameters

clang::SourceLocation Loc
ArrayRef<clang::TokenValue> Tokens

ArrayRef<clang::ModuleMacro*> getLeafModuleMacros(
    const clang::IdentifierInfo* II) const

Description

Get the list of leaf (non-overridden) module macros for a name.

Declared at: clang/include/clang/Lex/Preprocessor.h:1304

Parameters

const clang::IdentifierInfo* II

clang::SourceLocation getLocForEndOfToken(
    clang::SourceLocation Loc,
    unsigned int Offset = 0)

Description

Computes the source location just past the end of the token at this source location. This routine can be used to produce a source location that points just past the end of the token referenced by \p Loc, and is generally used when a diagnostic needs to point just after a token where it expected something different that it received. If the returned source location would not be meaningful (e.g., if it points into a macro), this routine returns an invalid source location.

Declared at: clang/include/clang/Lex/Preprocessor.h:2010

Parameters

clang::SourceLocation Loc
unsigned int Offset = 0
an offset from the end of the token, where the source location should refer to. The default offset (0) produces a source location pointing just past the end of the token; an offset of 1 produces a source location pointing to the last character in the token, etc.

clang::MacroDirective* getLocalMacroDirective(
    const clang::IdentifierInfo* II) const

Description

Given an identifier, return its latest non-imported MacroDirective if it is # define'd and not # undef'd, or null if it isn't # define'd.

Declared at: clang/include/clang/Lex/Preprocessor.h:1251

Parameters

const clang::IdentifierInfo* II

clang::MacroDirective*
getLocalMacroDirectiveHistory(
    const clang::IdentifierInfo* II) const

Description

Given an identifier, return the latest non-imported macro directive for that identifier. One can iterate over all previous macro directives from the most recent one.

Declared at: clang/include/clang/Lex/Preprocessor.h:1279

Parameters

const clang::IdentifierInfo* II

const clang::Preprocessor::MacroAnnotations&
getMacroAnnotations(
    const clang::IdentifierInfo* II) const

Declared at: clang/include/clang/Lex/Preprocessor.h:2655

Parameters

const clang::IdentifierInfo* II

clang::MacroDefinition getMacroDefinition(
    const clang::IdentifierInfo* II)

Declared at: clang/include/clang/Lex/Preprocessor.h:1221

Parameters

const clang::IdentifierInfo* II

clang::MacroDefinition getMacroDefinitionAtLoc(
    const clang::IdentifierInfo* II,
    clang::SourceLocation Loc)

Declared at: clang/include/clang/Lex/Preprocessor.h:1234

Parameters

const clang::IdentifierInfo* II
clang::SourceLocation Loc

clang::MacroInfo* getMacroInfo(
    const clang::IdentifierInfo* II)

Declared at: clang/include/clang/Lex/Preprocessor.h:1266

Parameters

const clang::IdentifierInfo* II

const clang::MacroInfo* getMacroInfo(
    const clang::IdentifierInfo* II) const

Declared at: clang/include/clang/Lex/Preprocessor.h:1262

Parameters

const clang::IdentifierInfo* II

unsigned int getMaxTokens() const

Description

Get the max number of tokens before issuing a -Wmax-tokens warning.

Declared at: clang/include/clang/Lex/Preprocessor.h:1179

clang::SourceLocation getMaxTokensOverrideLoc()
    const

Declared at: clang/include/clang/Lex/Preprocessor.h:1186

clang::Module* getModuleForLocation(
    clang::SourceLocation Loc)

Description

Find the module that owns the source or header file that\p Loc points to. If the location is in a file that was included into a module, or is outside any module, returns nullptr.

Declared at: clang/include/clang/Lex/Preprocessor.h:2533

Parameters

clang::SourceLocation Loc

clang::SourceLocation getModuleImportLoc(
    clang::Module* M) const

Declared at: clang/include/clang/Lex/Preprocessor.h:1584

Parameters

clang::Module* M

clang::ModuleLoader& getModuleLoader() const

Description

Retrieve the module loader associated with this preprocessor.

Declared at: clang/include/clang/Lex/Preprocessor.h:1091

clang::ModuleMacro* getModuleMacro(
    clang::Module* Mod,
    const clang::IdentifierInfo* II)

Declared at: clang/include/clang/Lex/Preprocessor.h:1301

Parameters

clang::Module* Mod
const clang::IdentifierInfo* II

unsigned int getNumDirectives() const

Description

Retrieve the number of Directives that have been processed by the Preprocessor.

Declared at: clang/include/clang/Lex/Preprocessor.h:1099

clang::PPCallbacks* getPPCallbacks() const

Description

\ { Accessors for preprocessor callbacks. Note that this class takes ownership of any PPCallbacks object given to it.

Declared at: clang/include/clang/Lex/Preprocessor.h:1166

std::pair<IdentifierInfo*, SourceLocation>
getPragmaARCCFCodeAuditedInfo() const

Description

The location of the currently-active # pragma clang arc_cf_code_audited begin. Returns an invalid location if there is no such pragma active.

Declared at: clang/include/clang/Lex/Preprocessor.h:1826

clang::SourceLocation getPragmaAssumeNonNullLoc()
    const

Description

The location of the currently-active # pragma clang assume_nonnull begin. Returns an invalid location if there is no such pragma active.

Declared at: clang/include/clang/Lex/Preprocessor.h:1841

bool getPragmasEnabled() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1117

ArrayRef<clang::PPConditionalInfo>
getPreambleConditionalStack() const

Declared at: clang/include/clang/Lex/Preprocessor.h:2560

clang::SourceLocation
getPreambleRecordedPragmaAssumeNonNullLoc() const

Description

Get the location of the recorded unterminated # pragma clang assume_nonnull begin in the preamble, if one exists. Returns an invalid location if the premable did not end with such a pragma active or if there is no recorded preamble.

Declared at: clang/include/clang/Lex/Preprocessor.h:1856

llvm::Optional<PreambleSkipInfo>
getPreambleSkipInfo() const

Declared at: clang/include/clang/Lex/Preprocessor.h:2575

const std::string& getPredefines() const

Description

Get the predefines for this processor. Used by some third-party tools to inspect and add predefines (see https://github.com/llvm/llvm-project/issues/57483).

Declared at: clang/include/clang/Lex/Preprocessor.h:1361

clang::FileID getPredefinesFileID() const

Description

Returns the FileID for the preprocessor predefines.

Declared at: clang/include/clang/Lex/Preprocessor.h:1159

clang::PreprocessingRecord*
getPreprocessingRecord() const

Description

Retrieve the preprocessing record, or NULL if there is no preprocessing record.

Declared at: clang/include/clang/Lex/Preprocessor.h:1456

llvm::BumpPtrAllocator& getPreprocessorAllocator()

Declared at: clang/include/clang/Lex/Preprocessor.h:1080

clang::PreprocessorOptions& getPreprocessorOpts()
    const

Description

Retrieve the preprocessor options used to initialize this preprocessor.

Declared at: clang/include/clang/Lex/Preprocessor.h:1064

bool getRawToken(clang::SourceLocation Loc,
                 clang::Token& Result,
                 bool IgnoreWhiteSpace = false)

Description

Relex the token at the specified location.

Declared at: clang/include/clang/Lex/Preprocessor.h:1946

Parameters

clang::SourceLocation Loc
clang::Token& Result
bool IgnoreWhiteSpace = false

Returns

true if there was a failure, false on success.

clang::SelectorTable& getSelectorTable()

Declared at: clang/include/clang/Lex/Preprocessor.h:1078

clang::SourceManager& getSourceManager() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1073

unsigned int getSpelling(
    const clang::Token& Tok,
    const char*& Buffer,
    bool* Invalid = nullptr) const

Description

Get the spelling of a token into a preallocated buffer, instead of as an std::string. The caller is required to allocate enough space for the token, which is guaranteed to be at least Tok.getLength() bytes long. The length of the actual result is returned. Note that this method may do two possible things: it may either fill in the buffer specified with characters, or it may *change the input pointer* to point to a constant buffer with the data already in it (avoiding a copy). The caller is not allowed to modify the returned buffer pointer if an internal buffer is returned.

Declared at: clang/include/clang/Lex/Preprocessor.h:1931

Parameters

const clang::Token& Tok
const char*& Buffer
bool* Invalid = nullptr

llvm::StringRef getSpelling(
    const clang::Token& Tok,
    SmallVectorImpl<char>& Buffer,
    bool* Invalid = nullptr) const

Description

Get the spelling of a token into a SmallVector. Note that the returned StringRef may not point to the supplied buffer if a copy can be avoided.

Declared at: clang/include/clang/Lex/Preprocessor.h:1940

Parameters

const clang::Token& Tok
SmallVectorImpl<char>& Buffer
bool* Invalid = nullptr

std::string getSpelling(
    const clang::Token& Tok,
    bool* Invalid = nullptr) const

Description

Return the 'spelling' of the Tok token. The spelling of a token is the characters used to represent the token in the source file after trigraph expansion and escaped-newline folding. In particular, this wants to get the true, uncanonicalized, spelling of things like digraphs, UCNs, etc.

Declared at: clang/include/clang/Lex/Preprocessor.h:1915

Parameters

const clang::Token& Tok
bool* Invalid = nullptr
If non-null, will be set \c true if an error occurs.

llvm::StringRef getSpelling(
    clang::SourceLocation loc,
    SmallVectorImpl<char>& buffer,
    bool* invalid = nullptr) const

Description

Return the 'spelling' of the token at the given location; does not go up to the spelling location or down to the expansion location.

Declared at: clang/include/clang/Lex/Preprocessor.h:1901

Parameters

clang::SourceLocation loc
SmallVectorImpl<char>& buffer
A buffer which will be used only if the token requires "cleaning", e.g. if it contains trigraphs or escaped newlines
bool* invalid = nullptr
If non-null, will be set \c true if an error occurs.

char getSpellingOfSingleCharacterNumericConstant(
    const clang::Token& Tok,
    bool* Invalid = nullptr) const

Description

Given a Token \p Tok that is a numeric constant with length 1, return the character.

Declared at: clang/include/clang/Lex/Preprocessor.h:1954

Parameters

const clang::Token& Tok
bool* Invalid = nullptr

LangOptions::FPEvalMethodKind getTUFPEvalMethod()
    const

Declared at: clang/include/clang/Lex/Preprocessor.h:2178

const clang::TargetInfo& getTargetInfo() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1070

unsigned int getTokenCount() const

Description

Get the number of tokens processed so far.

Declared at: clang/include/clang/Lex/Preprocessor.h:1176

size_t getTotalMemory() const

Declared at: clang/include/clang/Lex/Preprocessor.h:2061

bool hadModuleLoaderFatalFailure() const

Declared at: clang/include/clang/Lex/Preprocessor.h:1093

bool hasRecordedPreamble() const

Declared at: clang/include/clang/Lex/Preprocessor.h:2556

bool isAtEndOfMacroExpansion(
    clang::SourceLocation loc,
    clang::SourceLocation* MacroEnd =
        nullptr) const

Description

Returns true if the given MacroID location points at the last token of the macro expansion.

Declared at: clang/include/clang/Lex/Preprocessor.h:2030

Parameters

clang::SourceLocation loc
clang::SourceLocation* MacroEnd = nullptr
If non-null and function returns true, it is set to end location of the macro.

bool isAtStartOfMacroExpansion(
    clang::SourceLocation loc,
    clang::SourceLocation* MacroBegin =
        nullptr) const

Description

Returns true if the given MacroID location points at the first token of the macro expansion.

Declared at: clang/include/clang/Lex/Preprocessor.h:2019

Parameters

clang::SourceLocation loc
clang::SourceLocation* MacroBegin = nullptr
If non-null and function returns true, it is set to begin location of the macro.

bool isBacktrackEnabled() const

Description

True if EnableBacktrackAtThisPos() was called and caching of tokens is on.

Declared at: clang/include/clang/Lex/Preprocessor.h:1571

bool isCodeCompletionEnabled() const

Description

Determine if we are performing code completion.

Declared at: clang/include/clang/Lex/Preprocessor.h:1793

bool isCodeCompletionReached() const

Description

Returns true if code-completion is enabled and we have hit the code-completion point.

Declared at: clang/include/clang/Lex/Preprocessor.h:1811

bool isCurrentLexer(
    const clang::PreprocessorLexer* L) const

Description

Return true if we are lexing directly from the specified lexer.

Declared at: clang/include/clang/Lex/Preprocessor.h:1138

Parameters

const clang::PreprocessorLexer* L

bool isInPrimaryFile() const

Description

Return true if we're in the top-level file, not in a # include.

Declared at: clang/include/clang/Lex/Preprocessor.h:2241

bool isIncrementalProcessingEnabled() const

Description

Returns true if incremental processing is enabled

Declared at: clang/include/clang/Lex/Preprocessor.h:1768

bool isMacroDefined(
    const clang::IdentifierInfo* II)

Declared at: clang/include/clang/Lex/Preprocessor.h:1200

Parameters

const clang::IdentifierInfo* II

bool isMacroDefined(llvm::StringRef Id)

Declared at: clang/include/clang/Lex/Preprocessor.h:1197

Parameters

llvm::StringRef Id

bool isMacroDefinedInLocalModule(
    const clang::IdentifierInfo* II,
    clang::Module* M)

Description

Determine whether II is defined as a macro within the module M, if that is a module that we've already preprocessed. Does not check for macros imported into M.

Declared at: clang/include/clang/Lex/Preprocessor.h:1208

Parameters

const clang::IdentifierInfo* II
clang::Module* M

bool isNextPPTokenLParen()

Description

Determine whether the next preprocessor token to be lexed is a '('. If so, consume the token and return true, if not, this method should have no observable side-effect on the lexed tokens.

Declared at: clang/include/clang/Lex/Preprocessor.h:2399

bool isPCHThroughHeader(
    const clang::FileEntry* FE)

Description

Returns true if the FileEntry is the PCH through header.

Declared at: clang/include/clang/Lex/Preprocessor.h:1463

Parameters

const clang::FileEntry* FE

bool isParsingIfOrElifDirective() const

Description

True if we are currently preprocessing a #if or #elif directive

Declared at: clang/include/clang/Lex/Preprocessor.h:1104

bool isPreprocessedOutput() const

Description

Returns true if the preprocessor is responsible for generating output, false if it is producing tokens to be consumed by Parse and Sema.

Declared at: clang/include/clang/Lex/Preprocessor.h:1135

bool isRecordingPreamble() const

Declared at: clang/include/clang/Lex/Preprocessor.h:2552

clang::Preprocessor::macro_iterator macro_begin(
    bool IncludeExternalMacros = true) const

Declared at: clang/include/clang/Lex/Preprocessor.h:1324

Parameters

bool IncludeExternalMacros = true

clang::Preprocessor::macro_iterator macro_end(
    bool IncludeExternalMacros = true) const

Declared at: clang/include/clang/Lex/Preprocessor.h:1325

Parameters

bool IncludeExternalMacros = true

llvm::iterator_range<macro_iterator> macros(
    bool IncludeExternalMacros = true) const

Declared at: clang/include/clang/Lex/Preprocessor.h:1328

Parameters

bool IncludeExternalMacros = true

void makeModuleVisible(clang::Module* M,
                       clang::SourceLocation Loc)

Declared at: clang/include/clang/Lex/Preprocessor.h:1582

Parameters

clang::Module* M
clang::SourceLocation Loc

bool markIncluded(const clang::FileEntry* File)

Description

Mark the file as included. Returns true if this is the first time the file was included.

Declared at: clang/include/clang/Lex/Preprocessor.h:1338

Parameters

const clang::FileEntry* File

void markMacroAsUsed(clang::MacroInfo* MI)

Description

A macro is used, update information about macros that need unused warnings.

Declared at: clang/include/clang/Lex/Preprocessor.h:2620

Parameters

clang::MacroInfo* MI

bool mightHavePendingAnnotationTokens()

Description

Determine whether it's possible for a future call to Lex to produce an annotation token created by a previous call to EnterAnnotationToken.

Declared at: clang/include/clang/Lex/Preprocessor.h:1751

bool needModuleMacros() const

Description

Determine whether we need to create module macros for #defines in the current context.

Declared at: clang/include/clang/Lex/Preprocessor.h:2278

void overrideMaxTokens(unsigned int Value,
                       clang::SourceLocation Loc)

Declared at: clang/include/clang/Lex/Preprocessor.h:1181

Parameters

unsigned int Value
clang::SourceLocation Loc

bool parseSimpleIntegerLiteral(clang::Token& Tok,
                               uint64_t& Value)

Description

Parses a simple integer literal to get its numeric value. Floating point literals and user defined literals are rejected. Used primarily to handle pragmas that accept integer arguments.

Declared at: clang/include/clang/Lex/Preprocessor.h:1641

Parameters

clang::Token& Tok
uint64_t& Value

static void processPathForFileMacro(
    SmallVectorImpl<char>& Path,
    const clang::LangOptions& LangOpts,
    const clang::TargetInfo& TI)

Declared at: clang/include/clang/Lex/Preprocessor.h:2668

Parameters

SmallVectorImpl<char>& Path
const clang::LangOptions& LangOpts
const clang::TargetInfo& TI

void recomputeCurLexerKind()

Description

Recompute the current lexer kind based on the CurLexer/ CurTokenLexer pointers.

Declared at: clang/include/clang/Lex/Preprocessor.h:1765

void removeCachedMacroExpandedTokensOfLastLexer()

Declared at: clang/include/clang/Lex/Preprocessor.h:2394

void removeCommentHandler(
    clang::CommentHandler* Handler)

Description

Remove the specified comment handler. It is an error to remove a handler that has not been registered.

Declared at: clang/include/clang/Lex/Preprocessor.h:1407

Parameters

clang::CommentHandler* Handler

void replayPreambleConditionalStack()

Description

After processing predefined file, initialize the conditional stack from the preamble.

Declared at: clang/include/clang/Lex/Preprocessor.h:2582

void setCodeCompletionHandler(
    clang::CodeCompletionHandler& Handler)

Description

Set the code completion handler to the given object.

Declared at: clang/include/clang/Lex/Preprocessor.h:1410

Parameters

clang::CodeCompletionHandler& Handler

void setCodeCompletionIdentifierInfo(
    clang::IdentifierInfo* Filter)

Description

Set the code completion token for filtering purposes.

Declared at: clang/include/clang/Lex/Preprocessor.h:1433

Parameters

clang::IdentifierInfo* Filter

void setCodeCompletionReached()

Description

Note that we hit the code-completion point.

Declared at: clang/include/clang/Lex/Preprocessor.h:1814

void setCodeCompletionTokenRange(
    const clang::SourceLocation Start,
    const clang::SourceLocation End)

Description

Set the code completion token range for detecting replacement range later on.

Declared at: clang/include/clang/Lex/Preprocessor.h:1439

Parameters

const clang::SourceLocation Start
const clang::SourceLocation End

void setCounterValue(unsigned int V)

Declared at: clang/include/clang/Lex/Preprocessor.h:2169

Parameters

unsigned int V

void setCurrentFPEvalMethod(
    clang::SourceLocation PragmaLoc,
    LangOptions::FPEvalMethodKind Val)

Declared at: clang/include/clang/Lex/Preprocessor.h:2194

Parameters

clang::SourceLocation PragmaLoc
LangOptions::FPEvalMethodKind Val

void setDiagnostics(clang::DiagnosticsEngine& D)

Declared at: clang/include/clang/Lex/Preprocessor.h:1067

Parameters

clang::DiagnosticsEngine& D

void setEmptylineHandler(
    clang::EmptylineHandler* Handler)

Description

Set empty line handler.

Declared at: clang/include/clang/Lex/Preprocessor.h:1397

Parameters

clang::EmptylineHandler* Handler

void setExternalSource(
    clang::ExternalPreprocessorSource* Source)

Declared at: clang/include/clang/Lex/Preprocessor.h:1082

Parameters

clang::ExternalPreprocessorSource* Source

void setLastFPEvalMethod(
    LangOptions::FPEvalMethodKind Val)

Declared at: clang/include/clang/Lex/Preprocessor.h:2190

Parameters

LangOptions::FPEvalMethodKind Val

void setLoadedMacroDirective(
    clang::IdentifierInfo* II,
    clang::MacroDirective* ED,
    clang::MacroDirective* MD)

Description

Set a MacroDirective that was loaded from a PCH file.

Declared at: clang/include/clang/Lex/Preprocessor.h:1295

Parameters

clang::IdentifierInfo* II
clang::MacroDirective* ED
clang::MacroDirective* MD

void setMainFileDir(
    const clang::DirectoryEntry* Dir)

Description

Set the directory in which the main file should be considered to have been found, if it is not a real file.

Declared at: clang/include/clang/Lex/Preprocessor.h:1868

Parameters

const clang::DirectoryEntry* Dir

void setPCHThroughHeaderFileID(clang::FileID FID)

Description

Set the FileID for the PCH through header.

Declared at: clang/include/clang/Lex/Preprocessor.h:2430

Parameters

clang::FileID FID

void setPragmaARCCFCodeAuditedInfo(
    clang::IdentifierInfo* Ident,
    clang::SourceLocation Loc)

Description

Set the location of the currently-active # pragma clang arc_cf_code_audited begin. An invalid location ends the pragma.

Declared at: clang/include/clang/Lex/Preprocessor.h:1832

Parameters

clang::IdentifierInfo* Ident
clang::SourceLocation Loc

void setPragmaAssumeNonNullLoc(
    clang::SourceLocation Loc)

Description

Set the location of the currently-active # pragma clang assume_nonnull begin. An invalid location ends the pragma.

Declared at: clang/include/clang/Lex/Preprocessor.h:1847

Parameters

clang::SourceLocation Loc

void setPragmasEnabled(bool Enabled)

Declared at: clang/include/clang/Lex/Preprocessor.h:1116

Parameters

bool Enabled

void setPreambleRecordedPragmaAssumeNonNullLoc(
    clang::SourceLocation Loc)

Description

Record the location of the unterminated # pragma clang assume_nonnull begin in the preamble.

Declared at: clang/include/clang/Lex/Preprocessor.h:1862

Parameters

clang::SourceLocation Loc

void setPredefines(std::string P)

Description

Set the predefines for this Preprocessor. These predefines are automatically injected when parsing the main file.

Declared at: clang/include/clang/Lex/Preprocessor.h:1366

Parameters

std::string P

void setPredefinesFileID(clang::FileID FID)

Description

Set the FileID for the preprocessor predefines.

Declared at: clang/include/clang/Lex/Preprocessor.h:2424

Parameters

clang::FileID FID

void setPreprocessToken(bool Preprocess)

Declared at: clang/include/clang/Lex/Preprocessor.h:1195

Parameters

bool Preprocess

void setPreprocessedOutput(
    bool IsPreprocessedOutput)

Description

Sets whether the preprocessor is responsible for producing output or if it is producing tokens to be consumed by Parse and Sema.

Declared at: clang/include/clang/Lex/Preprocessor.h:1129

Parameters

bool IsPreprocessedOutput

void setRecordedPreambleConditionalStack(
    ArrayRef<clang::PPConditionalInfo> s)

Declared at: clang/include/clang/Lex/Preprocessor.h:2564

Parameters

ArrayRef<clang::PPConditionalInfo> s

void setReplayablePreambleConditionalStack(
    ArrayRef<clang::PPConditionalInfo> s,
    llvm::Optional<PreambleSkipInfo> SkipInfo)

Declared at: clang/include/clang/Lex/Preprocessor.h:2568

Parameters

ArrayRef<clang::PPConditionalInfo> s
llvm::Optional<PreambleSkipInfo> SkipInfo

void setSkipMainFilePreamble(unsigned int Bytes,
                             bool StartOfLine)

Description

Instruct the preprocessor to skip part of the main source file.

Declared at: clang/include/clang/Lex/Preprocessor.h:1878

Parameters

unsigned int Bytes
The number of bytes in the preamble to skip.
bool StartOfLine
Whether skipping these bytes puts the lexer at the start of a line.

void setTUFPEvalMethod(
    LangOptions::FPEvalMethodKind Val)

Declared at: clang/include/clang/Lex/Preprocessor.h:2205

Parameters

LangOptions::FPEvalMethodKind Val

void setTokenWatcher(llvm::unique_function<
                     void(const clang::Token&)> F)

Description

Register a function that would be called on each token in the final expanded token stream. This also reports annotation tokens produced by the parser.

Declared at: clang/include/clang/Lex/Preprocessor.h:1191

Parameters

llvm::unique_function<void(const clang::Token&)> F

void updateModuleMacroInfo(
    const clang::IdentifierInfo* II,
    clang::Preprocessor::ModuleMacroInfo& Info)

Description

Update the set of active module macros and ambiguity flag for a module macro name.

Declared at: clang/include/clang/Lex/Preprocessor.h:2282

Parameters

const clang::IdentifierInfo* II
clang::Preprocessor::ModuleMacroInfo& Info

void updateOutOfDateIdentifier(
    clang::IdentifierInfo& II) const

Declared at: clang/include/clang/Lex/Preprocessor.h:1030

Parameters

clang::IdentifierInfo& II

bool usingPCHWithPragmaHdrStop()

Description

True if using a PCH with a #pragma hdrstop.

Declared at: clang/include/clang/Lex/Preprocessor.h:1475

bool usingPCHWithThroughHeader()

Description

True if using a PCH with a through header.

Declared at: clang/include/clang/Lex/Preprocessor.h:1469

~Preprocessor()

Declared at: clang/include/clang/Lex/Preprocessor.h:1040