clang API Documentation

Classes | Public Types | Public Member Functions | Friends
clang::Preprocessor Class Reference

#include <Preprocessor.h>

Inheritance diagram for clang::Preprocessor:
Inheritance graph
[legend]
Collaboration diagram for clang::Preprocessor:
Collaboration graph
[legend]

List of all members.

Classes

struct  IncludeStackInfo
struct  MacroInfoChain

Public Types

typedef llvm::DenseMap
< IdentifierInfo *, MacroInfo * >
::const_iterator 
macro_iterator

Public Member Functions

 Preprocessor (DiagnosticsEngine &diags, LangOptions &opts, const TargetInfo *target, SourceManager &SM, HeaderSearch &Headers, ModuleLoader &TheModuleLoader, IdentifierInfoLookup *IILookup=0, bool OwnsHeaderSearch=false, bool DelayInitialization=false)
 ~Preprocessor ()
void Initialize (const TargetInfo &Target)
 Initialize the preprocessor, if the constructor did not already perform the initialization.
DiagnosticsEnginegetDiagnostics () const
void setDiagnostics (DiagnosticsEngine &D)
const LangOptionsgetLangOptions () const
const TargetInfogetTargetInfo () const
FileManagergetFileManager () const
SourceManagergetSourceManager () const
HeaderSearchgetHeaderSearchInfo () const
IdentifierTablegetIdentifierTable ()
SelectorTablegetSelectorTable ()
Builtin::ContextgetBuiltinInfo ()
llvm::BumpPtrAllocator & getPreprocessorAllocator ()
void setPTHManager (PTHManager *pm)
PTHManagergetPTHManager ()
void setExternalSource (ExternalPreprocessorSource *Source)
ExternalPreprocessorSourcegetExternalSource () const
ModuleLoadergetModuleLoader () const
 Retrieve the module loader associated with this preprocessor.
void SetCommentRetentionState (bool KeepComments, bool KeepMacroComments)
bool getCommentRetentionState () const
void SetSuppressIncludeNotFoundError (bool Suppress)
bool GetSuppressIncludeNotFoundError ()
bool isCurrentLexer (const PreprocessorLexer *L) const
PreprocessorLexergetCurrentLexer () const
PreprocessorLexergetCurrentFileLexer () const
PPCallbacksgetPPCallbacks () const
void addPPCallbacks (PPCallbacks *C)
MacroInfogetMacroInfo (IdentifierInfo *II) const
void setMacroInfo (IdentifierInfo *II, MacroInfo *MI, bool LoadedFromAST=false)
macro_iterator macro_begin (bool IncludeExternalMacros=true) const
macro_iterator macro_end (bool IncludeExternalMacros=true) const
const std::string & getPredefines () const
void setPredefines (const char *P)
void setPredefines (const std::string &P)
IdentifierInfogetIdentifierInfo (StringRef Name) const
void AddPragmaHandler (StringRef Namespace, PragmaHandler *Handler)
void AddPragmaHandler (PragmaHandler *Handler)
void RemovePragmaHandler (StringRef Namespace, PragmaHandler *Handler)
void RemovePragmaHandler (PragmaHandler *Handler)
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.
CodeCompletionHandlergetCodeCompletionHandler () 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.
PreprocessingRecordgetPreprocessingRecord () const
 Retrieve the preprocessing record, or NULL if there is no preprocessing record.
void createPreprocessingRecord (bool IncludeNestedMacroExpansions)
 Create a new preprocessing record, which will keep track of all macro expansions, macro definitions, etc.
void EnterMainSourceFile ()
void EndSourceFile ()
void EnterSourceFile (FileID CurFileID, const DirectoryLookup *Dir, SourceLocation Loc)
void EnterMacro (Token &Identifier, SourceLocation ILEnd, MacroArgs *Args)
void EnterTokenStream (const Token *Toks, unsigned NumToks, bool DisableMacroExpansion, bool OwnsTokens)
void RemoveTopOfLexerStack ()
void EnableBacktrackAtThisPos ()
void CommitBacktrackedTokens ()
 CommitBacktrackedTokens - Disable the last EnableBacktrackAtThisPos call.
void Backtrack ()
bool isBacktrackEnabled () const
void Lex (Token &Result)
void LexAfterModuleImport (Token &Result)
 Lex a token following the 'import' contextual keyword.
void LexNonComment (Token &Result)
void LexUnexpandedToken (Token &Result)
void LexUnexpandedNonComment (Token &Result)
const TokenLookAhead (unsigned N)
void RevertCachedTokens (unsigned N)
void EnterToken (const Token &Tok)
void AnnotateCachedTokens (const Token &Tok)
void ReplaceLastTokenWithAnnotation (const Token &Tok)
 Replace the last token with an annotation token.
