clang API Documentation

Public Types | Public Member Functions
clang::PPCallbacks Class Reference

#include <PPCallbacks.h>

Inheritance diagram for clang::PPCallbacks:
Inheritance graph
[legend]

List of all members.

Public Types

enum  FileChangeReason { EnterFile, ExitFile, SystemHeaderPragma, RenameFile }

Public Member Functions

virtual ~PPCallbacks ()
virtual void FileChanged (SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID=FileID())
virtual void FileSkipped (const FileEntry &ParentFile, const Token &FilenameTok, SrcMgr::CharacteristicKind FileType)
virtual bool FileNotFound (StringRef FileName, SmallVectorImpl< char > &RecoveryPath)
virtual void InclusionDirective (SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, const FileEntry *File, SourceLocation EndLoc, StringRef SearchPath, StringRef RelativePath)
 This callback is invoked whenever an inclusion directive of any kind (#include, #import, etc.) has been processed, regardless of whether the inclusion will actually result in an inclusion.
virtual void EndOfMainFile ()
virtual void Ident (SourceLocation Loc, const std::string &str)
virtual void PragmaComment (SourceLocation Loc, const IdentifierInfo *Kind, const std::string &Str)
virtual void PragmaMessage (SourceLocation Loc, StringRef Str)
virtual void PragmaDiagnosticPush (SourceLocation Loc, StringRef Namespace)
virtual void PragmaDiagnosticPop (SourceLocation Loc, StringRef Namespace)
virtual void PragmaDiagnostic (SourceLocation Loc, StringRef Namespace, diag::Mapping mapping, StringRef Str)
virtual void MacroExpands (const Token &MacroNameTok, const MacroInfo *MI, SourceRange Range)
virtual void MacroDefined (const Token &MacroNameTok, const MacroInfo *MI)
 MacroDefined - This hook is called whenever a macro definition is seen.
virtual void MacroUndefined (const Token &MacroNameTok, const MacroInfo *MI)
virtual void Defined (const Token &MacroNameTok)
 Defined - This hook is called whenever the 'defined' operator is seen.
virtual void SourceRangeSkipped (SourceRange Range)
virtual void If (SourceLocation Loc, SourceRange ConditionRange)
virtual void Elif (SourceLocation Loc, SourceRange ConditionRange, SourceLocation IfLoc)
virtual void Ifdef (SourceLocation Loc, const Token &MacroNameTok)
virtual void Ifndef (SourceLocation Loc, const Token &MacroNameTok)
virtual void Else (SourceLocation Loc, SourceLocation IfLoc)
virtual void Endif (SourceLocation Loc, SourceLocation IfLoc)

Detailed Description

PPCallbacks - This interface provides a way to observe the actions of the preprocessor as it does its thing. Clients can define their hooks here to implement preprocessor level tools.

Definition at line 32 of file PPCallbacks.h.


Member Enumeration Documentation

Enumerator:
EnterFile 
ExitFile 
SystemHeaderPragma 
RenameFile 

Definition at line 36 of file PPCallbacks.h.


Constructor & Destructor Documentation

PPCallbacks::~PPCallbacks ( ) [virtual]

Definition at line 27 of file PPLexerChange.cpp.


Member Function Documentation

virtual void clang::PPCallbacks::Defined ( const Token MacroNameTok) [inline, virtual]

Defined - This hook is called whenever the 'defined' operator is seen.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 183 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::Defined().

virtual void clang::PPCallbacks::Elif ( SourceLocation  Loc,
SourceRange  ConditionRange,
SourceLocation  IfLoc 
) [inline, virtual]

Elif -- This hook is called whenever an #elif is seen.

Parameters:
Locthe source location of the directive.
ConditionRangeThe SourceRange of the expression being tested.
IfLocthe source location of the if/#ifdef/#ifndef directive.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 204 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::Elif().

virtual void clang::PPCallbacks::Else ( SourceLocation  Loc,
SourceLocation  IfLoc 
) [inline, virtual]

Else -- This hook is called whenever an #else is seen.

Parameters:
Locthe source location of the directive.
IfLocthe source location of the if/#ifdef/#ifndef directive.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 223 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::Else().

virtual void clang::PPCallbacks::Endif ( SourceLocation  Loc,
SourceLocation  IfLoc 
) [inline, virtual]

Endif -- This hook is called whenever an #endif is seen.

Parameters:
Locthe source location of the directive.
IfLocthe source location of the if/#ifdef/#ifndef directive.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 229 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::Endif().

virtual void clang::PPCallbacks::EndOfMainFile ( ) [inline, virtual]

EndOfMainFile - This callback is invoked when the end of the main file is reach, no subsequent callbacks will be made.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 123 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::EndOfMainFile(), and clang::Preprocessor::EndSourceFile().

virtual void clang::PPCallbacks::FileChanged ( SourceLocation  Loc,
FileChangeReason  Reason,
SrcMgr::CharacteristicKind  FileType,
FileID  PrevFID = FileID() 
) [inline, virtual]

FileChanged - This callback is invoked whenever a source file is entered or exited. The SourceLocation indicates the new location, and EnteringFile indicates whether this is because we are entering a new #include'd file (when true) or whether we're exiting one because we ran off the end (when false).

Parameters:
PrevFIDthe file that was exited if
  • Reason is ExitFile.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 47 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::FileChanged(), clang::Preprocessor::HandleEndOfFile(), and clang::Preprocessor::HandlePragmaSystemHeader().

virtual bool clang::PPCallbacks::FileNotFound ( StringRef  FileName,
SmallVectorImpl< char > &  RecoveryPath 
) [inline, virtual]

FileNotFound - This callback is invoked whenever an inclusion directive results in a file-not-found error.

Parameters:
FileNameThe name of the file being included, as written in the source code.
RecoveryPathIf this client indicates that it can recover from this missing file, the client should set this as an additional header search patch.
Returns:
true to indicate that the preprocessor should attempt to recover by adding RecoveryPath as a header search path.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 73 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::FileNotFound().

virtual void clang::PPCallbacks::FileSkipped ( const FileEntry ParentFile,
const Token FilenameTok,
SrcMgr::CharacteristicKind  FileType 
) [inline, virtual]

FileSkipped - This callback is invoked whenever a source file is skipped as the result of header guard optimization. ParentFile is the file that #includes the skipped file. FilenameTok is the token in ParentFile that indicates the skipped file.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 56 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::FileSkipped().

virtual void clang::PPCallbacks::Ident ( SourceLocation  Loc,
const std::string &  str 
) [inline, virtual]

Ident - This callback is invoked when a #ident or #sccs directive is read.

Parameters:
LocThe location of the directive.
strThe text of the directive.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 130 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::Ident().

virtual void clang::PPCallbacks::If ( SourceLocation  Loc,
SourceRange  ConditionRange 
) [inline, virtual]

If -- This hook is called whenever an if is seen.

Parameters:
Locthe source location of the directive.
ConditionRangeThe SourceRange of the expression being tested.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 196 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::If().

virtual void clang::PPCallbacks::Ifdef ( SourceLocation  Loc,
const Token MacroNameTok 
) [inline, virtual]

Ifdef -- This hook is called whenever an #ifdef is seen.

Parameters:
Locthe source location of the directive.
IIInformation on the token being tested.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 211 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::Ifdef().

virtual void clang::PPCallbacks::Ifndef ( SourceLocation  Loc,
const Token MacroNameTok 
) [inline, virtual]

Ifndef -- This hook is called whenever an #ifndef is seen.

Parameters:
Locthe source location of the directive.
IIInformation on the token being tested.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 217 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::Ifndef().

virtual void clang::PPCallbacks::InclusionDirective ( SourceLocation  HashLoc,
const Token IncludeTok,
StringRef  FileName,
bool  IsAngled,
const FileEntry File,
SourceLocation  EndLoc,
StringRef  SearchPath,
StringRef  RelativePath 
) [inline, virtual]

This callback is invoked whenever an inclusion directive of any kind (#include, #import, etc.) has been processed, regardless of whether the inclusion will actually result in an inclusion.

Parameters:
HashLocThe location of the '#' that starts the inclusion directive.
IncludeTokThe token that indicates the kind of inclusion directive, e.g., 'include' or 'import'.
FileNameThe name of the file being included, as written in the source code.
IsAngledWhether the file name was enclosed in angle brackets; otherwise, it was enclosed in quotes.
FileThe actual file that may be included by this inclusion directive.
EndLocThe location of the last token within the inclusion directive.
SearchPathContains the search path which was used to find the file in the file system. If the file was found via an absolute include path, SearchPath will be empty. For framework includes, the SearchPath and RelativePath will be split up. For example, if an include of "Some/Some.h" is found via the framework path "path/to/Frameworks/Some.framework/Headers/Some.h", SearchPath will be "path/to/Frameworks/Some.framework/Headers" and RelativePath will be "Some.h".
RelativePathThe path relative to SearchPath, at which the include file was found. This is equal to FileName except for framework includes.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 111 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::InclusionDirective().

virtual void clang::PPCallbacks::MacroDefined ( const Token MacroNameTok,
const MacroInfo MI 
) [inline, virtual]

MacroDefined - This hook is called whenever a macro definition is seen.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 174 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::MacroDefined().

virtual void clang::PPCallbacks::MacroExpands ( const Token MacroNameTok,
const MacroInfo MI,
SourceRange  Range 
) [inline, virtual]

MacroExpands - This is called by Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is found.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 169 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::MacroExpands().

virtual void clang::PPCallbacks::MacroUndefined ( const Token MacroNameTok,
const MacroInfo MI 
) [inline, virtual]

MacroUndefined - This hook is called whenever a macro #undef is seen. MI is released immediately following this callback.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 179 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::MacroUndefined().

virtual void clang::PPCallbacks::PragmaComment ( SourceLocation  Loc,
const IdentifierInfo Kind,
const std::string &  Str 
) [inline, virtual]

PragmaComment - This callback is invoked when a #pragma comment directive is read.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 136 of file PPCallbacks.h.

Referenced by clang::Preprocessor::HandlePragmaComment(), and clang::PPChainedCallbacks::PragmaComment().

virtual void clang::PPCallbacks::PragmaDiagnostic ( SourceLocation  Loc,
StringRef  Namespace,
diag::Mapping  mapping,
StringRef  Str 
) [inline, virtual]

PragmaDiagnostic - This callback is invoked when a #pragma gcc dianostic directive is read.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 162 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::PragmaDiagnostic().

virtual void clang::PPCallbacks::PragmaDiagnosticPop ( SourceLocation  Loc,
StringRef  Namespace 
) [inline, virtual]

PragmaDiagnosticPop - This callback is invoked when a #pragma gcc dianostic pop directive is read.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 156 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::PragmaDiagnosticPop().

virtual void clang::PPCallbacks::PragmaDiagnosticPush ( SourceLocation  Loc,
StringRef  Namespace 
) [inline, virtual]

PragmaDiagnosticPush - This callback is invoked when a #pragma gcc dianostic push directive is read.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 150 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::PragmaDiagnosticPush().

virtual void clang::PPCallbacks::PragmaMessage ( SourceLocation  Loc,
StringRef  Str 
) [inline, virtual]

PragmaMessage - This callback is invoked when a #pragma message directive is read.

Parameters:
LocThe location of the message directive.
strThe text of the message directive.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 145 of file PPCallbacks.h.

Referenced by clang::Preprocessor::HandlePragmaMessage(), and clang::PPChainedCallbacks::PragmaMessage().

virtual void clang::PPCallbacks::SourceRangeSkipped ( SourceRange  Range) [inline, virtual]

SourceRangeSkipped - This hook is called when a source range is skipped.

Parameters:
RangeThe SourceRange that was skipped. The range begins at the if/#else directive and ends after the #endif/#else directive.

Reimplemented in clang::PPChainedCallbacks.

Definition at line 189 of file PPCallbacks.h.

Referenced by clang::PPChainedCallbacks::SourceRangeSkipped().


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