clang
15.0.0git
|
This interface provides a way to observe the actions of the preprocessor as it does its thing. More...
#include "clang/Lex/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 | PragmaWarningSpecifier { PWS_Default, PWS_Disable, PWS_Error, PWS_Once, PWS_Suppress, PWS_Level1, PWS_Level2, PWS_Level3, PWS_Level4 } |
Callback invoked when a #pragma warning directive is read. 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. More... | |
virtual void | FileSkipped (const FileEntryRef &SkippedFile, const Token &FilenameTok, SrcMgr::CharacteristicKind FileType) |
Callback invoked whenever a source file is skipped as the result of header guard optimization. More... | |
virtual void | InclusionDirective (SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, Optional< FileEntryRef > File, StringRef SearchPath, StringRef RelativePath, const Module *Imported, SrcMgr::CharacteristicKind FileType) |
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. More... | |
virtual void | EnteredSubmodule (Module *M, SourceLocation ImportLoc, bool ForPragma) |
Callback invoked whenever a submodule was entered. More... | |
virtual void | LeftSubmodule (Module *M, SourceLocation ImportLoc, bool ForPragma) |
Callback invoked whenever a submodule was left. More... | |
virtual void | moduleImport (SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported) |
Callback invoked whenever there was an explicit module-import syntax. More... | |
virtual void | EndOfMainFile () |
Callback invoked when the end of the main file is reached. More... | |
virtual void | Ident (SourceLocation Loc, StringRef str) |
Callback invoked when a #ident or #sccs directive is read. More... | |
virtual void | PragmaDirective (SourceLocation Loc, PragmaIntroducerKind Introducer) |
Callback invoked when start reading any pragma directive. More... | |
virtual void | PragmaComment (SourceLocation Loc, const IdentifierInfo *Kind, StringRef Str) |
Callback invoked when a #pragma comment directive is read. More... | |
virtual void | PragmaMark (SourceLocation Loc, StringRef Trivia) |
Callback invoked when a #pragma mark comment is read. More... | |
virtual void | PragmaDetectMismatch (SourceLocation Loc, StringRef Name, StringRef Value) |
Callback invoked when a #pragma detect_mismatch directive is read. More... | |
virtual void | PragmaDebug (SourceLocation Loc, StringRef DebugType) |
Callback invoked when a #pragma clang __debug directive is read. More... | |
virtual void | PragmaMessage (SourceLocation Loc, StringRef Namespace, PragmaMessageKind Kind, StringRef Str) |
Callback invoked when a #pragma message directive is read. More... | |
virtual void | PragmaDiagnosticPush (SourceLocation Loc, StringRef Namespace) |
Callback invoked when a #pragma gcc diagnostic push directive is read. More... | |
virtual void | PragmaDiagnosticPop (SourceLocation Loc, StringRef Namespace) |
Callback invoked when a #pragma gcc diagnostic pop directive is read. More... | |
virtual void | PragmaDiagnostic (SourceLocation Loc, StringRef Namespace, diag::Severity mapping, StringRef Str) |
Callback invoked when a #pragma gcc diagnostic directive is read. More... | |
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. More... | |
virtual void | PragmaWarning (SourceLocation Loc, PragmaWarningSpecifier WarningSpec, ArrayRef< int > Ids) |
virtual void | PragmaWarningPush (SourceLocation Loc, int Level) |
Callback invoked when a #pragma warning(push) directive is read. More... | |
virtual void | PragmaWarningPop (SourceLocation Loc) |
Callback invoked when a #pragma warning(pop) directive is read. More... | |
virtual void | PragmaExecCharsetPush (SourceLocation Loc, StringRef Str) |
Callback invoked when a #pragma execution_character_set(push) directive is read. More... | |
virtual void | PragmaExecCharsetPop (SourceLocation Loc) |
Callback invoked when a #pragma execution_character_set(pop) directive is read. More... | |
virtual void | PragmaAssumeNonNullBegin (SourceLocation Loc) |
Callback invoked when a #pragma clang assume_nonnull begin directive is read. More... | |
virtual void | PragmaAssumeNonNullEnd (SourceLocation Loc) |
Callback invoked when a #pragma clang assume_nonnull end directive is read. More... | |
virtual void | MacroExpands (const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) |
Called by Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is found. More... | |
virtual void | MacroDefined (const Token &MacroNameTok, const MacroDirective *MD) |
Hook called whenever a macro definition is seen. More... | |
virtual void | MacroUndefined (const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef) |
Hook called whenever a macro #undef is seen. More... | |
virtual void | Defined (const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range) |
Hook called whenever the 'defined' operator is seen. More... | |
virtual void | HasInclude (SourceLocation Loc, StringRef FileName, bool IsAngled, Optional< FileEntryRef > File, SrcMgr::CharacteristicKind FileType) |
Hook called when a '__has_include' or '__has_include_next' directive is read. More... | |
virtual void | SourceRangeSkipped (SourceRange Range, SourceLocation EndifLoc) |
Hook called when a source range is skipped. More... | |
virtual void | If (SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue) |
Hook called whenever an #if is seen. More... | |
virtual void | Elif (SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc) |
Hook called whenever an #elif is seen. More... | |
virtual void | Ifdef (SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) |
Hook called whenever an #ifdef is seen. More... | |
virtual void | Elifdef (SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) |
Hook called whenever an #elifdef branch is taken. More... | |
virtual void | Elifdef (SourceLocation Loc, SourceRange ConditionRange, SourceLocation IfLoc) |
Hook called whenever an #elifdef is skipped. More... | |
virtual void | Ifndef (SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) |
Hook called whenever an #ifndef is seen. More... | |
virtual void | Elifndef (SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) |
Hook called whenever an #elifndef branch is taken. More... | |
virtual void | Elifndef (SourceLocation Loc, SourceRange ConditionRange, SourceLocation IfLoc) |
Hook called whenever an #elifndef is skipped. More... | |
virtual void | Else (SourceLocation Loc, SourceLocation IfLoc) |
Hook called whenever an #else is seen. More... | |
virtual void | Endif (SourceLocation Loc, SourceLocation IfLoc) |
Hook called whenever an #endif is seen. More... | |
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 35 of file PPCallbacks.h.
Enumerator | |
---|---|
CVK_NotEvaluated | |
CVK_False | |
CVK_True |
Definition at line 320 of file PPCallbacks.h.
Enumerator | |
---|---|
EnterFile | |
ExitFile | |
SystemHeaderPragma | |
RenameFile |
Definition at line 39 of file PPCallbacks.h.
Determines the kind of #pragma invoking a call to PragmaMessage.
Enumerator | |
---|---|
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 194 of file PPCallbacks.h.
Callback invoked when a #pragma warning directive is read.
Enumerator | |
---|---|
PWS_Default | |
PWS_Disable | |
PWS_Error | |
PWS_Once | |
PWS_Suppress | |
PWS_Level1 | |
PWS_Level2 | |
PWS_Level3 | |
PWS_Level4 |
Definition at line 238 of file PPCallbacks.h.
|
virtualdefault |
|
inlinevirtual |
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 301 of file PPCallbacks.h.
|
inlinevirtual |
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 340 of file PPCallbacks.h.
|
inlinevirtual |
Hook called whenever an #elifdef branch is taken.
Loc | the source location of the directive. |
MacroNameTok | Information on the token being tested. |
MD | The MacroDefinition if the name was a macro, null otherwise. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 356 of file PPCallbacks.h.
|
inlinevirtual |
Hook called whenever an #elifdef is skipped.
Loc | the source location of the directive. |
ConditionRange | The SourceRange of the expression being tested. |
IfLoc | the source location of the #if/#ifdef/#ifndef directive. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 364 of file PPCallbacks.h.
|
inlinevirtual |
Hook called whenever an #elifndef branch is taken.
Loc | the source location of the directive. |
MacroNameTok | Information on the token being tested. |
MD | The MacroDefinition if the name was a macro, null otherwise. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 380 of file PPCallbacks.h.
|
inlinevirtual |
Hook called whenever an #elifndef is skipped.
Loc | the source location of the directive. |
ConditionRange | The SourceRange of the expression being tested. |
IfLoc | the source location of the #if/#ifdef/#ifndef directive. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 388 of file PPCallbacks.h.
|
inlinevirtual |
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 395 of file PPCallbacks.h.
|
inlinevirtual |
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 401 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when the end of the main file is reached.
No subsequent callbacks will be made.
Reimplemented in clang::PPChainedCallbacks, and clang::tooling::dependencies::ModuleDepCollectorPP.
Definition at line 157 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked whenever a submodule was entered.
M | The submodule we have entered. |
ImportLoc | The location of import directive token. |
ForPragma | If entering from pragma directive. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 125 of file PPCallbacks.h.
|
inlinevirtual |
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::MacroPPCallbacks, clang::PPChainedCallbacks, clang::sema::SemaPPCallbacks, and clang::tooling::dependencies::ModuleDepCollectorPP.
Definition at line 47 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked whenever a source file is skipped as the result of header guard optimization.
SkippedFile | The file that is skipped instead of entering #include |
FilenameTok | The file name token in #include "FileName" directive or macro expanded file name token from #include MACRO(PARAMS) directive. Note that FilenameTok contains corresponding quotes/angles symbols. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 60 of file PPCallbacks.h.
|
virtual |
Hook called when a '__has_include' or '__has_include_next' directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 17 of file PPCallbacks.cpp.
|
inlinevirtual |
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 164 of file PPCallbacks.h.
|
inlinevirtual |
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 330 of file PPCallbacks.h.
|
inlinevirtual |
Hook called whenever an #ifdef is seen.
Loc | the source location of the directive. |
MacroNameTok | Information on the token being tested. |
MD | The MacroDefinition if the name was a macro, null otherwise. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 348 of file PPCallbacks.h.
|
inlinevirtual |
Hook called whenever an #ifndef is seen.
Loc | the source location of the directive. |
MacroNameTok | Information on the token being tested. |
MD | The MacroDefiniton if the name was a macro, null otherwise. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 372 of file PPCallbacks.h.
|
inlinevirtual |
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. |
FileType | The characteristic kind, indicates whether a file or directory holds normal user code, system code, or system code which is implicitly 'extern "C"' in C++ mode. |
Reimplemented in clang::PPChainedCallbacks, clang::tooling::dependencies::ModuleDepCollectorPP, and clang::MacroPPCallbacks.
Definition at line 105 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked whenever a submodule was left.
M | The submodule we have left. |
ImportLoc | The location of import directive token. |
ForPragma | If entering from pragma directive. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 136 of file PPCallbacks.h.
|
inlinevirtual |
Hook called whenever a macro definition is seen.
Reimplemented in clang::PPChainedCallbacks, and clang::MacroPPCallbacks.
Definition at line 284 of file PPCallbacks.h.
|
inlinevirtual |
Called by Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is found.
Reimplemented in clang::PPChainedCallbacks, clang::detail::MacroExpansionRangeRecorder, and TokenCollector::CollectPPExpansions.
Definition at line 279 of file PPCallbacks.h.
|
inlinevirtual |
Hook called whenever a macro #undef is seen.
MacroNameTok | The active Token |
MD | A MacroDefinition for the named macro. |
Undef | New MacroDirective if the macro was defined, null otherwise. |
MD is released immediately following this callback.
Reimplemented in clang::PPChainedCallbacks, and clang::MacroPPCallbacks.
Definition at line 294 of file PPCallbacks.h.
|
inlinevirtual |
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, and clang::tooling::dependencies::ModuleDepCollectorPP.
Definition at line 149 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma clang assume_nonnull begin directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 271 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma clang assume_nonnull end directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 275 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma comment directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 173 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma clang __debug directive is read.
Loc | The location of the debug directive. |
DebugType | The identifier following __debug. |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 190 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma detect_mismatch directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 183 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma gcc diagnostic directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 227 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma gcc diagnostic pop directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 222 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma gcc diagnostic push directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 216 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when start reading any pragma directive.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 168 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma execution_character_set(pop) directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 267 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma execution_character_set(push) directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 263 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma mark comment is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 178 of file PPCallbacks.h.
|
inlinevirtual |
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 210 of file PPCallbacks.h.
|
inlinevirtual |
Called when an OpenCL extension is either disabled or enabled with a pragma.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 232 of file PPCallbacks.h.
|
inlinevirtual |
Reimplemented in clang::PPChainedCallbacks.
Definition at line 249 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma warning(pop) directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 258 of file PPCallbacks.h.
|
inlinevirtual |
Callback invoked when a #pragma warning(push) directive is read.
Reimplemented in clang::PPChainedCallbacks.
Definition at line 254 of file PPCallbacks.h.
|
inlinevirtual |
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. |
EndifLoc | The end location of the 'endif' token, which may precede the range skipped by the directive (e.g excluding comments after an 'endif'). |
Reimplemented in clang::PPChainedCallbacks, and clang::CoverageSourceInfo.
Definition at line 317 of file PPCallbacks.h.