void recomputeCurLexerKind ()
 Recompute the current lexer kind based on the CurLexer/CurPTHLexer/ CurTokenLexer pointers.
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. Returns an invalid location if code-completion is not enabled or the file containing the code-completion point has not been lexed yet.
SourceLocation getCodeCompletionFileLoc () const
 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.
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. Returns an invalid location if there is no such pragma active.
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 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=0) const
std::string getSpelling (const Token &Tok, bool *Invalid=0) const
unsigned getSpelling (const Token &Tok, const char *&Buffer, bool *Invalid=0) const
StringRef getSpelling (const Token &Tok, SmallVectorImpl< char > &Buffer, bool *Invalid=0) const
char getSpellingOfSingleCharacterNumericConstant (const Token &Tok, bool *Invalid=0) const
StringRef getImmediateMacroName (SourceLocation Loc)
 Retrieve the name of the immediate macro expansion.
void CreateString (const char *Buf, unsigned Len, Token &Tok, SourceLocation ExpansionLocStart=SourceLocation(), SourceLocation ExpansionLocEnd=SourceLocation())
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=0) const
 Returns true if the given MacroID location points at the first token of the macro expansion.
bool isAtEndOfMacroExpansion (SourceLocation loc, SourceLocation *MacroEnd=0) 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
void DumpLocation (SourceLocation Loc) const
void DumpMacro (const MacroInfo &MI) const
SourceLocation AdvanceToTokenCharacter (SourceLocation TokStart, unsigned Char) const
void IncrementPasteCounter (bool isFast)
void PrintStats ()
size_t getTotalMemory () const
void HandleMicrosoftCommentPaste (Token &Tok)
IdentifierInfoLookUpIdentifierInfo (Token &Identifier) const
void SetPoisonReason (IdentifierInfo *II, unsigned DiagID)
void HandlePoisonedIdentifier (Token &Tok)
void MaybeHandlePoisonedIdentifier (Token &Identifier)
void PoisonSEHIdentifiers (bool Poison=true)
void HandleIdentifier (Token &Identifier)
bool HandleEndOfFile (Token &Result, bool isEndOfMacro=false)
bool HandleEndOfTokenLexer (Token &Result)
void HandleDirective (Token &Result)
void CheckEndOfDirective (const char *Directive, bool EnableMacros=false)
void DiscardUntilEndOfDirective ()
bool SawDateOrTime () const
unsigned getCounterValue () const
void setCounterValue (unsigned V)
ModulegetCurrentModule ()
 Retrieves the module that we're currently building, if any.
MacroInfoAllocateMacroInfo (SourceLocation L)
MacroInfoCloneMacroInfo (const MacroInfo &MI)
 CloneMacroInfo - Allocate a new MacroInfo object which is clone of MI.
bool GetIncludeFilenameSpelling (SourceLocation Loc, StringRef &Filename)
const FileEntryLookupFile (StringRef Filename, bool isAngled, const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, Module **SuggestedModule, bool SkipCache=false)
const DirectoryLookupGetCurDirLookup ()
bool isInPrimaryFile () const
bool ConcatenateIncludeName (SmallString< 128 > &FilenameBuffer, SourceLocation &End)
bool LexOnOffSwitch (tok::OnOffSwitch &OOS)
void HandlePragmaOnce (Token &OnceTok)
void HandlePragmaMark ()
void HandlePragmaPoison (Token &PoisonTok)
void HandlePragmaSystemHeader (Token &SysHeaderTok)
void HandlePragmaDependency (Token &DependencyTok)
void HandlePragmaComment (Token &CommentTok)
void HandlePragmaMessage (Token &MessageTok)
void HandlePragmaPushMacro (Token &Tok)
void HandlePragmaPopMacro (Token &Tok)
IdentifierInfoParsePragmaPushOrPopMacro (Token &Tok)
bool HandleComment (Token &Token, SourceRange Comment)
void markMacroAsUsed (MacroInfo *MI)
 A macro is used, update information about macros that need unused warnings.

Friends

class MacroArgs
void TokenLexer::ExpandFunctionArguments ()

Detailed Description

Preprocessor - This object 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 63 of file Preprocessor.h.


Member Typedef Documentation

typedef llvm::DenseMap<IdentifierInfo*, MacroInfo*>::const_iterator clang::Preprocessor::macro_iterator

macro_iterator/macro_begin/macro_end - This allows you to walk the current state of the macro table. This visits every currently-defined macro.

Definition at line 446 of file Preprocessor.h.


Constructor & Destructor Documentation

Preprocessor::Preprocessor ( DiagnosticsEngine diags,
LangOptions opts,
const TargetInfo target,
SourceManager SM,
HeaderSearch Headers,
ModuleLoader TheModuleLoader,
IdentifierInfoLookup IILookup = 0,
bool  OwnsHeaderSearch = false,
bool  DelayInitialization = false 
)

Definition at line 52 of file Preprocessor.cpp.

References Initialize().

Preprocessor::~Preprocessor ( )

Definition at line 75 of file Preprocessor.cpp.


Member Function Documentation

void Preprocessor::AddCommentHandler ( CommentHandler Handler)

Add the specified comment handler to the preprocessor.

Definition at line 623 of file Preprocessor.cpp.

void clang::Preprocessor::addPPCallbacks ( PPCallbacks C) [inline]
void Preprocessor::AddPragmaHandler ( StringRef  Namespace,
PragmaHandler Handler 
)

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 669 of file Pragma.cpp.

