clang API Documentation
This interface provides a way to observe the actions of the preprocessor as it does its thing. More...
#include <PPCallbacks.h>
Public Types | |
enum | FileChangeReason { EnterFile, ExitFile, SystemHeaderPragma, RenameFile } |
enum | PragmaMessageKind { PMK_Message, PMK_Warning, PMK_Error } |
Determines the kind of #pragma invoking a call to PragmaMessage. More... | |
enum | ConditionValueKind { CVK_NotEvaluated, CVK_False, CVK_True } |
Public Member Functions | |
virtual | ~PPCallbacks () |
virtual void | FileChanged (SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID=FileID()) |
Callback invoked whenever a source file is entered or exited. | |
virtual void | FileSkipped (const FileEntry &ParentFile, const Token &FilenameTok, SrcMgr::CharacteristicKind FileType) |
Callback invoked whenever a source file is skipped as the result of header guard optimization. | |
virtual bool | FileNotFound (StringRef FileName, SmallVectorImpl< char > &RecoveryPath) |
Callback invoked whenever an inclusion directive results in a file-not-found error. | |
virtual void | InclusionDirective (SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, const Module *Imported) |
Callback 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 | moduleImport (SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported) |
Callback invoked whenever there was an explicit module-import syntax. | |
virtual void | EndOfMainFile () |
Callback invoked when the end of the main file is reached. | |
virtual void | Ident (SourceLocation Loc, const std::string &str) |
Callback invoked when a #ident or #sccs directive is read. | |
virtual void | PragmaDirective (SourceLocation Loc, PragmaIntroducerKind Introducer) |
Callback invoked when start reading any pragma directive. | |
virtual void | PragmaComment (SourceLocation Loc, const IdentifierInfo *Kind, const std::string &Str) |
Callback invoked when a #pragma comment directive is read. | |
virtual void | PragmaDetectMismatch (SourceLocation Loc, const std::string &Name, const std::string &Value) |
Callback invoked when a #pragma detect_mismatch directive is read. | |
virtual void | PragmaDebug (SourceLocation Loc, StringRef DebugType) |
Callback invoked when a #pragma clang __debug directive is read. | |
virtual void | PragmaMessage (SourceLocation Loc, StringRef Namespace, PragmaMessageKind Kind, StringRef Str) |
Callback invoked when a #pragma message directive is read. | |
virtual void | PragmaDiagnosticPush (SourceLocation Loc, StringRef Namespace) |
Callback invoked when a #pragma gcc dianostic push directive is read. | |
virtual void | PragmaDiagnosticPop (SourceLocation Loc, StringRef Namespace) |
Callback invoked when a #pragma gcc dianostic pop directive is read. | |
virtual void | PragmaDiagnostic (SourceLocation Loc, StringRef Namespace, diag::Severity mapping, StringRef Str) |
Callback invoked when a #pragma gcc dianostic directive is read. | |
virtual void | PragmaOpenCLExtension (SourceLocation NameLoc, const IdentifierInfo *Name, SourceLocation StateLoc, unsigned State) |
Called when an OpenCL extension is either disabled or enabled with a pragma. | |
virtual void | PragmaWarning (SourceLocation Loc, StringRef WarningSpec, ArrayRef< int > Ids) |
Callback invoked when a #pragma warning directive is read. | |
virtual void | PragmaWarningPush (SourceLocation Loc, int Level) |
Callback invoked when a #pragma warning(push) directive is read. | |
virtual void | PragmaWarningPop (SourceLocation Loc) |
Callback invoked when a #pragma warning(pop) directive is read. | |
virtual void | MacroExpands (const Token &MacroNameTok, const MacroDirective *MD, SourceRange Range, const MacroArgs *Args) |
Called by Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is found. | |
virtual void | MacroDefined (const Token &MacroNameTok, const MacroDirective *MD) |
Hook called whenever a macro definition is seen. | |
virtual void | MacroUndefined (const Token &MacroNameTok, const MacroDirective *MD) |
Hook called whenever a macro #undef is seen. | |
virtual void | Defined (const Token &MacroNameTok, const MacroDirective *MD, SourceRange Range) |
Hook called whenever the 'defined' operator is seen. | |
virtual void | SourceRangeSkipped (SourceRange Range) |
Hook called when a source range is skipped. | |
virtual void | If (SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue) |
Hook called whenever an #if is seen. | |
virtual void | Elif (SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc) |
Hook called whenever an #elif is seen. | |
virtual void | Ifdef (SourceLocation Loc, const Token &MacroNameTok, const MacroDirective *MD) |
Hook called whenever an #ifdef is seen. | |
virtual void | Ifndef (SourceLocation Loc, const Token &MacroNameTok, const MacroDirective *MD) |
Hook called whenever an #ifndef is seen. | |
virtual void | Else (SourceLocation Loc, SourceLocation IfLoc) |
Hook called whenever an #else is seen. | |
virtual void | Endif (SourceLocation Loc, SourceLocation IfLoc) |
Hook called whenever an #endif is seen. |
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 37 of file PPCallbacks.h.
Definition at line 269 of file PPCallbacks.h.
Definition at line 41 of file PPCallbacks.h.
Determines the kind of #pragma invoking a call to PragmaMessage.
PMK_Message |
#pragma message has been invoked. |
PMK_Warning |
#pragma GCC warning has been invoked. |
PMK_Error |
#pragma GCC error has been invoked. |
Definition at line 183 of file PPCallbacks.h.
PPCallbacks::~PPCallbacks | ( | ) | [virtual] |
Definition at line 27 of file PPLexerChange.cpp.
virtual void clang::PPCallbacks::Defined | ( | const Token & | MacroNameTok, |
const MacroDirective * | MD, | ||
SourceRange | Range | ||
) | [inline, virtual] |
Hook called whenever the 'defined' operator is seen.
MD | The MacroDirective if the name was a macro, null otherwise. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 259 of file PPCallbacks.h.
virtual void clang::PPCallbacks::Elif | ( | SourceLocation | Loc, |
SourceRange | ConditionRange, | ||
ConditionValueKind | ConditionValue, | ||
SourceLocation | IfLoc | ||
) | [inline, virtual] |
Hook called whenever an #elif is seen.
Loc | the source location of the directive. |
ConditionRange | The SourceRange of the expression being tested. |
ConditionValue | The evaluated value of the condition. |
IfLoc | the source location of the #if/#ifdef/#ifndef directive. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 289 of file PPCallbacks.h.
virtual void clang::PPCallbacks::Else | ( | SourceLocation | Loc, |
SourceLocation | IfLoc | ||
) | [inline, virtual] |
Hook called whenever an #else is seen.
Loc | the source location of the directive. |
IfLoc | the source location of the #if/#ifdef/#ifndef directive. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 312 of file PPCallbacks.h.
virtual void clang::PPCallbacks::Endif | ( | SourceLocation | Loc, |
SourceLocation | IfLoc | ||
) | [inline, virtual] |
Hook called whenever an #endif is seen.
Loc | the source location of the directive. |
IfLoc | the source location of the #if/#ifdef/#ifndef directive. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 318 of file PPCallbacks.h.
virtual void clang::PPCallbacks::EndOfMainFile | ( | ) | [inline, virtual] |
Callback invoked when the end of the main file is reached.
No subsequent callbacks will be made.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 149 of file PPCallbacks.h.
virtual void clang::PPCallbacks::FileChanged | ( | SourceLocation | Loc, |
FileChangeReason | Reason, | ||
SrcMgr::CharacteristicKind | FileType, | ||
FileID | PrevFID = FileID() |
||
) | [inline, virtual] |
Callback invoked whenever a source file is entered or exited.
Loc | Indicates the new location. |
PrevFID | the file that was exited if Reason is ExitFile. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 49 of file PPCallbacks.h.
virtual bool clang::PPCallbacks::FileNotFound | ( | StringRef | FileName, |
SmallVectorImpl< char > & | RecoveryPath | ||
) | [inline, virtual] |
Callback invoked whenever an inclusion directive results in a file-not-found error.
FileName | The name of the file being included, as written in the source code. |
RecoveryPath | If this client indicates that it can recover from this missing file, the client should set this as an additional header search patch. |
RecoveryPath
as a header search path. Reimplemented in clang::PPChainedCallbacks.
Definition at line 78 of file PPCallbacks.h.
virtual void clang::PPCallbacks::FileSkipped | ( | const FileEntry & | ParentFile, |
const Token & | FilenameTok, | ||
SrcMgr::CharacteristicKind | FileType | ||
) | [inline, virtual] |
Callback invoked whenever a source file is skipped as the result of header guard optimization.
ParentFile | The file that #included the skipped file. |
FilenameTok | The token in ParentFile that indicates the skipped file. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 61 of file PPCallbacks.h.
virtual void clang::PPCallbacks::Ident | ( | SourceLocation | Loc, |
const std::string & | str | ||
) | [inline, virtual] |
Callback invoked when a #ident or #sccs directive is read.
Loc | The location of the directive. |
str | The text of the directive. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 156 of file PPCallbacks.h.
virtual void clang::PPCallbacks::If | ( | SourceLocation | Loc, |
SourceRange | ConditionRange, | ||
ConditionValueKind | ConditionValue | ||
) | [inline, virtual] |
Hook called whenever an #if is seen.
Loc | the source location of the directive. |
ConditionRange | The SourceRange of the expression being tested. |
ConditionValue | The evaluated value of the condition. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 279 of file PPCallbacks.h.
virtual void clang::PPCallbacks::Ifdef | ( | SourceLocation | Loc, |
const Token & | MacroNameTok, | ||
const MacroDirective * | MD | ||
) | [inline, virtual] |
Hook called whenever an #ifdef is seen.
Loc | the source location of the directive. |
MacroNameTok | Information on the token being tested. |
MD | The MacroDirective if the name was a macro, null otherwise. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 297 of file PPCallbacks.h.
virtual void clang::PPCallbacks::Ifndef | ( | SourceLocation | Loc, |
const Token & | MacroNameTok, | ||
const MacroDirective * | MD | ||
) | [inline, virtual] |
Hook called whenever an #ifndef is seen.
Loc | the source location of the directive. |
MacroNameTok | Information on the token being tested. |
MD | The MacroDirective if the name was a macro, null otherwise. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 305 of file PPCallbacks.h.
virtual void clang::PPCallbacks::InclusionDirective | ( | SourceLocation | HashLoc, |
const Token & | IncludeTok, | ||
StringRef | FileName, | ||
bool | IsAngled, | ||
CharSourceRange | FilenameRange, | ||
const FileEntry * | File, | ||
StringRef | SearchPath, | ||
StringRef | RelativePath, | ||
const Module * | Imported | ||
) | [inline, virtual] |
Callback 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.
HashLoc | The location of the '#' that starts the inclusion directive. |
IncludeTok | The token that indicates the kind of inclusion directive, e.g., 'include' or 'import'. |
FileName | The name of the file being included, as written in the source code. |
IsAngled | Whether the file name was enclosed in angle brackets; otherwise, it was enclosed in quotes. |
FilenameRange | The character range of the quotes or angle brackets for the written file name. |
File | The actual file that may be included by this inclusion directive. |
SearchPath | Contains 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". |
RelativePath | The path relative to SearchPath, at which the include file was found. This is equal to FileName except for framework includes. |
Imported | The module, whenever an inclusion directive was automatically turned into a module import or null otherwise. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 120 of file PPCallbacks.h.
virtual void clang::PPCallbacks::MacroDefined | ( | const Token & | MacroNameTok, |
const MacroDirective * | MD | ||
) | [inline, virtual] |
Hook called whenever a macro definition is seen.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 246 of file PPCallbacks.h.
virtual void clang::PPCallbacks::MacroExpands | ( | const Token & | MacroNameTok, |
const MacroDirective * | MD, | ||
SourceRange | Range, | ||
const MacroArgs * | Args | ||
) | [inline, virtual] |
Called by Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is found.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 241 of file PPCallbacks.h.
virtual void clang::PPCallbacks::MacroUndefined | ( | const Token & | MacroNameTok, |
const MacroDirective * | MD | ||
) | [inline, virtual] |
Hook called whenever a macro #undef is seen.
MD is released immediately following this callback.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 253 of file PPCallbacks.h.
virtual void clang::PPCallbacks::moduleImport | ( | SourceLocation | ImportLoc, |
ModuleIdPath | Path, | ||
const Module * | Imported | ||
) | [inline, virtual] |
Callback invoked whenever there was an explicit module-import syntax.
ImportLoc | The location of import directive token. |
Path | The identifiers (and their locations) of the module "path", e.g., "std.vector" would be split into "std" and "vector". |
Imported | The imported module; can be null if importing failed. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 141 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaComment | ( | SourceLocation | Loc, |
const IdentifierInfo * | Kind, | ||
const std::string & | Str | ||
) | [inline, virtual] |
Callback invoked when a #pragma comment directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 165 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaDebug | ( | SourceLocation | Loc, |
StringRef | DebugType | ||
) | [inline, virtual] |
Callback invoked when a #pragma clang __debug directive is read.
Loc | The location of the debug directive. |
DebugType | The identifier following __debug. |
Definition at line 179 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaDetectMismatch | ( | SourceLocation | Loc, |
const std::string & | Name, | ||
const std::string & | Value | ||
) | [inline, virtual] |
Callback invoked when a #pragma detect_mismatch directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 171 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaDiagnostic | ( | SourceLocation | Loc, |
StringRef | Namespace, | ||
diag::Severity | mapping, | ||
StringRef | Str | ||
) | [inline, virtual] |
Callback invoked when a #pragma gcc dianostic directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 216 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaDiagnosticPop | ( | SourceLocation | Loc, |
StringRef | Namespace | ||
) | [inline, virtual] |
Callback invoked when a #pragma gcc dianostic pop directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 211 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaDiagnosticPush | ( | SourceLocation | Loc, |
StringRef | Namespace | ||
) | [inline, virtual] |
Callback invoked when a #pragma gcc dianostic push directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 205 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaDirective | ( | SourceLocation | Loc, |
PragmaIntroducerKind | Introducer | ||
) | [inline, virtual] |
Callback invoked when start reading any pragma directive.
Definition at line 160 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaMessage | ( | SourceLocation | Loc, |
StringRef | Namespace, | ||
PragmaMessageKind | Kind, | ||
StringRef | Str | ||
) | [inline, virtual] |
Callback invoked when a #pragma message directive is read.
Loc | The location of the message directive. |
Namespace | The namespace of the message directive. |
Kind | The type of the message directive. |
Str | The text of the message directive. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 199 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaOpenCLExtension | ( | SourceLocation | NameLoc, |
const IdentifierInfo * | Name, | ||
SourceLocation | StateLoc, | ||
unsigned | State | ||
) | [inline, virtual] |
Called when an OpenCL extension is either disabled or enabled with a pragma.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 221 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaWarning | ( | SourceLocation | Loc, |
StringRef | WarningSpec, | ||
ArrayRef< int > | Ids | ||
) | [inline, virtual] |
Callback invoked when a #pragma warning directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 227 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaWarningPop | ( | SourceLocation | Loc | ) | [inline, virtual] |
Callback invoked when a #pragma warning(pop) directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 236 of file PPCallbacks.h.
virtual void clang::PPCallbacks::PragmaWarningPush | ( | SourceLocation | Loc, |
int | Level | ||
) | [inline, virtual] |
Callback invoked when a #pragma warning(push) directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 232 of file PPCallbacks.h.
virtual void clang::PPCallbacks::SourceRangeSkipped | ( | SourceRange | Range | ) | [inline, virtual] |
Hook called when a source range is skipped.
Range | The SourceRange that was skipped. The range begins at the #if/#else directive and ends after the #endif/#else directive. |
Reimplemented in clang::PPChainedCallbacks, and clang::CoverageSourceInfo.
Definition at line 266 of file PPCallbacks.h.