clang API Documentation
Engages in a tight little dance with the lexer to efficiently preprocess tokens. More...
#include <Preprocessor.h>
Classes | |
struct | DeserializedMacroInfoChain |
struct | IncludeStackInfo |
Keeps track of the stack of files currently #included, and macros currently being expanded from, not counting CurLexer/CurTokenLexer. | |
struct | MacroExpandsInfo |
struct | MacroInfoChain |
class | ResetMacroExpansionHelper |
Public Member Functions | |
Preprocessor (IntrusiveRefCntPtr< PreprocessorOptions > PPOpts, DiagnosticsEngine &diags, LangOptions &opts, SourceManager &SM, HeaderSearch &Headers, ModuleLoader &TheModuleLoader, IdentifierInfoLookup *IILookup=nullptr, bool OwnsHeaderSearch=false, TranslationUnitKind TUKind=TU_Complete) | |
~Preprocessor () | |
void | Initialize (const TargetInfo &Target) |
Initialize the preprocessor using information about the target. | |
void | InitializeForModelFile () |
Initialize the preprocessor to parse a model file. | |
void | FinalizeForModelFile () |
Cleanup after model file parsing. | |
PreprocessorOptions & | getPreprocessorOpts () const |
Retrieve the preprocessor options used to initialize this preprocessor. | |
DiagnosticsEngine & | getDiagnostics () const |
void | setDiagnostics (DiagnosticsEngine &D) |
const LangOptions & | getLangOpts () const |
const TargetInfo & | getTargetInfo () const |
FileManager & | getFileManager () const |
SourceManager & | getSourceManager () const |
HeaderSearch & | getHeaderSearchInfo () const |
IdentifierTable & | getIdentifierTable () |
SelectorTable & | getSelectorTable () |
Builtin::Context & | getBuiltinInfo () |
llvm::BumpPtrAllocator & | getPreprocessorAllocator () |
void | setPTHManager (PTHManager *pm) |
PTHManager * | getPTHManager () |
void | setExternalSource (ExternalPreprocessorSource *Source) |
ExternalPreprocessorSource * | getExternalSource () const |
ModuleLoader & | getModuleLoader () const |
Retrieve the module loader associated with this preprocessor. | |
bool | hadModuleLoaderFatalFailure () const |
bool | isParsingIfOrElifDirective () const |
True if we are currently preprocessing a #if or #elif directive. | |
void | SetCommentRetentionState (bool KeepComments, bool KeepMacroComments) |
Control whether the preprocessor retains comments in output. | |
bool | getCommentRetentionState () const |
void | setPragmasEnabled (bool Enabled) |
bool | getPragmasEnabled () const |
void | SetSuppressIncludeNotFoundError (bool Suppress) |
bool | GetSuppressIncludeNotFoundError () |
void | setPreprocessedOutput (bool IsPreprocessedOutput) |
bool | isPreprocessedOutput () const |
bool | isCurrentLexer (const PreprocessorLexer *L) const |
Return true if we are lexing directly from the specified lexer. | |
PreprocessorLexer * | getCurrentLexer () const |
Return the current lexer being lexed from. | |
PreprocessorLexer * | getCurrentFileLexer () const |
Return the current file lexer being lexed from. | |
Module * | getCurrentSubmodule () const |
Return the submodule owning the file being lexed. | |
FileID | getPredefinesFileID () const |
Returns the FileID for the preprocessor predefines. | |
MacroDirective * | getMacroDirective (IdentifierInfo *II) const |
Given an identifier, return its latest MacroDirective if it is #defined or null if it isn't #define'd. | |
const MacroInfo * | getMacroInfo (IdentifierInfo *II) const |
MacroInfo * | getMacroInfo (IdentifierInfo *II) |
MacroDirective * | getMacroDirectiveHistory (const IdentifierInfo *II) const |
Given an identifier, return the (probably #undef'd) MacroInfo representing the most recent macro definition. | |
void | appendMacroDirective (IdentifierInfo *II, MacroDirective *MD) |
Add a directive to the macro directive history for this identifier. | |
DefMacroDirective * | appendDefMacroDirective (IdentifierInfo *II, MacroInfo *MI, SourceLocation Loc, unsigned ImportedFromModuleID, ArrayRef< unsigned > Overrides) |
DefMacroDirective * | appendDefMacroDirective (IdentifierInfo *II, MacroInfo *MI) |
void | setLoadedMacroDirective (IdentifierInfo *II, MacroDirective *MD) |
Set a MacroDirective that was loaded from a PCH file. | |
StringRef | getLastMacroWithSpelling (SourceLocation Loc, ArrayRef< TokenValue > Tokens) const |
Return the name of the macro defined before Loc that has spelling Tokens . If there are multiple macros with same spelling, return the last one defined. | |
const std::string & | getPredefines () const |
void | setPredefines (const char *P) |
Set the predefines for this Preprocessor. | |
void | setPredefines (const std::string &P) |
IdentifierInfo * | getIdentifierInfo (StringRef Name) const |
void | AddPragmaHandler (StringRef Namespace, PragmaHandler *Handler) |
Add the specified pragma handler to this preprocessor. | |
void | AddPragmaHandler (PragmaHandler *Handler) |
void | RemovePragmaHandler (StringRef Namespace, PragmaHandler *Handler) |
Remove the specific pragma handler from this preprocessor. | |
void | RemovePragmaHandler (PragmaHandler *Handler) |
void | IgnorePragmas () |
Install empty handlers for all pragmas (making them ignored). | |
void | addCommentHandler (CommentHandler *Handler) |
Add the specified comment handler to the preprocessor. | |
void | removeCommentHandler (CommentHandler *Handler) |
Remove the specified comment handler. | |
void | setCodeCompletionHandler (CodeCompletionHandler &Handler) |
Set the code completion handler to the given object. | |
CodeCompletionHandler * | getCodeCompletionHandler () const |
Retrieve the current code-completion handler. | |
void | clearCodeCompletionHandler () |
Clear out the code completion handler. | |
void | CodeCompleteNaturalLanguage () |
Hook used by the lexer to invoke the "natural language" code completion point. | |
PreprocessingRecord * | getPreprocessingRecord () const |
Retrieve the preprocessing record, or NULL if there is no preprocessing record. | |
void | createPreprocessingRecord () |
Create a new preprocessing record, which will keep track of all macro expansions, macro definitions, etc. | |
void | EnterMainSourceFile () |
Enter the specified FileID as the main source file, which implicitly adds the builtin defines etc. | |
void | EndSourceFile () |
Inform the preprocessor callbacks that processing is complete. | |
bool | EnterSourceFile (FileID CurFileID, const DirectoryLookup *Dir, SourceLocation Loc) |
Add a source file to the top of the include stack and start lexing tokens from it instead of the current buffer. | |
void | EnterMacro (Token &Identifier, SourceLocation ILEnd, MacroInfo *Macro, MacroArgs *Args) |
Add a Macro to the top of the include stack and start lexing tokens from it instead of the current buffer. | |
void | EnterTokenStream (const Token *Toks, unsigned NumToks, bool DisableMacroExpansion, bool OwnsTokens) |
Add a "macro" context to the top of the include stack, which will cause the lexer to start returning the specified tokens. | |
void | RemoveTopOfLexerStack () |
Pop the current lexer/macro exp off the top of the lexer stack. | |
void | EnableBacktrackAtThisPos () |
void | CommitBacktrackedTokens () |
Disable the last EnableBacktrackAtThisPos call. | |
void | Backtrack () |
Make Preprocessor re-lex the tokens that were lexed since EnableBacktrackAtThisPos() was previously called. | |
bool | isBacktrackEnabled () const |
True if EnableBacktrackAtThisPos() was called and caching of tokens is on. | |
void | Lex (Token &Result) |
Lex the next token for this preprocessor. | |
void | LexAfterModuleImport (Token &Result) |
Lex a token following the 'import' contextual keyword. | |
bool | LexStringLiteral (Token &Result, std::string &String, const char *DiagnosticTag, bool AllowMacroExpansion) |
Lex a string literal, which may be the concatenation of multiple string literals and may even come from macro expansion. | |
bool | FinishLexStringLiteral (Token &Result, std::string &String, const char *DiagnosticTag, bool AllowMacroExpansion) |
Complete the lexing of a string literal where the first token has already been lexed (see LexStringLiteral). | |
void | LexNonComment (Token &Result) |
Lex a token. If it's a comment, keep lexing until we get something not a comment. | |
void | LexUnexpandedToken (Token &Result) |
Just like Lex, but disables macro expansion of identifier tokens. | |
void | LexUnexpandedNonComment (Token &Result) |
Like LexNonComment, but this disables macro expansion of identifier tokens. | |
bool | parseSimpleIntegerLiteral (Token &Tok, uint64_t &Value) |
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. | |
void | SetMacroExpansionOnlyInDirectives () |
Disables macro expansion everywhere except for preprocessor directives. | |
const Token & | LookAhead (unsigned N) |
Peeks ahead N tokens and returns that token without consuming any tokens. | |
void | RevertCachedTokens (unsigned N) |
When backtracking is enabled and tokens are cached, this allows to revert a specific number of tokens. | |
void | EnterToken (const Token &Tok) |
Enters a token in the token stream to be lexed next. | |
void | AnnotateCachedTokens (const Token &Tok) |
SourceLocation | getLastCachedTokenLocation () const |
void | ReplaceLastTokenWithAnnotation (const Token &Tok) |
Replace the last token with an annotation token. | |
void | TypoCorrectToken (const Token &Tok) |
void | recomputeCurLexerKind () |
Recompute the current lexer kind based on the CurLexer/CurPTHLexer/ CurTokenLexer pointers. | |
bool | isIncrementalProcessingEnabled () const |
Returns true if incremental processing is enabled. | |
void | enableIncrementalProcessing (bool value=true) |
Enables the incremental processing. | |
bool | SetCodeCompletionPoint (const FileEntry *File, unsigned Line, unsigned Column) |
Specify the point at which code-completion will be performed. | |
bool | isCodeCompletionEnabled () const |
Determine if we are performing code completion. | |
SourceLocation | getCodeCompletionLoc () const |
Returns the location of the code-completion point. | |
SourceLocation | getCodeCompletionFileLoc () const |
Returns the start location of the file of code-completion point. | |
bool | isCodeCompletionReached () const |
Returns true if code-completion is enabled and we have hit the code-completion point. | |
void | setCodeCompletionReached () |
Note that we hit the code-completion point. | |
SourceLocation | getPragmaARCCFCodeAuditedLoc () const |
The location of the currently-active #pragma clang arc_cf_code_audited begin. | |
void | setPragmaARCCFCodeAuditedLoc (SourceLocation Loc) |
Set the location of the currently-active #pragma clang arc_cf_code_audited begin. An invalid location ends the pragma. | |
void | setSkipMainFilePreamble (unsigned Bytes, bool StartOfLine) |
Instruct the preprocessor to skip part of the main source file. | |
DiagnosticBuilder | Diag (SourceLocation Loc, unsigned DiagID) const |
DiagnosticBuilder | Diag (const Token &Tok, unsigned DiagID) const |
StringRef | getSpelling (SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const |
std::string | getSpelling (const Token &Tok, bool *Invalid=nullptr) const |
Return the 'spelling' of the Tok token. | |
unsigned | getSpelling (const Token &Tok, const char *&Buffer, bool *Invalid=nullptr) const |
Get the spelling of a token into a preallocated buffer, instead of as an std::string. | |
StringRef | getSpelling (const Token &Tok, SmallVectorImpl< char > &Buffer, bool *Invalid=nullptr) const |
Get the spelling of a token into a SmallVector. | |
bool | getRawToken (SourceLocation Loc, Token &Result, bool IgnoreWhiteSpace=false) |
Relex the token at the specified location. | |
char | getSpellingOfSingleCharacterNumericConstant (const Token &Tok, bool *Invalid=nullptr) const |
Given a Token Tok that is a numeric constant with length 1, return the character. | |
StringRef | getImmediateMacroName (SourceLocation Loc) |
Retrieve the name of the immediate macro expansion. | |
void | CreateString (StringRef Str, Token &Tok, SourceLocation ExpansionLocStart=SourceLocation(), SourceLocation ExpansionLocEnd=SourceLocation()) |
Plop the specified string into a scratch buffer and set the specified token's location and length to it. | |
SourceLocation | getLocForEndOfToken (SourceLocation Loc, unsigned Offset=0) |
Computes the source location just past the end of the token at this source location. | |
bool | isAtStartOfMacroExpansion (SourceLocation loc, SourceLocation *MacroBegin=nullptr) const |
Returns true if the given MacroID location points at the first token of the macro expansion. | |
bool | isAtEndOfMacroExpansion (SourceLocation loc, SourceLocation *MacroEnd=nullptr) const |
Returns true if the given MacroID location points at the last token of the macro expansion. | |
void | DumpToken (const Token &Tok, bool DumpFlags=false) const |
Print the token to stderr, used for debugging. | |
void | DumpLocation (SourceLocation Loc) const |
void | DumpMacro (const MacroInfo &MI) const |
SourceLocation | AdvanceToTokenCharacter (SourceLocation TokStart, unsigned Char) const |
Given a location that specifies the start of a token, return a new location that specifies a character within the token. | |
void | IncrementPasteCounter (bool isFast) |
Increment the counters for the number of token paste operations performed. | |
void | PrintStats () |
size_t | getTotalMemory () const |
void | HandleMicrosoftCommentPaste (Token &Tok) |
IdentifierInfo * | LookUpIdentifierInfo (Token &Identifier) const |
void | SetPoisonReason (IdentifierInfo *II, unsigned DiagID) |
Specifies the reason for poisoning an identifier. | |
void | HandlePoisonedIdentifier (Token &Tok) |
Display reason for poisoned identifier. | |
void | MaybeHandlePoisonedIdentifier (Token &Identifier) |
void | PoisonSEHIdentifiers (bool Poison=true) |
bool | HandleIdentifier (Token &Identifier) |
Callback invoked when the lexer reads an identifier and has filled in the tokens IdentifierInfo member. | |
bool | HandleEndOfFile (Token &Result, bool isEndOfMacro=false) |
Callback invoked when the lexer hits the end of the current file. | |
bool | HandleEndOfTokenLexer (Token &Result) |
Callback invoked when the current TokenLexer hits the end of its token stream. | |
void | HandleDirective (Token &Result) |
Callback invoked when the lexer sees a # token at the start of a line. | |
void | CheckEndOfDirective (const char *Directive, bool EnableMacros=false) |
Ensure that the next token is a tok::eod token. | |
void | DiscardUntilEndOfDirective () |
Read and discard all tokens remaining on the current line until the tok::eod token is found. | |
bool | SawDateOrTime () const |
Returns true if the preprocessor has seen a use of __DATE__ or __TIME__ in the file so far. | |
unsigned | getCounterValue () const |
void | setCounterValue (unsigned V) |
Module * | getCurrentModule () |
Retrieves the module that we're currently building, if any. | |
MacroInfo * | AllocateMacroInfo (SourceLocation L) |
Allocate a new MacroInfo object with the provided SourceLocation. | |
MacroInfo * | AllocateDeserializedMacroInfo (SourceLocation L, unsigned SubModuleID) |
Allocate a new MacroInfo object loaded from an AST file. | |
bool | GetIncludeFilenameSpelling (SourceLocation Loc, StringRef &Filename) |
Turn the specified lexer token into a fully checked and spelled filename, e.g. as an operand of #include. | |
const FileEntry * | LookupFile (SourceLocation FilenameLoc, StringRef Filename, bool isAngled, const DirectoryLookup *FromDir, const FileEntry *FromFile, const DirectoryLookup *&CurDir, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, ModuleMap::KnownHeader *SuggestedModule, bool SkipCache=false) |
Given a "foo" or <foo> reference, look up the indicated file. | |
const DirectoryLookup * | GetCurDirLookup () |
Get the DirectoryLookup structure used to find the current FileEntry, if CurLexer is non-null and if applicable. | |
bool | isInPrimaryFile () const |
Return true if we're in the top-level file, not in a #include. | |
bool | ConcatenateIncludeName (SmallString< 128 > &FilenameBuffer, SourceLocation &End) |
Handle cases where the #include name is expanded from a macro as multiple tokens, which need to be glued together. | |
bool | LexOnOffSwitch (tok::OnOffSwitch &OOS) |
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. | |
bool | CheckMacroName (Token &MacroNameTok, MacroUse isDefineUndef) |
void | HandlePragmaOnce (Token &OnceTok) |
void | HandlePragmaMark () |
void | HandlePragmaPoison (Token &PoisonTok) |
void | HandlePragmaSystemHeader (Token &SysHeaderTok) |
void | HandlePragmaDependency (Token &DependencyTok) |
void | HandlePragmaPushMacro (Token &Tok) |
Handle #pragma push_macro. | |
void | HandlePragmaPopMacro (Token &Tok) |
Handle #pragma pop_macro. | |
void | HandlePragmaIncludeAlias (Token &Tok) |
IdentifierInfo * | ParsePragmaPushOrPopMacro (Token &Tok) |
bool | HandleComment (Token &Token, SourceRange Comment) |
void | markMacroAsUsed (MacroInfo *MI) |
A macro is used, update information about macros that need unused warnings. | |
PPCallbacks * | getPPCallbacks () const |
Accessors for preprocessor callbacks. | |
void | addPPCallbacks (std::unique_ptr< PPCallbacks > C) |
Friends | |
class | ASTReader |
class | MacroArgs |
void | TokenLexer::ExpandFunctionArguments () |
typedef llvm::DenseMap< const IdentifierInfo *, MacroDirective * > ::const_iterator | macro_iterator |
macro_iterator | macro_begin (bool IncludeExternalMacros=true) const |
macro_iterator | macro_end (bool IncludeExternalMacros=true) const |
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.
Definition at line 95 of file Preprocessor.h.
typedef llvm::DenseMap<const IdentifierInfo *, MacroDirective*>::const_iterator clang::Preprocessor::macro_iterator |
Iterators for the macro history table. Currently defined macros have IdentifierInfo::hasMacroDefinition() set and an empty MacroInfo::getUndefLoc() at the head of the list.
Definition at line 648 of file Preprocessor.h.
Preprocessor::Preprocessor | ( | IntrusiveRefCntPtr< PreprocessorOptions > | PPOpts, |
DiagnosticsEngine & | diags, | ||
LangOptions & | opts, | ||
SourceManager & | SM, | ||
HeaderSearch & | Headers, | ||
ModuleLoader & | TheModuleLoader, | ||
IdentifierInfoLookup * | IILookup = nullptr , |
||
bool | OwnsHeaderSearch = false , |
||
TranslationUnitKind | TUKind = TU_Complete |
||
) |
Definition at line 58 of file Preprocessor.cpp.
References getIdentifierInfo(), and SetPoisonReason().
Definition at line 141 of file Preprocessor.cpp.
void Preprocessor::addCommentHandler | ( | CommentHandler * | Handler | ) |
Add the specified comment handler to the preprocessor.
Definition at line 817 of file Preprocessor.cpp.
Referenced by clang::Parser::Parser().
void clang::Preprocessor::addPPCallbacks | ( | std::unique_ptr< PPCallbacks > | C | ) | [inline] |
Definition at line 590 of file Preprocessor.h.
Referenced by clang::AttachDependencyGraphGen(), clang::AttachHeaderIncludeGen(), clang::DependencyCollector::attachToPreprocessor(), clang::DependencyFileGenerator::CreateAndAttachToPreprocessor(), clang::CodeGenAction::CreateASTConsumer(), clang::arcmt::MigrateSourceAction::CreateASTConsumer(), clang::arcmt::ObjCMigrateAction::CreateASTConsumer(), createPreprocessingRecord(), clang::DoPrintPreprocessedInput(), and clang::RewriteIncludesInInput().
void Preprocessor::AddPragmaHandler | ( | StringRef | Namespace, |
PragmaHandler * | Handler | ||
) |
Add the specified pragma handler to this preprocessor.
If 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".
AddPragmaHandler - Add the specified pragma handler to the preprocessor. If '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".
Definition at line 729 of file Pragma.cpp.
References clang::PragmaNamespace::AddPragma(), clang::PragmaNamespace::FindHandler(), clang::PragmaNamespace::getIfNamespace(), and clang::PragmaHandler::getName().
Referenced by AddPragmaHandler(), clang::DoPrintPreprocessedInput(), and IgnorePragmas().
void clang::Preprocessor::AddPragmaHandler | ( | PragmaHandler * | Handler | ) | [inline] |
Definition at line 677 of file Preprocessor.h.
References AddPragmaHandler().
SourceLocation clang::Preprocessor::AdvanceToTokenCharacter | ( | SourceLocation | TokStart, |
unsigned | Char | ||
) | const [inline] |
Given a location that specifies the start of a token, return a new location that specifies a character within the token.
Definition at line 1182 of file Preprocessor.h.
Referenced by GetLineValue(), and clang::NumericLiteralParser::NumericLiteralParser().
MacroInfo * Preprocessor::AllocateDeserializedMacroInfo | ( | SourceLocation | L, |
unsigned | SubModuleID | ||
) |
Allocate a new MacroInfo object loaded from an AST file.
Definition at line 49 of file PPDirectives.cpp.
References clang::SrcMgr::static_assert().
Allocate a new MacroInfo object with the provided SourceLocation.
Definition at line 43 of file PPDirectives.cpp.
References AllocateMacroInfo().
Referenced by AllocateMacroInfo(), and RegisterBuiltinMacro().
void clang::Preprocessor::AnnotateCachedTokens | ( | const Token & | Tok | ) | [inline] |
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.
Definition at line 910 of file Preprocessor.h.
References clang::Token::isAnnotation(), and isBacktrackEnabled().
Referenced by clang::Parser::TryAnnotateTypeOrScopeToken(), and clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec().
DefMacroDirective* clang::Preprocessor::appendDefMacroDirective | ( | IdentifierInfo * | II, |
MacroInfo * | MI, | ||
SourceLocation | Loc, | ||
unsigned | ImportedFromModuleID, | ||
ArrayRef< unsigned > | Overrides | ||
) | [inline] |
Definition at line 628 of file Preprocessor.h.
References appendMacroDirective().
Referenced by appendDefMacroDirective(), HandlePragmaPopMacro(), and RegisterBuiltinMacro().
DefMacroDirective* clang::Preprocessor::appendDefMacroDirective | ( | IdentifierInfo * | II, |
MacroInfo * | MI | ||
) | [inline] |
Definition at line 637 of file Preprocessor.h.
References appendDefMacroDirective(), and clang::MacroInfo::getDefinitionLoc().
void Preprocessor::appendMacroDirective | ( | IdentifierInfo * | II, |
MacroDirective * | MD | ||
) |
Add a directive to the macro directive history for this identifier.
Definition at line 45 of file PPMacroExpansion.cpp.
References clang::MacroDirective::getPrevious(), clang::MacroDirective::isDefined(), clang::IdentifierInfo::isFromAST(), clang::IdentifierInfo::setChangedSinceDeserialization(), clang::IdentifierInfo::setHasMacroDefinition(), and clang::MacroDirective::setPrevious().
Referenced by appendDefMacroDirective(), and HandlePragmaPopMacro().
void Preprocessor::Backtrack | ( | ) |
Make Preprocessor re-lex the tokens that were lexed since EnableBacktrackAtThisPos() was previously called.
Definition at line 40 of file PPCaching.cpp.
References recomputeCurLexerKind().
void Preprocessor::CheckEndOfDirective | ( | const char * | DirType, |
bool | EnableMacros = false |
||
) |
Ensure that the next token is a tok::eod token.
If not, emit a diagnostic and consume up until the eod. If EnableMacros
is true, then we consider macros that expand to zero tokens as being ok.
If not, emit a diagnostic and consume up until the eod. If EnableMacros is true, then we consider macros that expand to zero tokens as being ok.
Definition at line 181 of file PPDirectives.cpp.
References clang::FixItHint::CreateInsertion(), Diag(), DiscardUntilEndOfDirective(), clang::Token::getLocation(), clang::Token::is(), clang::Token::isNot(), Lex(), and LexUnexpandedToken().
bool Preprocessor::CheckMacroName | ( | Token & | MacroNameTok, |
MacroUse | isDefineUndef | ||
) |
Definition at line 103 of file PPDirectives.cpp.
References Diag(), clang::Token::getIdentifierInfo(), getIdentifierInfo(), clang::Token::getKind(), getLangOpts(), getMacroInfo(), clang::IdentifierInfo::getPPKeywordID(), getSpelling(), clang::IdentifierInfo::hasMacroDefinition(), clang::Token::is(), clang::MacroInfo::isBuiltinMacro(), clang::IdentifierInfo::isCPlusPlusOperatorKeyword(), clang::MU_Other, clang::MU_Undef, and clang::Token::setIdentifierInfo().
Referenced by EvaluateDefined().
void clang::Preprocessor::clearCodeCompletionHandler | ( | ) | [inline] |
Clear out the code completion handler.
Definition at line 713 of file Preprocessor.h.
Referenced by clang::Parser::~Parser().
Hook used by the lexer to invoke the "natural language" code completion point.
Definition at line 414 of file Preprocessor.cpp.
References clang::CodeCompletionHandler::CodeCompleteNaturalLanguage(), and setCodeCompletionReached().
Referenced by clang::Lexer::ReadToEndOfLine(), and clang::MacroArgs::StringifyArgument().
Disable the last EnableBacktrackAtThisPos call.
Definition at line 32 of file PPCaching.cpp.
bool Preprocessor::ConcatenateIncludeName | ( | SmallString< 128 > & | FilenameBuffer, |
SourceLocation & | End | ||
) |
Handle cases where the #include name is expanded from a macro as multiple tokens, which need to be glued together.
This occurs for code like:
\#define FOO <x/y.h> \#include FOO
because in this case, "<x/y.h>" is returned as 7 tokens, not one.
This code concatenates and consumes tokens up to the '>' token. It returns false if the > was found, otherwise it returns true if it finds and consumes the EOD marker.
Definition at line 1311 of file PPDirectives.cpp.
References Diag(), clang::Token::getLength(), clang::Token::getLocation(), getSpelling(), clang::Token::hasLeadingSpace(), clang::Token::is(), clang::Token::isNot(), Lex(), and setCodeCompletionReached().
Referenced by EvaluateHasIncludeCommon(), and HandlePragmaIncludeAlias().
Create a new preprocessing record, which will keep track of all macro expansions, macro definitions, etc.
Definition at line 851 of file Preprocessor.cpp.
References addPPCallbacks(), getSourceManager(), and Record.
void Preprocessor::CreateString | ( | StringRef | Str, |
Token & | Tok, | ||
SourceLocation | ExpansionLocStart = SourceLocation() , |
||
SourceLocation | ExpansionLocEnd = SourceLocation() |
||
) |
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.
CreateString - Plop the specified string into a scratch buffer and return a location for it. If specified, the source location provides a source location for the token.
Definition at line 445 of file Preprocessor.cpp.
References clang::SourceManager::createExpansionLoc(), clang::Token::is(), clang::Token::isLiteral(), clang::SourceLocation::isValid(), clang::Token::setLength(), clang::Token::setLiteralData(), clang::Token::setLocation(), clang::Token::setRawIdentifierData(), and SourceMgr.
Referenced by ComputeDATE_TIME(), ParsePragmaPushOrPopMacro(), and clang::MacroArgs::StringifyArgument().
DiagnosticBuilder clang::Preprocessor::Diag | ( | SourceLocation | Loc, |
unsigned | DiagID | ||
) | const [inline] |
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.
Definition at line 1031 of file Preprocessor.h.
References clang::DiagnosticsEngine::Report().
Referenced by buildMSAsmString(), clang::CharLiteralParser::CharLiteralParser(), checkConfigMacro(), CheckEndOfDirective(), CheckMacroName(), ConcatenateIncludeName(), clang::Lexer::Diag(), EnterSourceFile(), EvaluateBuildingModule(), EvaluateDefined(), EvaluateDirectiveSubExpr(), EvaluateHasIncludeCommon(), EvaluateHasIncludeNext(), EvaluateValue(), FinishLexStringLiteral(), GetIncludeFilenameSpelling(), GetLineValue(), HandleDirective(), HandleEndOfFile(), HandleIdentifier(), HandlePoisonedIdentifier(), clang::PragmaNamespace::HandlePragma(), HandlePragmaDependency(), HandlePragmaIncludeAlias(), HandlePragmaOnce(), HandlePragmaPoison(), HandlePragmaPopMacro(), HandlePragmaSystemHeader(), clang::PreprocessorLexer::LexIncludeFilename(), LexOnOffSwitch(), clang::NumericLiteralParser::NumericLiteralParser(), ParseAlignPragma(), ParseLoopHintValue(), ParsePragmaPushOrPopMacro(), ReadLineMarkerFlags(), and clang::MacroArgs::StringifyArgument().
DiagnosticBuilder clang::Preprocessor::Diag | ( | const Token & | Tok, |
unsigned | DiagID | ||
) | const [inline] |
Definition at line 1035 of file Preprocessor.h.
References clang::Token::getLocation(), and clang::DiagnosticsEngine::Report().
Read and discard all tokens remaining on the current line until the tok::eod token is found.
Definition at line 95 of file PPDirectives.cpp.
References clang::comments::tok::eof, clang::Token::isNot(), and LexUnexpandedToken().
Referenced by CheckEndOfDirective(), GetLineValue(), HandleDirective(), and ReadLineMarkerFlags().
void Preprocessor::DumpLocation | ( | SourceLocation | Loc | ) | const |
Definition at line 229 of file Preprocessor.cpp.
References clang::SourceLocation::dump(), and SourceMgr.
Referenced by DumpToken().
void Preprocessor::DumpMacro | ( | const MacroInfo & | MI | ) | const |
Definition at line 233 of file Preprocessor.cpp.
References DumpToken(), clang::MacroInfo::getNumTokens(), and clang::MacroInfo::getReplacementToken().
void Preprocessor::DumpToken | ( | const Token & | Tok, |
bool | DumpFlags = false |
||
) | const |
Print the token to stderr, used for debugging.
Definition at line 205 of file Preprocessor.cpp.
References DumpLocation(), clang::SourceManager::getCharacterData(), clang::Token::getKind(), clang::Token::getLength(), clang::Token::getLocation(), getSpelling(), clang::tok::getTokenName(), clang::Token::hasLeadingSpace(), clang::Token::isAtStartOfLine(), clang::Token::isExpandDisabled(), clang::Token::needsCleaning(), and SourceMgr.
Referenced by DumpMacro(), clang::DumpRawTokensAction::ExecuteAction(), and clang::DumpTokensAction::ExecuteAction().
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.
Definition at line 26 of file PPCaching.cpp.
void clang::Preprocessor::enableIncrementalProcessing | ( | bool | value = true | ) | [inline] |
Enables the incremental processing.
Definition at line 953 of file Preprocessor.h.
void Preprocessor::EndSourceFile | ( | ) |
Inform the preprocessor callbacks that processing is complete.
Definition at line 516 of file Preprocessor.cpp.
Referenced by clang::FrontendAction::EndSourceFile().
void Preprocessor::EnterMacro | ( | Token & | Tok, |
SourceLocation | ILEnd, | ||
MacroInfo * | Macro, | ||
MacroArgs * | Args | ||
) |
Add a Macro to the top of the include stack and start lexing tokens from it instead of the current buffer.
Args | specifies the tokens input to a function-like macro. |
ILEnd | specifies the location of the ')' for a function-like macro or the identifier for an object-like macro. |
EnterMacro - Add a Macro to the top of the include stack and start lexing tokens from it instead of the current buffer.
Definition at line 161 of file PPLexerChange.cpp.
void Preprocessor::EnterMainSourceFile | ( | ) |
Enter the specified FileID as the main source file, which implicitly adds the builtin defines etc.
EnterMainSourceFile - Enter the specified FileID as the main source file, which implicitly adds the builtin defines etc.
Definition at line 479 of file Preprocessor.cpp.
References clang::SourceManager::createFileID(), EnterSourceFile(), clang::SourceManager::getFileEntryForID(), clang::SourceManager::getMainFileID(), clang::HeaderSearch::IncrementIncludeCount(), clang::FileID::isInvalid(), clang::SourceManager::isLoadedFileID(), and SourceMgr.
Referenced by clang::CacheTokens(), DoPrintMacros(), clang::DoPrintPreprocessedInput(), clang::DumpTokensAction::ExecuteAction(), clang::PreprocessOnlyAction::ExecuteAction(), clang::ParseAST(), clang::RewriteIncludesInInput(), and clang::RewriteMacrosInInput().
bool Preprocessor::EnterSourceFile | ( | FileID | FID, |
const DirectoryLookup * | CurDir, | ||
SourceLocation | Loc | ||
) |
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.
EnterSourceFile - Add a source file to the top of the include stack and start lexing tokens from it instead of the current buffer.
Definition at line 71 of file PPLexerChange.cpp.
References Diag(), clang::SourceManager::getBuffer(), clang::SourceManager::getBufferName(), clang::SourceManager::getFileEntryForID(), clang::SourceManager::getLocForStartOfFile(), clang::SourceLocation::getLocWithOffset(), getSourceManager(), and isCodeCompletionEnabled().
Referenced by EnterMainSourceFile().
void clang::Preprocessor::EnterToken | ( | const Token & | Tok | ) | [inline] |
Enters a token in the token stream to be lexed next.
If BackTrack() is called afterwards, the token will remain at the insertion point.
Definition at line 897 of file Preprocessor.h.
Referenced by FixDigraph(), and clang::Parser::TryAnnotateTypeOrScopeToken().
void Preprocessor::EnterTokenStream | ( | const Token * | Toks, |
unsigned | NumToks, | ||
bool | DisableMacroExpansion, | ||
bool | OwnsTokens | ||
) |
Add a "macro" context to the top of the include stack, which will cause the lexer to start returning the specified tokens.
If 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 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 new
[] and must be freed.
EnterTokenStream - Add a "macro" context to the top of the include stack, which will cause the lexer to start returning the specified tokens.
If 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 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 new[] and must be freed.
Definition at line 190 of file PPLexerChange.cpp.
Referenced by EnterAnnotationToken(), clang::MacroArgs::getPreExpArgument(), HandleDirective(), ParseAlignPragma(), and clang::Parser::ParseMSAsmIdentifier().
void Preprocessor::FinalizeForModelFile | ( | ) |
Cleanup after model file parsing.
Definition at line 194 of file Preprocessor.cpp.
bool Preprocessor::FinishLexStringLiteral | ( | Token & | Result, |
std::string & | String, | ||
const char * | DiagnosticTag, | ||
bool | AllowMacroExpansion | ||
) |
Complete the lexing of a string literal where the first token has already been lexed (see LexStringLiteral).
Definition at line 758 of file Preprocessor.cpp.
References Diag(), clang::StringLiteralParser::GetString(), clang::StringLiteralParser::hadError, clang::Token::hasUDSuffix(), clang::Token::is(), clang::StringLiteralParser::isAscii(), clang::Token::isNot(), Lex(), LexUnexpandedToken(), and clang::StringLiteralParser::Pascal.
Referenced by LexStringLiteral().
Builtin::Context& clang::Preprocessor::getBuiltinInfo | ( | ) | [inline] |
Definition at line 505 of file Preprocessor.h.
Referenced by clang::FrontendAction::BeginSourceFile(), clang::CompilerInstance::createASTContext(), and clang::createChainedIncludesSource().
SourceLocation clang::Preprocessor::getCodeCompletionFileLoc | ( | ) | const [inline] |
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.
Definition at line 987 of file Preprocessor.h.
CodeCompletionHandler* clang::Preprocessor::getCodeCompletionHandler | ( | ) | const [inline] |
Retrieve the current code-completion handler.
Definition at line 708 of file Preprocessor.h.
Referenced by EvaluateDefined(), and EvaluateValue().
SourceLocation clang::Preprocessor::getCodeCompletionLoc | ( | ) | const [inline] |
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.
Definition at line 981 of file Preprocessor.h.
bool clang::Preprocessor::getCommentRetentionState | ( | ) | const [inline] |
Definition at line 538 of file Preprocessor.h.
Referenced by HandleComment(), PrintPreprocessedTokens(), and clang::Lexer::resetExtendedTokenMode().
unsigned clang::Preprocessor::getCounterValue | ( | ) | const [inline] |
Definition at line 1304 of file Preprocessor.h.
const DirectoryLookup* clang::Preprocessor::GetCurDirLookup | ( | ) | [inline] |
Get the DirectoryLookup structure used to find the current FileEntry, if CurLexer is non-null and if applicable.
This allows us to implement #include_next and find directory-specific properties.
Definition at line 1346 of file Preprocessor.h.
Referenced by EvaluateHasIncludeNext().
PreprocessorLexer * Preprocessor::getCurrentFileLexer | ( | ) | const |
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.
getCurrentLexer - 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.
Definition at line 51 of file PPLexerChange.cpp.
Referenced by HandlePragmaDependency(), HandlePragmaOnce(), HandlePragmaSystemHeader(), and LookupFile().
PreprocessorLexer* clang::Preprocessor::getCurrentLexer | ( | ) | const [inline] |
Return the current lexer being lexed from.
Note that this ignores any potentially active macro expansions and _Pragma expansions going on at the time.
Definition at line 570 of file Preprocessor.h.
Referenced by EvaluateHasIncludeCommon(), and EvaluateHasIncludeNext().
Retrieves the module that we're currently building, if any.
Definition at line 465 of file Preprocessor.cpp.
References getHeaderSearchInfo(), getLangOpts(), and clang::HeaderSearch::lookupModule().
Referenced by clang::Sema::ActOnEndOfTranslationUnit(), and HandleEndOfFile().
Module* clang::Preprocessor::getCurrentSubmodule | ( | ) | const [inline] |
Return the submodule owning the file being lexed.
Definition at line 579 of file Preprocessor.h.
Referenced by EvaluateHasIncludeNext().
DiagnosticsEngine& clang::Preprocessor::getDiagnostics | ( | ) | const [inline] |
Definition at line 494 of file Preprocessor.h.
Referenced by AddImplicitIncludePCH(), AddImplicitIncludePTH(), clang::AttachHeaderIncludeGen(), clang::CharLiteralParser::CharLiteralParser(), clang::ento::CreateAnalysisConsumer(), clang::DependencyFileGenerator::CreateAndAttachToPreprocessor(), clang::CompilerInstance::createCodeCompletionConsumer(), EnableCodeCompletion(), HandleEndOfFile(), clang::PCHGenerator::HandleTranslationUnit(), HasExtension(), clang::html::HighlightMacros(), clang::InitializePreprocessor(), ParseDirective(), clang::Sema::Sema(), and setCodeCompletionReached().
ExternalPreprocessorSource* clang::Preprocessor::getExternalSource | ( | ) | const [inline] |
Definition at line 516 of file Preprocessor.h.
Referenced by isTrivialSingleTokenExpansion().
FileManager& clang::Preprocessor::getFileManager | ( | ) | const [inline] |
Definition at line 499 of file Preprocessor.h.
Referenced by AddImplicitIncludePCH(), clang::CacheTokens(), EnableCodeCompletion(), and HandleEndOfFile().
HeaderSearch& clang::Preprocessor::getHeaderSearchInfo | ( | ) | const [inline] |
Definition at line 501 of file Preprocessor.h.
Referenced by clang::Sema::ActOnEndOfTranslationUnit(), clang::GenerateModuleAction::BeginSourceFileAction(), compileModuleImpl(), clang::GenerateModuleAction::ComputeASTConsumerArguments(), clang::CompilerInstance::createPCHExternalASTSource(), clang::FrontendAction::EndSourceFile(), clang::FrontendAction::Execute(), getCurrentModule(), clang::VerifyDiagnosticConsumer::HandleDiagnostic(), HandleEndOfFile(), HandlePragmaIncludeAlias(), clang::ASTWriter::inferSubmoduleIDFromLocation(), and clang::CompilerInstance::loadGlobalModuleIndex().
IdentifierInfo* clang::Preprocessor::getIdentifierInfo | ( | StringRef | Name | ) | const [inline] |
Return information about the specified preprocessor identifier token.
Definition at line 668 of file Preprocessor.h.
References clang::IdentifierTable::get().
Referenced by checkConfigMacro(), clang::comments::Sema::checkDeprecatedCommand(), CheckMacroName(), DiagnoseSwitchLabelsFallthrough(), clang::Parser::Initialize(), clang::Sema::Initialize(), LookUpIdentifierInfo(), Preprocessor(), and RegisterBuiltinMacro().
IdentifierTable& clang::Preprocessor::getIdentifierTable | ( | ) | [inline] |
Definition at line 503 of file Preprocessor.h.
Referenced by clang::Sema::ActOnClassPropertyRefExpr(), clang::FrontendAction::BeginSourceFile(), BuildNonArrayForRange(), BuildVarDecl(), clang::CompilerInstance::createASTContext(), clang::createChainedIncludesSource(), clang::Sema::DeclareGlobalNewDelete(), clang::ASTReader::DecodeIdentifierInfo(), clang::FrontendAction::EndSourceFile(), clang::ASTReader::getIdentifierTable(), clang::Sema::getOrCreateStdNamespace(), clang::Sema::HandleExprPropertyRefExpr(), handleOwnershipAttr(), clang::Parser::Initialize(), clang::Sema::isStdInitializerList(), LookupMemberExpr(), and LookupStdInitializerList().
StringRef clang::Preprocessor::getImmediateMacroName | ( | SourceLocation | Loc | ) | [inline] |
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.
Definition at line 1122 of file Preprocessor.h.
References getLangOpts().
Referenced by isExpandedFromConfigurationMacro().
bool Preprocessor::GetIncludeFilenameSpelling | ( | SourceLocation | Loc, |
StringRef & | Buffer | ||
) |
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.
GetIncludeFilenameSpelling - Turn the specified lexer token into a fully checked and spelled filename, e.g. as an operand of #include. This returns true if the input filename was in <>'s or false if it were in ""'s. 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.
Definition at line 1259 of file PPDirectives.cpp.
References Diag().
Referenced by EvaluateHasIncludeCommon(), HandlePragmaDependency(), and HandlePragmaIncludeAlias().
const LangOptions& clang::Preprocessor::getLangOpts | ( | ) | const [inline] |
Definition at line 497 of file Preprocessor.h.
Referenced by AddMacroResults(), clang::TokenConcatenation::AvoidConcat(), clang::FrontendAction::BeginSourceFile(), clang::CharLiteralParser::CharLiteralParser(), CheckMacroName(), clang::createChainedIncludesSource(), clang::DoRewriteTest(), emitPremigrationErrors(), EvaluateBuildingModule(), EvaluateDirectiveSubExpr(), EvaluateValue(), clang::DumpRawTokensAction::ExecuteAction(), clang::DeclSpec::Finish(), getCurrentModule(), getImmediateMacroName(), clang::Parser::getLangOpts(), HandleDirective(), HandleIdentifier(), HasExtension(), HasFeature(), clang::html::HighlightMacros(), clang::Sema::Initialize(), clang::InitializePreprocessor(), LexAfterModuleImport(), LexRawTokensFromMainFile(), clang::NumericLiteralParser::NumericLiteralParser(), PrintPreprocessedTokens(), clang::RewriteMacrosInInput(), clang::html::SyntaxHighlight(), and clang::TokenConcatenation::TokenConcatenation().
SourceLocation clang::Preprocessor::getLastCachedTokenLocation | ( | ) | const [inline] |
Get the location of the last cached token, suitable for setting the end location of an annotation token.
Definition at line 918 of file Preprocessor.h.
StringRef Preprocessor::getLastMacroWithSpelling | ( | SourceLocation | Loc, |
ArrayRef< TokenValue > | Tokens | ||
) | const |
Return the name of the macro defined before Loc
that has spelling Tokens
. If there are multiple macros with same spelling, return the last one defined.
Definition at line 317 of file Preprocessor.cpp.
References clang::MacroDirective::DefInfo::getLocation(), clang::MacroDirective::DefInfo::getMacroInfo(), clang::SourceManager::isBeforeInTranslationUnit(), clang::SourceLocation::isInvalid(), clang::SourceLocation::isValid(), macro_begin(), macro_end(), MacroDefinitionEquals(), SourceMgr, and Tokens.
Referenced by clang::comments::Sema::checkDeprecatedCommand(), and DiagnoseSwitchLabelsFallthrough().
SourceLocation clang::Preprocessor::getLocForEndOfToken | ( | SourceLocation | Loc, |
unsigned | Offset = 0 |
||
) | [inline] |
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 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.
Offset | 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. |
Definition at line 1150 of file Preprocessor.h.
Referenced by clang::Sema::ActOnCXXDelete(), addFixitForObjCARCConversion(), clang::Sema::CheckFriendTypeDecl(), clang::Sema::CheckObjCBridgeRelatedConversions(), clang::Sema::CheckUsingDeclQualifier(), clang::Sema::DiagnoseAssignmentAsCondition(), DiagnoseDirectIsaAccess(), clang::Sema::DiagnoseDtorReference(), diagnoseLogicalNotOnLHSofComparison(), diagnoseObjCARCConversion(), diagnoseObjCLiteralComparison(), diagnoseStringPlusChar(), diagnoseStringPlusInt(), EvaluateHasIncludeCommon(), clang::DeclSpec::Finish(), GenerateNewArgTokens(), clang::Sema::ParseObjCEncodeExpression(), SuggestParentheses(), clang::ConversionFixItGenerator::tryToFixConversion(), and clang::Sema::tryToRecoverWithCall().
MacroDirective* clang::Preprocessor::getMacroDirective | ( | IdentifierInfo * | II | ) | const [inline] |
Given an identifier, return its latest MacroDirective if it is #defined or null if it isn't #define'd.
Definition at line 600 of file Preprocessor.h.
References getMacroDirectiveHistory(), clang::IdentifierInfo::hasMacroDefinition(), and clang::MacroDirective::isDefined().
Referenced by EvaluateDefined(), getMacroInfo(), HandleIdentifier(), and HandlePragmaPopMacro().
MacroDirective * Preprocessor::getMacroDirectiveHistory | ( | const IdentifierInfo * | II | ) | const |
Given an identifier, return the (probably #undef'd) MacroInfo representing the most recent macro definition.
One can iterate over all previous macro definitions from the most recent one. This should only be called for identifiers that hadMacroDefinition().
Definition at line 37 of file PPMacroExpansion.cpp.
References clang::IdentifierInfo::hadMacroDefinition().
Referenced by checkConfigMacro(), clang::CodeCompletionResult::CreateCodeCompletionString(), getMacroDirective(), and isMacroDefined().
const MacroInfo* clang::Preprocessor::getMacroInfo | ( | IdentifierInfo * | II | ) | const [inline] |
Definition at line 609 of file Preprocessor.h.
Referenced by clang::MacroArgs::ArgNeedsPreexpansion(), CheckMacroName(), clang::Sema::getPrintingPolicy(), HandleEndOfFile(), HandlePragmaPushMacro(), and isTrivialSingleTokenExpansion().
MacroInfo* clang::Preprocessor::getMacroInfo | ( | IdentifierInfo * | II | ) | [inline] |
Definition at line 613 of file Preprocessor.h.
References getMacroDirective().
ModuleLoader& clang::Preprocessor::getModuleLoader | ( | ) | const [inline] |
Retrieve the module loader associated with this preprocessor.
Definition at line 521 of file Preprocessor.h.
Referenced by clang::PCHGenerator::HandleTranslationUnit().
PPCallbacks* clang::Preprocessor::getPPCallbacks | ( | ) | const [inline] |
Accessors for preprocessor callbacks.
Note that this class takes ownership of any PPCallbacks object given to it.
Definition at line 589 of file Preprocessor.h.
Referenced by EvaluateDefined().
SourceLocation clang::Preprocessor::getPragmaARCCFCodeAuditedLoc | ( | ) | const [inline] |
The location of the currently-active #pragma clang arc_cf_code_audited begin.
Returns an invalid location if there is no such pragma active.
Definition at line 1007 of file Preprocessor.h.
Referenced by clang::Sema::AddCFAuditedAttribute().
bool clang::Preprocessor::getPragmasEnabled | ( | ) | const [inline] |
Definition at line 541 of file Preprocessor.h.
const std::string& clang::Preprocessor::getPredefines | ( | ) | const [inline] |
Definition at line 659 of file Preprocessor.h.
FileID clang::Preprocessor::getPredefinesFileID | ( | ) | const [inline] |
Returns the FileID for the preprocessor predefines.
Definition at line 582 of file Preprocessor.h.
Referenced by checkConfigMacro(), clang::RewriteIncludesInInput(), and shouldIgnoreMacro().
PreprocessingRecord* clang::Preprocessor::getPreprocessingRecord | ( | ) | const [inline] |
Retrieve the preprocessing record, or NULL if there is no preprocessing record.
Definition at line 723 of file Preprocessor.h.
llvm::BumpPtrAllocator& clang::Preprocessor::getPreprocessorAllocator | ( | ) | [inline] |
Definition at line 506 of file Preprocessor.h.
Referenced by ParseAlignPragma(), and ParseLoopHintValue().
PreprocessorOptions& clang::Preprocessor::getPreprocessorOpts | ( | ) | const [inline] |
Retrieve the preprocessor options used to initialize this preprocessor.
Definition at line 492 of file Preprocessor.h.
PTHManager* clang::Preprocessor::getPTHManager | ( | ) | [inline] |
Definition at line 510 of file Preprocessor.h.
Referenced by AddImplicitIncludePTH().
bool clang::Preprocessor::getRawToken | ( | SourceLocation | Loc, |
Token & | Result, | ||
bool | IgnoreWhiteSpace = false |
||
) | [inline] |
Relex the token at the specified location.
Definition at line 1091 of file Preprocessor.h.
Referenced by UseNSOptionsMacro().
SelectorTable& clang::Preprocessor::getSelectorTable | ( | ) | [inline] |
Definition at line 504 of file Preprocessor.h.
Referenced by clang::Sema::ActOnClassPropertyRefExpr(), clang::CompilerInstance::createASTContext(), clang::Sema::HandleExprPropertyRefExpr(), and LookupMemberExpr().
SourceManager& clang::Preprocessor::getSourceManager | ( | ) | const [inline] |
Definition at line 500 of file Preprocessor.h.
Referenced by clang::DependencyCollector::attachToPreprocessor(), clang::TokenConcatenation::AvoidConcat(), clang::VerifyDiagnosticConsumer::BeginSourceFile(), clang::CacheTokens(), clang::CharLiteralParser::CharLiteralParser(), checkConfigMacro(), clang::Lexer::Create_PragmaLexer(), clang::CompilerInstance::createASTContext(), createPreprocessingRecord(), clang::DoPrintPreprocessedInput(), clang::DoRewriteTest(), emitPremigrationErrors(), EnterSourceFile(), clang::DumpRawTokensAction::ExecuteAction(), clang::DeclSpec::Finish(), clang::PreprocessorLexer::getFileEntry(), GetFirstChar(), GetMappedTokenLoc(), clang::VerifyDiagnosticConsumer::HandleComment(), HandleEndOfFile(), clang::html::HighlightMacros(), clang::ASTWriter::inferSubmoduleIDFromLocation(), clang::TokenLexer::Init(), isExpandedFromConfigurationMacro(), clang::TokenLexer::Lex(), LexRawTokensFromMainFile(), clang::PreprocessorLexer::PreprocessorLexer(), clang::PTHLexer::PTHLexer(), ReadLineMarkerFlags(), clang::RewriteIncludesInInput(), clang::RewriteMacrosInInput(), shouldIgnoreMacro(), and clang::html::SyntaxHighlight().
StringRef clang::Preprocessor::getSpelling | ( | SourceLocation | loc, |
SmallVectorImpl< char > & | buffer, | ||
bool * | invalid = nullptr |
||
) | const [inline] |
Return the 'spelling' of the token at the given location; does not go up to the spelling location or down to the expansion location.
buffer | A buffer which will be used only if the token requires "cleaning", e.g. if it contains trigraphs or escaped newlines |
invalid | If non-null, will be set true if an error occurs. |
Definition at line 1046 of file Preprocessor.h.
Referenced by buildMSAsmString(), CheckMacroName(), ConcatenateIncludeName(), clang::DoRewriteTest(), DumpToken(), EvaluateHasIncludeCommon(), EvaluateValue(), GetFirstChar(), GetLineValue(), getSpelling(), HandlePragmaDependency(), HandlePragmaIncludeAlias(), clang::MacroInfo::isIdenticalTo(), LookUpIdentifierInfo(), ParseOpenMPDirectiveKind(), ParsePragmaPushOrPopMacro(), parseSimpleIntegerLiteral(), PrintMacroDefinition(), PrintPreprocessedTokens(), clang::RewriteMacrosInInput(), and clang::MacroArgs::StringifyArgument().
std::string clang::Preprocessor::getSpelling | ( | const Token & | Tok, |
bool * | Invalid = nullptr |
||
) | const [inline] |
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.
Invalid | If non-null, will be set true if an error occurs. |
Definition at line 1060 of file Preprocessor.h.
References getSpelling().
unsigned clang::Preprocessor::getSpelling | ( | const Token & | Tok, |
const char *& | Buffer, | ||
bool * | Invalid = nullptr |
||
) | const [inline] |
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.
Definition at line 1076 of file Preprocessor.h.
References getSpelling().
StringRef Preprocessor::getSpelling | ( | const Token & | Tok, |
SmallVectorImpl< char > & | Buffer, | ||
bool * | Invalid = nullptr |
||
) | const |
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.
getSpelling - This method is used to 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.
Definition at line 423 of file Preprocessor.cpp.
References clang::Token::getIdentifierInfo(), clang::Token::getLength(), getSpelling(), clang::Token::hasUCN(), clang::Token::isNot(), and clang::Token::needsCleaning().
char clang::Preprocessor::getSpellingOfSingleCharacterNumericConstant | ( | const Token & | Tok, |
bool * | Invalid = nullptr |
||
) | const [inline] |
Given a Token Tok
that is a numeric constant with length 1, return the character.
Definition at line 1099 of file Preprocessor.h.
References clang::SourceManager::getCharacterData(), clang::Token::getLength(), clang::Token::getLiteralData(), clang::Token::getLocation(), clang::Token::is(), and clang::Token::needsCleaning().
bool clang::Preprocessor::GetSuppressIncludeNotFoundError | ( | ) | [inline] |
Definition at line 547 of file Preprocessor.h.
const TargetInfo& clang::Preprocessor::getTargetInfo | ( | ) | const [inline] |
Definition at line 498 of file Preprocessor.h.
Referenced by clang::CharLiteralParser::CharLiteralParser(), EvaluateValue(), clang::DeclSpec::Finish(), clang::Parser::getTargetInfo(), HasExtension(), HasFeature(), and clang::InitializePreprocessor().
size_t Preprocessor::getTotalMemory | ( | ) | const |
Definition at line 289 of file Preprocessor.cpp.
Referenced by PrintStats().
bool clang::Preprocessor::hadModuleLoaderFatalFailure | ( | ) | const [inline] |
Definition at line 523 of file Preprocessor.h.
References clang::ModuleLoader::HadFatalFailure.
bool Preprocessor::HandleComment | ( | Token & | Token, |
SourceRange | Comment | ||
) |
Definition at line 831 of file Preprocessor.cpp.
References getCommentRetentionState(), and Lex().
void Preprocessor::HandleDirective | ( | Token & | Result | ) |
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.
HandleDirective - This callback is 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.
Definition at line 676 of file PPDirectives.cpp.
References clang::CodeCompletionHandler::CodeCompleteDirective(), Diag(), DiscardUntilEndOfDirective(), EnterTokenStream(), clang::PreprocessorLexer::getConditionalStackDepth(), clang::MultipleIncludeOpt::getHasReadAnyTokensVal(), clang::Token::getIdentifierInfo(), clang::MultipleIncludeOpt::getImmediatelyAfterTopLevelIfndef(), clang::Token::getKind(), getLangOpts(), clang::Token::getLocation(), clang::IdentifierInfo::getPPKeywordID(), clang::Token::is(), LexUnexpandedToken(), clang::PreprocessorLexer::MIOpt, clang::PreprocessorLexer::ParsingPreprocessorDirective, clang::PIK_HashPragma, clang::MultipleIncludeOpt::resetImmediatelyAfterTopLevelIfndef(), and setCodeCompletionReached().
Referenced by clang::PTHLexer::Lex().
bool Preprocessor::HandleEndOfFile | ( | Token & | Result, |
bool | isEndOfMacro = false |
||
) |
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.
HandleEndOfFile - This callback is invoked when the lexer hits the end of the current file. This either returns the EOF token or pops a level off the include stack and keeps going.
Definition at line 294 of file PPLexerChange.cpp.
References computeRelativePath(), clang::FixItHint::CreateReplacement(), Diag(), clang::comments::tok::eof, clang::PPCallbacks::ExitFile, clang::HeaderSearch::FirstTimeLexingFile(), clang::MultipleIncludeOpt::GetControllingMacroAtEndOfFile(), getCurrentModule(), clang::MultipleIncludeOpt::GetDefinedLocation(), clang::MultipleIncludeOpt::GetDefinedMacro(), getDiagnostics(), clang::FileManager::getFile(), clang::SourceManager::getFileCharacteristic(), clang::SourceManager::getFileEntryForID(), clang::PreprocessorLexer::getFileID(), getFileManager(), getHeaderSearchInfo(), clang::SourceManager::getIncludeLoc(), clang::PreprocessorLexer::getInitialNumSLocEntries(), clang::Token::getLocation(), clang::SourceManager::getLocForStartOfFile(), clang::SourceLocation::getLocWithOffset(), getMacroInfo(), clang::MultipleIncludeOpt::GetMacroLocation(), clang::SourceManager::getMainFileID(), clang::HeaderSearch::getModuleMap(), clang::DirectoryEntry::getName(), clang::PreprocessorLexer::getSourceLocation(), getSourceManager(), clang::FileManager::getVirtualFileSystem(), clang::SourceManager::hasFileInfo(), clang::vfs::recursive_directory_iterator::increment(), isCodeCompletionEnabled(), clang::ModuleMap::isHeaderInUnavailableModule(), clang::DiagnosticsEngine::isIgnored(), isIncrementalProcessingEnabled(), clang::SourceLocation::isValid(), clang::SourceManager::local_sloc_entry_size(), clang::PreprocessorLexer::MIOpt, RemoveTopOfLexerStack(), clang::Token::setAnnotationEndLoc(), clang::Token::setAnnotationValue(), clang::HeaderSearch::SetFileControllingMacro(), clang::Token::setLocation(), clang::SourceManager::setNumCreatedFIDsForFileID(), clang::Token::startToken(), and clang::TU_Complete.
Referenced by HandleEndOfTokenLexer().
bool Preprocessor::HandleEndOfTokenLexer | ( | Token & | Result | ) |
Callback invoked when the current TokenLexer hits the end of its token stream.
HandleEndOfTokenLexer - This callback is invoked when the current TokenLexer hits the end of its token stream.
Definition at line 509 of file PPLexerChange.cpp.
References HandleEndOfFile().
Referenced by HandleMicrosoftCommentPaste(), and clang::TokenLexer::Lex().
bool Preprocessor::HandleIdentifier | ( | Token & | Identifier | ) |
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').
HandleIdentifier - This callback is invoked when the lexer reads an identifier. This callback looks up the identifier in the map and/or potentially macro expands it or turns it into a named token (like 'for').
Note that callers of this method are guarded by checking the IdentifierInfo's 'isHandleIdentifierCase' bit. If this method changes, the IdentifierInfo methods that compute these properties will need to change to match.
Definition at line 595 of file Preprocessor.cpp.
References Diag(), clang::Token::DisableExpand, clang::Token::getIdentifierInfo(), getLangOpts(), clang::Token::getLocation(), getMacroDirective(), HandlePoisonedIdentifier(), clang::MacroInfo::isEnabled(), clang::Token::isExpandDisabled(), clang::MacroInfo::isFunctionLike(), clang::MacroInfo::isObjectLike(), clang::IdentifierInfo::isPoisoned(), clang::Token::setFlag(), clang::Token::setIdentifierInfo(), clang::Token::setKind(), and clang::ExternalPreprocessorSource::updateOutOfDateIdentifier().
Referenced by clang::PTHLexer::Lex(), and clang::TokenLexer::Lex().
void Preprocessor::HandleMicrosoftCommentPaste | ( | Token & | Tok | ) |
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.
HandleMicrosoftCommentPaste - 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.
Definition at line 547 of file PPLexerChange.cpp.
References clang::comments::tok::eof, HandleEndOfTokenLexer(), clang::Token::is(), clang::Token::isNot(), Lex(), clang::PreprocessorLexer::LexingRawMode, and clang::PreprocessorLexer::ParsingPreprocessorDirective.
void Preprocessor::HandlePoisonedIdentifier | ( | Token & | Tok | ) |
Display reason for poisoned identifier.
Definition at line 576 of file Preprocessor.cpp.
References Diag(), and clang::Token::getIdentifierInfo().
Referenced by HandleIdentifier(), clang::TokenLexer::Lex(), and MaybeHandlePoisonedIdentifier().
void Preprocessor::HandlePragmaDependency | ( | Token & | DependencyTok | ) |
HandlePragmaDependency - Handle #pragma GCC dependency "foo" blah.
Definition at line 451 of file Pragma.cpp.
References Diag(), getCurrentFileLexer(), clang::PreprocessorLexer::getFileEntry(), GetIncludeFilenameSpelling(), clang::Token::getLocation(), clang::FileEntry::getModificationTime(), getSpelling(), clang::Token::is(), clang::Token::isNot(), Lex(), clang::PreprocessorLexer::LexIncludeFilename(), and LookupFile().
void Preprocessor::HandlePragmaIncludeAlias | ( | Token & | Tok | ) |
Definition at line 621 of file Pragma.cpp.
References clang::HeaderSearch::AddIncludeAlias(), ConcatenateIncludeName(), Diag(), getHeaderSearchInfo(), GetIncludeFilenameSpelling(), clang::Token::getLocation(), getSpelling(), clang::Token::is(), clang::Token::isNot(), Lex(), and clang::PreprocessorLexer::LexIncludeFilename().
void Preprocessor::HandlePragmaMark | ( | ) |
Definition at line 364 of file Pragma.cpp.
void Preprocessor::HandlePragmaOnce | ( | Token & | OnceTok | ) |
HandlePragmaOnce - Handle #pragma once. OnceTok is the 'once'.
Definition at line 353 of file Pragma.cpp.
References Diag(), getCurrentFileLexer(), isInPrimaryFile(), and clang::HeaderSearch::MarkFileIncludeOnce().
void Preprocessor::HandlePragmaPoison | ( | Token & | PoisonTok | ) |
HandlePragmaPoison - Handle #pragma GCC poison. PoisonTok is the 'poison'.
Definition at line 375 of file Pragma.cpp.
References Diag(), clang::IdentifierInfo::hasMacroDefinition(), clang::Token::is(), clang::IdentifierInfo::isFromAST(), clang::Token::isNot(), clang::IdentifierInfo::isPoisoned(), clang::PreprocessorLexer::LexingRawMode, LexUnexpandedToken(), LookUpIdentifierInfo(), clang::IdentifierInfo::setChangedSinceDeserialization(), and clang::IdentifierInfo::setIsPoisoned().
void Preprocessor::HandlePragmaPopMacro | ( | Token & | PopMacroTok | ) |
Handle #pragma pop_macro.
The syntax is:
#pragma pop_macro("macro")
Definition at line 583 of file Pragma.cpp.
References appendDefMacroDirective(), appendMacroDirective(), Diag(), clang::MacroInfo::getDefinitionLoc(), clang::Token::getLocation(), getMacroDirective(), clang::IdentifierInfo::getName(), clang::MacroInfo::isWarnIfUnused(), and ParsePragmaPushOrPopMacro().
void Preprocessor::HandlePragmaPushMacro | ( | Token & | PushMacroTok | ) |
Handle #pragma push_macro.
The syntax is:
#pragma push_macro("macro")
Definition at line 560 of file Pragma.cpp.
References getMacroInfo(), ParsePragmaPushOrPopMacro(), and clang::MacroInfo::setIsAllowRedefinitionsWithoutWarning().
void Preprocessor::HandlePragmaSystemHeader | ( | Token & | SysHeaderTok | ) |
HandlePragmaSystemHeader - Implement #pragma GCC system_header. We know that the whole directive has been parsed.
Definition at line 417 of file Pragma.cpp.
References clang::SourceManager::AddLineNote(), clang::SrcMgr::C_System, Diag(), getCurrentFileLexer(), clang::PreprocessorLexer::getFileEntry(), clang::PresumedLoc::getFilename(), clang::PresumedLoc::getLine(), clang::SourceManager::getLineTableFilenameID(), clang::Token::getLocation(), clang::SourceManager::getPresumedLoc(), isInPrimaryFile(), clang::PresumedLoc::isInvalid(), clang::HeaderSearch::MarkFileSystemHeader(), and clang::PPCallbacks::SystemHeaderPragma.
void Preprocessor::IgnorePragmas | ( | ) |
Install empty handlers for all pragmas (making them ignored).
Ignore all pragmas, useful for modes such as -Eonly which would otherwise warn about those pragmas being unknown.
Definition at line 1393 of file Pragma.cpp.
References AddPragmaHandler(), clang::PragmaNamespace::FindHandler(), clang::PragmaNamespace::getIfNamespace(), and RemovePragmaHandler().
Referenced by DoPrintMacros(), clang::PreprocessOnlyAction::ExecuteAction(), and clang::RewriteIncludesInInput().
void clang::Preprocessor::IncrementPasteCounter | ( | bool | isFast | ) | [inline] |
Increment the counters for the number of token paste operations performed.
If fast was specified, this is a 'fast paste' case we handled.
Definition at line 1191 of file Preprocessor.h.
void Preprocessor::Initialize | ( | const TargetInfo & | Target | ) |
Initialize the preprocessor using information about the target.
Target | is owned by the caller and must remain valid for the lifetime of the preprocessor. |
Definition at line 172 of file Preprocessor.cpp.
References BuiltinInfo, and clang::HeaderSearch::setTarget().
void Preprocessor::InitializeForModelFile | ( | ) |
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.
Definition at line 182 of file Preprocessor.cpp.
bool clang::Preprocessor::isAtEndOfMacroExpansion | ( | SourceLocation | loc, |
SourceLocation * | MacroEnd = nullptr |
||
) | const [inline] |
Returns true if the given MacroID location points at the last token of the macro expansion.
MacroEnd | If non-null and function returns true, it is set to end location of the macro. |
Definition at line 1170 of file Preprocessor.h.
bool clang::Preprocessor::isAtStartOfMacroExpansion | ( | SourceLocation | loc, |
SourceLocation * | MacroBegin = nullptr |
||
) | const [inline] |
Returns true if the given MacroID location points at the first token of the macro expansion.
MacroBegin | If non-null and function returns true, it is set to begin location of the macro. |
Definition at line 1159 of file Preprocessor.h.
bool clang::Preprocessor::isBacktrackEnabled | ( | ) | const [inline] |
True if EnableBacktrackAtThisPos() was called and caching of tokens is on.
Definition at line 796 of file Preprocessor.h.
Referenced by AnnotateCachedTokens(), ReplaceLastTokenWithAnnotation(), RevertCachedTokens(), and TypoCorrectToken().
bool clang::Preprocessor::isCodeCompletionEnabled | ( | ) | const [inline] |
Determine if we are performing code completion.
Definition at line 975 of file Preprocessor.h.
Referenced by clang::Sema::ActOnEndOfTranslationUnit(), EnterSourceFile(), HandleEndOfFile(), clang::Parser::Parser(), and setCodeCompletionReached().
bool clang::Preprocessor::isCodeCompletionReached | ( | ) | const [inline] |
Returns true if code-completion is enabled and we have hit the code-completion point.
Definition at line 993 of file Preprocessor.h.
bool clang::Preprocessor::isCurrentLexer | ( | const PreprocessorLexer * | L | ) | const [inline] |
Return true if we are lexing directly from the specified lexer.
Definition at line 562 of file Preprocessor.h.
bool clang::Preprocessor::isIncrementalProcessingEnabled | ( | ) | const [inline] |
Returns true if incremental processing is enabled.
Definition at line 950 of file Preprocessor.h.
Referenced by HandleEndOfFile(), and clang::Parser::ParseTopLevelDecl().
bool Preprocessor::isInPrimaryFile | ( | ) | const |
Return true if we're in the top-level file, not in a #include.
isInPrimaryFile - Return true if we're in the top-level file, not in a #include. This looks through macro expansions and active _Pragma lexers.
Definition at line 35 of file PPLexerChange.cpp.
Referenced by EvaluateHasIncludeNext(), HandlePragmaOnce(), and HandlePragmaSystemHeader().
bool clang::Preprocessor::isParsingIfOrElifDirective | ( | ) | const [inline] |
True if we are currently preprocessing a #if or #elif directive.
Definition at line 528 of file Preprocessor.h.
Referenced by EvaluateHasIncludeCommon().
bool clang::Preprocessor::isPreprocessedOutput | ( | ) | const [inline] |
Returns true if the preprocessor is responsible for generating output, false if it is producing tokens to be consumed by Parse and Sema.
Definition at line 559 of file Preprocessor.h.
void Preprocessor::Lex | ( | Token & | Result | ) |
Lex the next token for this preprocessor.
Definition at line 685 of file Preprocessor.cpp.
References clang::Token::is(), and LexAfterModuleImport().
Referenced by clang::CacheTokens(), CheckEndOfDirective(), ConcatenateIncludeName(), clang::Parser::ConsumeToken(), DoPrintMacros(), clang::DoPrintPreprocessedInput(), EvaluateHasIncludeCommon(), clang::DumpTokensAction::ExecuteAction(), clang::PreprocessOnlyAction::ExecuteAction(), FinishLexStringLiteral(), FixDigraph(), clang::MacroArgs::getPreExpArgument(), HandleComment(), HandleMicrosoftCommentPaste(), HandlePragmaDependency(), HandlePragmaIncludeAlias(), LexAfterModuleImport(), clang::PreprocessorLexer::LexIncludeFilename(), LexNonComment(), LexStringLiteral(), LexUnexpandedToken(), ParseAlignPragma(), ParseLoopHintValue(), ParsePragmaPushOrPopMacro(), parseSimpleIntegerLiteral(), PrintPreprocessedTokens(), ReadLineMarkerFlags(), clang::RewriteIncludesInInput(), clang::RewriteMacrosInInput(), clang::Parser::TryAnnotateTypeOrScopeToken(), and clang::Parser::TryConsumeToken().
void Preprocessor::LexAfterModuleImport | ( | Token & | Result | ) |
Lex a token following the 'import' contextual keyword.
Definition at line 716 of file Preprocessor.cpp.
References clang::Token::getIdentifierInfo(), clang::Token::getKind(), getLangOpts(), clang::Token::getLocation(), Lex(), clang::ModuleLoader::loadModule(), clang::Module::MacrosVisible, and recomputeCurLexerKind().
Referenced by Lex().
void clang::Preprocessor::LexNonComment | ( | Token & | Result | ) | [inline] |
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.
Definition at line 827 of file Preprocessor.h.
References clang::Token::getKind(), and Lex().
Referenced by EvaluateBuildingModule(), EvaluateDefined(), EvaluateDirectiveSubExpr(), EvaluateHasIncludeCommon(), and EvaluateValue().
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.
Definition at line 782 of file Pragma.cpp.
References Diag(), clang::Token::getIdentifierInfo(), clang::Token::isNot(), clang::IdentifierInfo::isStr(), LexUnexpandedToken(), clang::tok::OOS_DEFAULT, clang::tok::OOS_OFF, and clang::tok::OOS_ON.
bool clang::Preprocessor::LexStringLiteral | ( | Token & | Result, |
std::string & | String, | ||
const char * | DiagnosticTag, | ||
bool | AllowMacroExpansion | ||
) | [inline] |
Lex a string literal, which may be the concatenation of multiple string literals and may even come from macro expansion.
Definition at line 806 of file Preprocessor.h.
References FinishLexStringLiteral(), Lex(), and LexUnexpandedToken().
void clang::Preprocessor::LexUnexpandedNonComment | ( | Token & | Result | ) | [inline] |
Like LexNonComment, but this disables macro expansion of identifier tokens.
Definition at line 847 of file Preprocessor.h.
References clang::Token::getKind(), and LexUnexpandedToken().
Referenced by EvaluateDefined().
void clang::Preprocessor::LexUnexpandedToken | ( | Token & | Result | ) | [inline] |
Just like Lex, but disables macro expansion of identifier tokens.
Definition at line 834 of file Preprocessor.h.
References Lex().
Referenced by CheckEndOfDirective(), DiscardUntilEndOfDirective(), FinishLexStringLiteral(), HandleDirective(), clang::PragmaNamespace::HandlePragma(), HandlePragmaPoison(), LexOnOffSwitch(), LexStringLiteral(), and LexUnexpandedNonComment().
const Token& clang::Preprocessor::LookAhead | ( | unsigned | N | ) | [inline] |
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'.
Definition at line 871 of file Preprocessor.h.
Referenced by clang::Parser::NextToken(), and ParseOpenMPDirectiveKind().
const FileEntry * Preprocessor::LookupFile | ( | SourceLocation | FilenameLoc, |
StringRef | Filename, | ||
bool | isAngled, | ||
const DirectoryLookup * | FromDir, | ||
const FileEntry * | FromFile, | ||
const DirectoryLookup *& | CurDir, | ||
SmallVectorImpl< char > * | SearchPath, | ||
SmallVectorImpl< char > * | RelativePath, | ||
ModuleMap::KnownHeader * | SuggestedModule, | ||
bool | SkipCache = false |
||
) |
Given a "foo" or <foo> reference, look up the indicated file.
Returns null on failure. isAngled
indicates whether the file reference is for system #include's or not (i.e. using <> instead of "").
Definition at line 533 of file PPDirectives.cpp.
References clang::ModuleMap::diagnoseHeaderInclusion(), getCurrentFileLexer(), clang::FileEntry::getDir(), clang::FileManager::getDirectory(), clang::SourceManager::getFileEntryForID(), clang::PreprocessorLexer::getFileID(), clang::SourceManager::getMainFileID(), clang::HeaderSearch::getModuleMap(), clang::HeaderSearch::LookupFile(), and clang::HeaderSearch::LookupSubframeworkHeader().
Referenced by EvaluateHasIncludeCommon(), HandlePragmaDependency(), and ParseDirective().
IdentifierInfo * Preprocessor::LookUpIdentifierInfo | ( | Token & | Identifier | ) | const |
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.
LookUpIdentifierInfo - 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.
Definition at line 529 of file Preprocessor.cpp.
References clang::expandUCNs(), getIdentifierInfo(), clang::Token::getRawIdentifier(), getSpelling(), clang::Token::hasUCN(), clang::Token::needsCleaning(), clang::Token::setIdentifierInfo(), and clang::Token::setKind().
Referenced by HandlePragmaPoison(), clang::html::HighlightMacros(), LexRawTokensFromMainFile(), ParsePragmaPushOrPopMacro(), and clang::html::SyntaxHighlight().
Preprocessor::macro_iterator Preprocessor::macro_begin | ( | bool | IncludeExternalMacros = true | ) | const |
Definition at line 279 of file Preprocessor.cpp.
References clang::ExternalPreprocessorSource::ReadDefinedMacros().
Referenced by AddMacroResults(), DoPrintMacros(), and getLastMacroWithSpelling().
Preprocessor::macro_iterator Preprocessor::macro_end | ( | bool | IncludeExternalMacros = true | ) | const |
Definition at line 300 of file Preprocessor.cpp.
References clang::ExternalPreprocessorSource::ReadDefinedMacros().
Referenced by AddMacroResults(), DoPrintMacros(), and getLastMacroWithSpelling().
void Preprocessor::markMacroAsUsed | ( | MacroInfo * | MI | ) |
A macro is used, update information about macros that need unused warnings.
Definition at line 1560 of file PPMacroExpansion.cpp.
References clang::MacroInfo::getDefinitionLoc(), clang::MacroInfo::isUsed(), clang::MacroInfo::isWarnIfUnused(), and clang::MacroInfo::setIsUsed().
Referenced by EvaluateDefined().
void clang::Preprocessor::MaybeHandlePoisonedIdentifier | ( | Token & | Identifier | ) | [inline] |
Definition at line 1230 of file Preprocessor.h.
References clang::Token::getIdentifierInfo(), and HandlePoisonedIdentifier().
ParsePragmaPushOrPopMacro - Handle parsing of pragma push_macro/pop_macro. Return the IdentifierInfo* associated with the macro to push or pop.
Definition at line 505 of file Pragma.cpp.
References CreateString(), Diag(), clang::Token::getLocation(), getSpelling(), clang::Token::hasUDSuffix(), clang::Token::isNot(), Lex(), LookUpIdentifierInfo(), and clang::Token::startToken().
Referenced by HandlePragmaPopMacro(), and HandlePragmaPushMacro().
bool Preprocessor::parseSimpleIntegerLiteral | ( | Token & | Tok, |
uint64_t & | Value | ||
) |
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.
Definition at line 799 of file Preprocessor.cpp.
References clang::Token::getLocation(), getSpelling(), clang::Token::is(), and Lex().
void Preprocessor::PoisonSEHIdentifiers | ( | bool | Poison = true | ) |
Definition at line 562 of file Preprocessor.cpp.
References clang::IdentifierInfo::setIsPoisoned().
void Preprocessor::PrintStats | ( | ) |
Definition at line 242 of file Preprocessor.cpp.
References getTotalMemory().
Referenced by clang::FrontendAction::EndSourceFile().
void Preprocessor::recomputeCurLexerKind | ( | ) |
Recompute the current lexer kind based on the CurLexer/CurPTHLexer/ CurTokenLexer pointers.
Definition at line 344 of file Preprocessor.cpp.
Referenced by Backtrack(), and LexAfterModuleImport().
void Preprocessor::removeCommentHandler | ( | CommentHandler * | Handler | ) |
Remove the specified comment handler.
It is an error to remove a handler that has not been registered.
Definition at line 824 of file Preprocessor.cpp.
Referenced by clang::Parser::~Parser().
void Preprocessor::RemovePragmaHandler | ( | StringRef | Namespace, |
PragmaHandler * | Handler | ||
) |
Remove the specific pragma handler from this preprocessor.
If Namespace
is non-null, then it should be the namespace that Handler
was added to. It is an error to remove a handler that has not been registered.
RemovePragmaHandler - Remove the specific pragma handler from the preprocessor. If
Definition at line 760 of file Pragma.cpp.
References clang::PragmaHandler::getIfNamespace(), clang::PragmaNamespace::IsEmpty(), and clang::PragmaNamespace::RemovePragmaHandler().
Referenced by IgnorePragmas(), and RemovePragmaHandler().
void clang::Preprocessor::RemovePragmaHandler | ( | PragmaHandler * | Handler | ) | [inline] |
Definition at line 687 of file Preprocessor.h.
References RemovePragmaHandler().
void Preprocessor::RemoveTopOfLexerStack | ( | ) |
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.
RemoveTopOfLexerStack - 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 unknown.
Definition at line 530 of file PPLexerChange.cpp.
Referenced by clang::MacroArgs::getPreExpArgument(), and HandleEndOfFile().
void clang::Preprocessor::ReplaceLastTokenWithAnnotation | ( | const Token & | Tok | ) | [inline] |
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.
Definition at line 931 of file Preprocessor.h.
References clang::Token::isAnnotation(), and isBacktrackEnabled().
void clang::Preprocessor::RevertCachedTokens | ( | unsigned | N | ) | [inline] |
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.
Definition at line 883 of file Preprocessor.h.
References isBacktrackEnabled().
bool clang::Preprocessor::SawDateOrTime | ( | ) | const [inline] |
Returns true if the preprocessor has seen a use of __DATE__ or __TIME__ in the file so far.
Definition at line 1301 of file Preprocessor.h.
void clang::Preprocessor::setCodeCompletionHandler | ( | CodeCompletionHandler & | Handler | ) | [inline] |
Set the code completion handler to the given object.
Definition at line 703 of file Preprocessor.h.
Referenced by clang::Parser::Parser().
bool Preprocessor::SetCodeCompletionPoint | ( | const FileEntry * | File, |
unsigned | Line, | ||
unsigned | Column | ||
) |
Specify the point at which code-completion will be performed.
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. |
Line | the line at which code completion should occur (1-based). |
Column | the column at which code completion should occur (1-based). |
Definition at line 355 of file Preprocessor.cpp.
References clang::SourceManager::getFileEntryForID(), clang::SourceManager::getMainFileID(), clang::SourceManager::getMemoryBufferForFile(), Line, clang::SourceManager::overrideFileContents(), Position, and SourceMgr.
Referenced by EnableCodeCompletion().
void clang::Preprocessor::setCodeCompletionReached | ( | ) | [inline] |
Note that we hit the code-completion point.
Definition at line 996 of file Preprocessor.h.
References getDiagnostics(), isCodeCompletionEnabled(), and clang::DiagnosticsEngine::setSuppressAllDiagnostics().
Referenced by CodeCompleteNaturalLanguage(), ConcatenateIncludeName(), EvaluateDefined(), EvaluateValue(), and HandleDirective().
void clang::Preprocessor::SetCommentRetentionState | ( | bool | KeepComments, |
bool | KeepMacroComments | ||
) | [inline] |
Control whether the preprocessor retains comments in output.
Definition at line 533 of file Preprocessor.h.
Referenced by clang::DoPrintPreprocessedInput().
void clang::Preprocessor::setCounterValue | ( | unsigned | V | ) | [inline] |
Definition at line 1305 of file Preprocessor.h.
void clang::Preprocessor::setDiagnostics | ( | DiagnosticsEngine & | D | ) | [inline] |
Definition at line 495 of file Preprocessor.h.
void clang::Preprocessor::setExternalSource | ( | ExternalPreprocessorSource * | Source | ) | [inline] |
Definition at line 512 of file Preprocessor.h.
void Preprocessor::setLoadedMacroDirective | ( | IdentifierInfo * | II, |
MacroDirective * | MD | ||
) |
Set a MacroDirective that was loaded from a PCH file.
Definition at line 62 of file PPMacroExpansion.cpp.
References clang::MacroDirective::isDefined(), and clang::IdentifierInfo::setHasMacroDefinition().
void clang::Preprocessor::SetMacroExpansionOnlyInDirectives | ( | ) | [inline] |
Disables macro expansion everywhere except for preprocessor directives.
Definition at line 859 of file Preprocessor.h.
Referenced by clang::RewriteIncludesInInput().
void Preprocessor::SetPoisonReason | ( | IdentifierInfo * | II, |
unsigned | DiagID | ||
) |
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.
Definition at line 558 of file Preprocessor.cpp.
Referenced by clang::Parser::Initialize(), and Preprocessor().
void clang::Preprocessor::setPragmaARCCFCodeAuditedLoc | ( | SourceLocation | Loc | ) | [inline] |
Set the location of the currently-active #pragma clang arc_cf_code_audited begin. An invalid location ends the pragma.
Definition at line 1013 of file Preprocessor.h.
void clang::Preprocessor::setPragmasEnabled | ( | bool | Enabled | ) | [inline] |
Definition at line 540 of file Preprocessor.h.
void clang::Preprocessor::setPredefines | ( | const char * | P | ) | [inline] |
Set the predefines for this Preprocessor.
These predefines are automatically injected when parsing the main file.
Definition at line 663 of file Preprocessor.h.
References P.
Referenced by createASTReader(), clang::CompilerInstance::createPCHExternalASTSource(), and clang::InitializePreprocessor().
void clang::Preprocessor::setPredefines | ( | const std::string & | P | ) | [inline] |
Definition at line 664 of file Preprocessor.h.
References P.
void clang::Preprocessor::setPreprocessedOutput | ( | bool | IsPreprocessedOutput | ) | [inline] |
Sets whether the preprocessor is responsible for producing output or if it is producing tokens to be consumed by Parse and Sema.
Definition at line 553 of file Preprocessor.h.
void Preprocessor::setPTHManager | ( | PTHManager * | pm | ) |
Definition at line 200 of file Preprocessor.cpp.
References clang::FileManager::addStatCache().
void clang::Preprocessor::setSkipMainFilePreamble | ( | unsigned | Bytes, |
bool | StartOfLine | ||
) | [inline] |
Instruct the preprocessor to skip part of the main source file.
Bytes | The number of bytes in the preamble to skip. |
StartOfLine | Whether skipping these bytes puts the lexer at the start of a line. |
Definition at line 1023 of file Preprocessor.h.
Referenced by clang::InitializePreprocessor().
void clang::Preprocessor::SetSuppressIncludeNotFoundError | ( | bool | Suppress | ) | [inline] |
Definition at line 543 of file Preprocessor.h.
Referenced by clang::DependencyFileGenerator::CreateAndAttachToPreprocessor().
void clang::Preprocessor::TypoCorrectToken | ( | const Token & | Tok | ) | [inline] |
Update the current token to represent the provided identifier, in order to cache an action performed by typo correction.
Definition at line 939 of file Preprocessor.h.
References clang::Token::getIdentifierInfo(), and isBacktrackEnabled().
friend class ASTReader [friend] |
Definition at line 364 of file Preprocessor.h.
friend class MacroArgs [friend] |
Definition at line 381 of file Preprocessor.h.
void TokenLexer::ExpandFunctionArguments | ( | ) | [friend] |