References clang::PragmaNamespace::AddPragma(), clang::PragmaNamespace::FindHandler(), clang::PragmaNamespace::getIfNamespace(), and clang::PragmaHandler::getName().

Referenced by AddPragmaHandler(), DoPrintMacros(), clang::DoPrintPreprocessedInput(), clang::PreprocessOnlyAction::ExecuteAction(), and clang::Parser::Parser().

void clang::Preprocessor::AddPragmaHandler ( PragmaHandler Handler) [inline]

Definition at line 469 of file Preprocessor.h.

References AddPragmaHandler().

SourceLocation clang::Preprocessor::AdvanceToTokenCharacter ( SourceLocation  TokStart,
unsigned  Char 
) const [inline]

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

Definition at line 904 of file Preprocessor.h.

Referenced by GetLineValue(), and clang::NumericLiteralParser::NumericLiteralParser().

MacroInfo * Preprocessor::AllocateMacroInfo ( SourceLocation  L)

AllocateMacroInfo - Allocate a new MacroInfo object with the provide SourceLocation.

Definition at line 52 of file PPDirectives.cpp.

References AllocateMacroInfo().

Referenced by AllocateMacroInfo(), CloneMacroInfo(), and RegisterBuiltinMacro().

void clang::Preprocessor::AnnotateCachedTokens ( const Token Tok) [inline]

AnnotateCachedTokens - 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 671 of file Preprocessor.h.

References clang::Token::isAnnotation(), and isBacktrackEnabled().

void Preprocessor::Backtrack ( )

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 
)

CheckEndOfDirective - 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.

Definition at line 156 of file PPDirectives.cpp.

References clang::FixItHint::CreateInsertion(), Diag(), DiscardUntilEndOfDirective(), clang::Token::getLocation(), clang::Token::is(), clang::Token::isNot(), Lex(), and LexUnexpandedToken().

void clang::Preprocessor::clearCodeCompletionHandler ( ) [inline]

Clear out the code completion handler.

Definition at line 501 of file Preprocessor.h.

Referenced by clang::Parser::~Parser().

MacroInfo * Preprocessor::CloneMacroInfo ( const MacroInfo MI)

CloneMacroInfo - Allocate a new MacroInfo object which is clone of MI.

Definition at line 58 of file PPDirectives.cpp.

References AllocateMacroInfo().

Referenced by HandlePragmaPushMacro().

void Preprocessor::CodeCompleteNaturalLanguage ( )

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

Definition at line 333 of file Preprocessor.cpp.

References clang::CodeCompletionHandler::CodeCompleteNaturalLanguage(), and setCodeCompletionReached().

Referenced by clang::Lexer::ReadToEndOfLine(), and clang::MacroArgs::StringifyArgument().

void Preprocessor::CommitBacktrackedTokens ( )

CommitBacktrackedTokens - Disable the last EnableBacktrackAtThisPos call.

Definition at line 32 of file PPCaching.cpp.

bool Preprocessor::ConcatenateIncludeName ( SmallString< 128 > &  FilenameBuffer,
SourceLocation End 
)

ConcatenateIncludeName - 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 <a/b.h> #include FOO because in this case, "<a/b.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 1175 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().

void Preprocessor::createPreprocessingRecord ( bool  IncludeNestedMacroExpansions)

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

Definition at line 657 of file Preprocessor.cpp.

References addPPCallbacks(), and getSourceManager().

void Preprocessor::CreateString ( const char *  Buf,
unsigned  Len,
Token Tok,
SourceLocation  ExpansionLocStart = SourceLocation(),
SourceLocation  ExpansionLocEnd = SourceLocation() 
)

CreateString - 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 364 of file Preprocessor.cpp.

References clang::SourceManager::createExpansionLoc(), clang::ScratchBuffer::getToken(), clang::Token::is(), clang::Token::isLiteral(), clang::SourceLocation::isValid(), clang::Token::setLength(), clang::Token::setLiteralData(), clang::Token::setLocation(), and clang::Token::setRawIdentifierData().

Referenced by ComputeDATE_TIME(), ParsePragmaPushOrPopMacro(), and clang::MacroArgs::StringifyArgument().

DiagnosticBuilder clang::Preprocessor::Diag ( SourceLocation  Loc,
unsigned  DiagID 
) const [inline]
DiagnosticBuilder clang::Preprocessor::Diag ( const Token Tok,
unsigned  DiagID 
) const [inline]
void Preprocessor::DiscardUntilEndOfDirective ( )

DiscardUntilEndOfDirective - Read and discard all tokens remaining on the current line until the tok::eod token is found.

Definition at line 87 of file PPDirectives.cpp.

References clang::Token::isNot(), and LexUnexpandedToken().

Referenced by CheckEndOfDirective(), GetLineValue(), HandleDirective(), and ReadLineMarkerFlags().

void Preprocessor::DumpLocation ( SourceLocation  Loc) const

Definition at line 204 of file Preprocessor.cpp.

References clang::SourceLocation::dump().

Referenced by DumpToken().

void Preprocessor::DumpMacro ( const MacroInfo MI) const
void Preprocessor::DumpToken ( const Token Tok,
bool  DumpFlags = false 
) const
void Preprocessor::EnableBacktrackAtThisPos ( )

EnableBacktrackAtThisPos - 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.

EnableBacktrackAtThisPos - 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.

Definition at line 26 of file PPCaching.cpp.

void Preprocessor::EndSourceFile ( )

EndSourceFile - Inform the preprocessor callbacks that processing is complete.

Definition at line 434 of file Preprocessor.cpp.

References clang::PPCallbacks::EndOfMainFile().

Referenced by clang::FrontendAction::EndSourceFile().

void Preprocessor::EnterMacro ( Token Tok,
SourceLocation  ILEnd,
MacroArgs Args 
)

EnterMacro - 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 159 of file PPLexerChange.cpp.

void Preprocessor::EnterMainSourceFile ( )
void Preprocessor::EnterSourceFile ( FileID  FID,
const DirectoryLookup CurDir,
SourceLocation  Loc 
)

EnterSourceFile - Add a source file to the top of the include stack and start lexing tokens from it instead of the current buffer. Emit an error and don't enter the file 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]

EnterToken - 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 658 of file Preprocessor.h.

Referenced by FixDigraph().

void Preprocessor::EnterTokenStream ( const Token Toks,
unsigned  NumToks,
bool  DisableMacroExpansion,
bool  OwnsTokens 
)

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 186 of file PPLexerChange.cpp.

Referenced by clang::MacroArgs::getPreExpArgument(), HandleDirective(), clang::PragmaGCCVisibilityHandler::HandlePragma(), and clang::PragmaUnusedHandler::HandlePragma().

Builtin::Context& clang::Preprocessor::getBuiltinInfo ( ) [inline]
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 723 of file Preprocessor.h.

CodeCompletionHandler* clang::Preprocessor::getCodeCompletionHandler ( ) const [inline]

Retrieve the current code-completion handler.

Definition at line 496 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 718 of file Preprocessor.h.

bool clang::Preprocessor::getCommentRetentionState ( ) const [inline]

Definition at line 393 of file Preprocessor.h.

Referenced by HandleComment(), and clang::Lexer::Lexer().

unsigned clang::Preprocessor::getCounterValue ( ) const [inline]

Definition at line 1016 of file Preprocessor.h.

const DirectoryLookup* clang::Preprocessor::GetCurDirLookup ( ) [inline]

GetCurLookup - 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 1051 of file Preprocessor.h.

Referenced by EvaluateHasIncludeNext().

PreprocessorLexer * Preprocessor::getCurrentFileLexer ( ) const

getCurrentFileLexer - 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]

getCurrentLexer - 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 412 of file Preprocessor.h.

Referenced by EvaluateHasIncludeCommon().

Module * Preprocessor::getCurrentModule ( )

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

Definition at line 384 of file Preprocessor.cpp.

References getHeaderSearchInfo(), getLangOptions(), and clang::HeaderSearch::lookupModule().

Referenced by clang::Sema::ActOnEndOfTranslationUnit(), and HandleEndOfFile().

DiagnosticsEngine& clang::Preprocessor::getDiagnostics ( ) const [inline]
ExternalPreprocessorSource* clang::Preprocessor::getExternalSource ( ) const [inline]

Definition at line 379 of file Preprocessor.h.

Referenced by isTrivialSingleTokenExpansion().

FileManager& clang::Preprocessor::getFileManager ( ) const [inline]
HeaderSearch& clang::Preprocessor::getHeaderSearchInfo ( ) const [inline]
IdentifierInfo* clang::Preprocessor::getIdentifierInfo ( StringRef  Name) const [inline]

getIdentifierInfo - Return information about the specified preprocessor identifier token. The version of this method that takes two character pointers is preferred unless the identifier is already available as a string (this avoids allocation and copying of memory to construct an std::string).

Definition at line 461 of file Preprocessor.h.

References clang::IdentifierTable::get().

Referenced by HasFeature(), clang::Parser::Initialize(), Initialize(), LookUpIdentifierInfo(), and RegisterBuiltinMacro().

IdentifierTable& clang::Preprocessor::getIdentifierTable ( ) [inline]
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 which 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 845 of file Preprocessor.h.

References getLangOptions().

bool Preprocessor::GetIncludeFilenameSpelling ( SourceLocation  Loc,
StringRef &  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 1126 of file PPDirectives.cpp.

References Diag().

Referenced by EvaluateHasIncludeCommon(), and HandlePragmaDependency().

const LangOptions& clang::Preprocessor::getLangOptions ( ) const [inline]
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.

Parameters:
Offsetan 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 871 of file Preprocessor.h.

Referenced by clang::Sema::CheckEquivalentExceptionSpec(), clang::Sema::CheckFriendTypeDecl(), clang::Sema::ConvertToIntegralOrEnumerationType(), clang::InitializationSequence::Diagnose(), clang::Sema::DiagnoseAssignmentAsCondition(), DiagnoseNarrowingInInitList(), diagnoseObjCARCConversion(), clang::DeclSpec::Finish(), clang::Sema::InstantiateInitializer(), clang::Sema::ParseObjCEncodeExpression(), SuggestInitializationFixit(), SuggestParentheses(), clang::ConversionFixItGenerator::tryToFixConversion(), and clang::Sema::tryToRecoverWithCall().

MacroInfo* clang::Preprocessor::getMacroInfo ( IdentifierInfo II) const [inline]
ModuleLoader& clang::Preprocessor::getModuleLoader ( ) const [inline]

Retrieve the module loader associated with this preprocessor.

Definition at line 384 of file Preprocessor.h.

Referenced by clang::Sema::ActOnModuleImport().

PPCallbacks* clang::Preprocessor::getPPCallbacks ( ) const [inline]

getPPCallbacks/addPPCallbacks - Accessors for preprocessor callbacks. Note that this class takes ownership of any PPCallbacks object given to it.

Definition at line 422 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 742 of file Preprocessor.h.

Referenced by clang::Sema::AddCFAuditedAttribute().

const std::string& clang::Preprocessor::getPredefines ( ) const [inline]

Definition at line 450 of file Preprocessor.h.

PreprocessingRecord* clang::Preprocessor::getPreprocessingRecord ( ) const [inline]

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

Definition at line 511 of file Preprocessor.h.

llvm::BumpPtrAllocator& clang::Preprocessor::getPreprocessorAllocator ( ) [inline]

Definition at line 369 of file Preprocessor.h.

PTHManager* clang::Preprocessor::getPTHManager ( ) [inline]

Definition at line 373 of file Preprocessor.h.

Referenced by AddImplicitIncludePTH().

SelectorTable& clang::Preprocessor::getSelectorTable ( ) [inline]
SourceManager& clang::Preprocessor::getSourceManager ( ) const [inline]
StringRef clang::Preprocessor::getSpelling ( SourceLocation  loc,
SmallVectorImpl< char > &  buffer,
bool *  invalid = 0 
) const [inline]

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

Parameters:
bufferA buffer which will be used only if the token requires "cleaning", e.g. if it contains trigraphs or escaped newlines
invalidIf non-null, will be set true if an error occurs.

Definition at line 782 of file Preprocessor.h.

Referenced by ConcatenateIncludeName(), clang::DoRewriteTest(), DumpToken(), EvaluateHasIncludeCommon(), EvaluateValue(), FindExpectedDiags(), GetFirstChar(), GetLineValue(), getSpelling(), HandlePragmaDependency(), clang::MacroInfo::isIdenticalTo(), LookUpIdentifierInfo(), ParsePragmaPushOrPopMacro(), clang::PrettyStackTraceParserEntry::print(), PrintMacroDefinition(), PrintPreprocessedTokens(), clang::RewriteMacrosInInput(), and clang::MacroArgs::StringifyArgument().

std::string clang::Preprocessor::getSpelling ( const Token Tok,
bool *  Invalid = 0 
) const [inline]

getSpelling() - 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.

Parameters:
InvalidIf non-null, will be set true if an error occurs.

Definition at line 795 of file Preprocessor.h.

References getSpelling().

unsigned clang::Preprocessor::getSpelling ( const Token Tok,
const char *&  Buffer,
bool *  Invalid = 0 
) const [inline]

getSpelling - This method is used to 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 809 of file Preprocessor.h.

References getSpelling().

StringRef Preprocessor::getSpelling ( const Token Tok,
SmallVectorImpl< char > &  Buffer,
bool *  Invalid = 0 
) const

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 342 of file Preprocessor.cpp.

References clang::Token::getIdentifierInfo(), clang::Token::getLength(), getSpelling(), clang::Token::isNot(), and clang::Token::needsCleaning().

char clang::Preprocessor::getSpellingOfSingleCharacterNumericConstant ( const Token Tok,
bool *  Invalid = 0 
) const [inline]

getSpellingOfSingleCharacterNumericConstant - Tok is a numeric constant with length 1, return the character.

Definition at line 823 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 399 of file Preprocessor.h.

const TargetInfo& clang::Preprocessor::getTargetInfo ( ) const [inline]
size_t Preprocessor::getTotalMemory ( ) const

Definition at line 250 of file Preprocessor.cpp.

bool Preprocessor::HandleComment ( Token Token,
SourceRange  Comment 
)

Definition at line 637 of file Preprocessor.cpp.

References getCommentRetentionState(), and Lex().

void Preprocessor::HandleDirective ( Token Result)
bool Preprocessor::HandleEndOfFile ( Token Result,
bool  isEndOfMacro = false 
)

HandleEndOfFile - This callback is 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 233 of file PPLexerChange.cpp.

References computeRelativePath(), Diag(), clang::PPCallbacks::ExitFile, clang::PPCallbacks::FileChanged(), clang::MultipleIncludeOpt::GetControllingMacroAtEndOfFile(), getCurrentModule(), clang::DiagnosticsEngine::getDiagnosticLevel(), getDiagnostics(), clang::FileManager::getFile(), clang::SourceManager::getFileCharacteristic(), clang::SourceManager::getFileEntryForID(), clang::PreprocessorLexer::getFileID(), getFileManager(), getHeaderSearchInfo(), clang::SourceManager::getIncludeLoc(), clang::PreprocessorLexer::getInitialNumSLocEntries(), clang::SourceManager::getLocForStartOfFile(), clang::SourceManager::getMainFileID(), clang::HeaderSearch::getModuleMap(), clang::DirectoryEntry::getName(), clang::PreprocessorLexer::getSourceLocation(), getSourceManager(), clang::SourceManager::hasFileInfo(), clang::DiagnosticsEngine::Ignored, isCodeCompletionEnabled(), clang::ModuleMap::isHeaderInUnavailableModule(), clang::SourceLocation::isValid(), clang::SourceManager::local_sloc_entry_size(), clang::PreprocessorLexer::MIOpt, RemoveTopOfLexerStack(), clang::HeaderSearch::SetFileControllingMacro(), clang::SourceManager::setNumCreatedFIDsForFileID(), and clang::Token::startToken().

Referenced by HandleEndOfTokenLexer().

bool Preprocessor::HandleEndOfTokenLexer ( Token Result)

HandleEndOfTokenLexer - This callback is invoked when the current TokenLexer hits the end of its token stream.

Definition at line 394 of file PPLexerChange.cpp.

References HandleEndOfFile().

Referenced by HandleMicrosoftCommentPaste(), and clang::TokenLexer::Lex().

void Preprocessor::HandleIdentifier ( Token Identifier)

HandleIdentifier - This callback is 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 507 of file Preprocessor.cpp.

References Diag(), clang::Token::DisableExpand, clang::Token::getIdentifierInfo(), getLangOptions(), clang::Token::getLocation(), getMacroInfo(), HandlePoisonedIdentifier(), clang::Token::isExpandDisabled(), 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)

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 432 of file PPLexerChange.cpp.

References HandleEndOfTokenLexer(), clang::Token::is(), clang::Token::isNot(), Lex(), clang::PreprocessorLexer::LexingRawMode, and clang::PreprocessorLexer::ParsingPreprocessorDirective.

void Preprocessor::HandlePoisonedIdentifier ( Token Tok)
void Preprocessor::HandlePragmaComment ( Token Tok)

HandlePragmaComment - Handle the microsoft #pragma comment extension. The syntax is: #pragma comment(linker, "foo") 'linker' is one of five identifiers: compiler, exestr, lib, linker, user. "foo" is a string, which is fully macro expanded, and permits string concatenation, embedded escape characters etc. See MSDN for more details.

Definition at line 404 of file Pragma.cpp.

References Diag(), clang::Token::getIdentifierInfo(), clang::Token::getLocation(), clang::Token::is(), clang::Token::isNot(), clang::IdentifierInfo::isStr(), Lex(), and clang::PPCallbacks::PragmaComment().

void Preprocessor::HandlePragmaDependency ( Token DependencyTok)
void Preprocessor::HandlePragmaMark ( )

Definition at line 261 of file Pragma.cpp.

void Preprocessor::HandlePragmaMessage ( Token Tok)

HandlePragmaMessage - Handle the microsoft and gcc #pragma message extension. The syntax is: #pragma message(string) OR, in GCC mode: #pragma message string string is a string, which is fully macro expanded, and permits string concatenation, embedded escape characters, etc... See MSDN for more details.

Definition at line 491 of file Pragma.cpp.

References Diag(), clang::Token::getKind(), clang::Token::getLocation(), clang::Token::is(), clang::Token::isNot(), Lex(), and clang::PPCallbacks::PragmaMessage().

void Preprocessor::HandlePragmaOnce ( Token OnceTok)

HandlePragmaOnce - Handle #pragma once. OnceTok is the 'once'.

Definition at line 250 of file Pragma.cpp.

References Diag(), getCurrentFileLexer(), isInPrimaryFile(), and clang::HeaderSearch::MarkFileIncludeOnce().

void Preprocessor::HandlePragmaPoison ( Token PoisonTok)
void Preprocessor::HandlePragmaPopMacro ( Token PopMacroTok)

HandlePragmaPopMacro - Handle #pragma pop_macro. The syntax is: #pragma pop_macro("macro")

Definition at line 631 of file Pragma.cpp.

References Diag(), clang::MacroInfo::getDefinitionLoc(), clang::Token::getLocation(), getMacroInfo(), clang::IdentifierInfo::getName(), clang::MacroInfo::isWarnIfUnused(), ParsePragmaPushOrPopMacro(), and setMacroInfo().

void Preprocessor::HandlePragmaPushMacro ( Token PushMacroTok)

HandlePragmaPushMacro - Handle #pragma push_macro. The syntax is: #pragma push_macro("macro")

Definition at line 607 of file Pragma.cpp.

References CloneMacroInfo(), getMacroInfo(), ParsePragmaPushOrPopMacro(), and clang::MacroInfo::setIsAllowRedefinitionsWithoutWarning().

void Preprocessor::HandlePragmaSystemHeader ( Token SysHeaderTok)
void clang::Preprocessor::IncrementPasteCounter ( bool  isFast) [inline]

IncrementPasteCounter - 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 913 of file Preprocessor.h.

void Preprocessor::Initialize ( const TargetInfo Target)

Initialize the preprocessor, if the constructor did not already perform the initialization.

Parameters:
TargetInformation about the target.

Definition at line 109 of file Preprocessor.cpp.

References BuiltinInfo, getIdentifierInfo(), SetPoisonReason(), and clang::HeaderSearch::setTarget().

Referenced by Preprocessor().

bool clang::Preprocessor::isAtEndOfMacroExpansion ( SourceLocation  loc,
SourceLocation MacroEnd = 0 
) const [inline]

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

Parameters:
MacroBeginIf non-null and function returns true, it is set to end location of the macro.

Definition at line 891 of file Preprocessor.h.

bool clang::Preprocessor::isAtStartOfMacroExpansion ( SourceLocation  loc,
SourceLocation MacroBegin = 0 
) const [inline]

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

Parameters:
MacroBeginIf non-null and function returns true, it is set to begin location of the macro.

Definition at line 880 of file Preprocessor.h.

bool clang::Preprocessor::isBacktrackEnabled ( ) const [inline]

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

Definition at line 583 of file Preprocessor.h.

Referenced by AnnotateCachedTokens(), ReplaceLastTokenWithAnnotation(), and RevertCachedTokens().

bool clang::Preprocessor::isCodeCompletionEnabled ( ) const [inline]

Determine if we are performing code completion.

Definition at line 713 of file Preprocessor.h.

Referenced by EnterSourceFile(), HandleEndOfFile(), 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 729 of file Preprocessor.h.

bool clang::Preprocessor::isCurrentLexer ( const PreprocessorLexer L) const [inline]

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

Definition at line 405 of file Preprocessor.h.

Referenced by clang::PTHLexer::Lex().

bool Preprocessor::isInPrimaryFile ( ) const

isInPrimaryFile - 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().

void clang::Preprocessor::Lex ( Token Result) [inline]
void Preprocessor::LexAfterModuleImport ( Token Result)

Lex a token following the 'import' contextual keyword.

Definition at line 585 of file Preprocessor.cpp.

References clang::Token::getIdentifierInfo(), clang::Token::getKind(), clang::Token::getLocation(), Lex(), clang::ModuleLoader::loadModule(), clang::Module::MacrosVisible, and recomputeCurLexerKind().

Referenced by Lex().

void clang::Preprocessor::LexNonComment ( Token Result) [inline]

LexNonComment - 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 602 of file Preprocessor.h.

References clang::Token::getKind(), and Lex().

Referenced by EvaluateDefined(), EvaluateDirectiveSubExpr(), EvaluateHasIncludeCommon(), and EvaluateValue().

bool Preprocessor::LexOnOffSwitch ( tok::OnOffSwitch OOS)

LexOnOffSwitch - 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 723 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.

Referenced by clang::PragmaFPContractHandler::HandlePragma().

void clang::Preprocessor::LexUnexpandedNonComment ( Token Result) [inline]

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

Definition at line 623 of file Preprocessor.h.

References clang::Token::getKind(), and LexUnexpandedToken().

Referenced by EvaluateDefined().

void clang::Preprocessor::LexUnexpandedToken ( Token Result) [inline]
const Token& clang::Preprocessor::LookAhead ( unsigned  N) [inline]

LookAhead - This 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 634 of file Preprocessor.h.

Referenced by MayBeDesignationStart().

const FileEntry * Preprocessor::LookupFile ( StringRef  Filename,
bool  isAngled,
const DirectoryLookup FromDir,
const DirectoryLookup *&  CurDir,
SmallVectorImpl< char > *  SearchPath,
SmallVectorImpl< char > *  RelativePath,
Module **  SuggestedModule,
bool  SkipCache = false 
)

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

Definition at line 483 of file PPDirectives.cpp.

References getCurrentFileLexer(), clang::SourceManager::getFileEntryForID(), clang::PreprocessorLexer::getFileID(), clang::SourceManager::getMainFileID(), clang::HeaderSearch::LookupFile(), and clang::HeaderSearch::LookupSubframeworkHeader().

Referenced by EvaluateHasIncludeCommon(), and HandlePragmaDependency().

IdentifierInfo * Preprocessor::LookUpIdentifierInfo ( Token Identifier) const

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 447 of file Preprocessor.cpp.

References getIdentifierInfo(), clang::Token::getLength(), clang::Token::getRawIdentifierData(), getSpelling(), 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
Preprocessor::macro_iterator Preprocessor::macro_end ( bool  IncludeExternalMacros = true) const
void Preprocessor::markMacroAsUsed ( MacroInfo MI)

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

Definition at line 1124 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]
IdentifierInfo * Preprocessor::ParsePragmaPushOrPopMacro ( Token Tok)

ParsePragmaPushOrPopMacro - Handle parsing of pragma push_macro/pop_macro. Return the IdentifierInfo* associated with the macro to push or pop.

Definition at line 560 of file Pragma.cpp.

References CreateString(), Diag(), clang::Token::getLocation(), getSpelling(), clang::Token::isNot(), Lex(), LookUpIdentifierInfo(), and clang::Token::startToken().

Referenced by HandlePragmaPopMacro(), and HandlePragmaPushMacro().

void Preprocessor::PoisonSEHIdentifiers ( bool  Poison = true)

Definition at line 474 of file Preprocessor.cpp.

References clang::IdentifierInfo::setIsPoisoned().

void Preprocessor::PrintStats ( )

Definition at line 217 of file Preprocessor.cpp.

Referenced by clang::FrontendAction::EndSourceFile().

void Preprocessor::recomputeCurLexerKind ( )

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

Definition at line 271 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 630 of file Preprocessor.cpp.

void Preprocessor::RemovePragmaHandler ( StringRef  Namespace,
PragmaHandler Handler 
)

RemovePragmaHandler - Remove the specific pragma handler from the 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.

Definition at line 700 of file Pragma.cpp.

References clang::PragmaNamespace::FindHandler(), clang::PragmaHandler::getIfNamespace(), clang::PragmaNamespace::IsEmpty(), and clang::PragmaNamespace::RemovePragmaHandler().

Referenced by RemovePragmaHandler(), and clang::Parser::~Parser().

void clang::Preprocessor::RemovePragmaHandler ( PragmaHandler Handler) [inline]

Definition at line 478 of file Preprocessor.h.

References RemovePragmaHandler().

void Preprocessor::RemoveTopOfLexerStack ( )

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 415 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 685 of file Preprocessor.h.

References clang::Token::isAnnotation(), and isBacktrackEnabled().

void clang::Preprocessor::RevertCachedTokens ( unsigned  N) [inline]

RevertCachedTokens - 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 645 of file Preprocessor.h.

References isBacktrackEnabled().

bool clang::Preprocessor::SawDateOrTime ( ) const [inline]

SawDateOrTime - This returns true if the preprocessor has seen a use of __DATE__ or __TIME__ in the file so far.

Definition at line 1013 of file Preprocessor.h.

void clang::Preprocessor::setCodeCompletionHandler ( CodeCompletionHandler Handler) [inline]

Set the code completion handler to the given object.

Definition at line 491 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.

Parameters:
Filethe 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.
Linethe line at which code completion should occur (1-based).
Columnthe column at which code completion should occur (1-based).
Returns:
true if an error occurred, false otherwise.

Definition at line 282 of file Preprocessor.cpp.

References clang::SourceManager::getMemoryBufferForFile(), and clang::SourceManager::overrideFileContents().

Referenced by EnableCodeCompletion().

void clang::Preprocessor::setCodeCompletionReached ( ) [inline]
void clang::Preprocessor::SetCommentRetentionState ( bool  KeepComments,
bool  KeepMacroComments 
) [inline]

SetCommentRetentionState - Control whether or not the preprocessor retains comments in output.

Definition at line 388 of file Preprocessor.h.

Referenced by clang::DoPrintPreprocessedInput().

void clang::Preprocessor::setCounterValue ( unsigned  V) [inline]

Definition at line 1017 of file Preprocessor.h.

void clang::Preprocessor::setDiagnostics ( DiagnosticsEngine D) [inline]

Definition at line 358 of file Preprocessor.h.

void clang::Preprocessor::setExternalSource ( ExternalPreprocessorSource Source) [inline]

Definition at line 375 of file Preprocessor.h.

void Preprocessor::setMacroInfo ( IdentifierInfo II,
MacroInfo MI,
bool  LoadedFromAST = false 
)
void Preprocessor::SetPoisonReason ( IdentifierInfo II,
unsigned  DiagID 
)

Definition at line 470 of file Preprocessor.cpp.

Referenced by clang::Parser::Initialize(), and Initialize().

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 748 of file Preprocessor.h.

void clang::Preprocessor::setPredefines ( const char *  P) [inline]

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

Definition at line 453 of file Preprocessor.h.

Referenced by createASTReader(), clang::CompilerInstance::createPCHExternalASTSource(), and clang::InitializePreprocessor().

void clang::Preprocessor::setPredefines ( const std::string &  P) [inline]

Definition at line 454 of file Preprocessor.h.

void Preprocessor::setPTHManager ( PTHManager pm)

Definition at line 175 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 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 759 of file Preprocessor.h.

Referenced by clang::InitializePreprocessor().

void clang::Preprocessor::SetSuppressIncludeNotFoundError ( bool  Suppress) [inline]

Definition at line 395 of file Preprocessor.h.

Referenced by clang::AttachDependencyFileGen().


Friends And Related Function Documentation

friend class MacroArgs [friend]

Definition at line 267 of file Preprocessor.h.

void TokenLexer::ExpandFunctionArguments ( ) [friend]

The documentation for this class was generated from the following files: