class MacroPPCallbacks
Declaration
class MacroPPCallbacks : public PPCallbacks { /* full declaration omitted */ };
Description
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.
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:26
Inherits from: PPCallbacks
Member Variables
- private clang::CodeGenerator* Gen
- A pointer to code generator, where debug info generator can be found.
- private clang::Preprocessor& PP
- Preprocessor.
- private clang::SourceLocation LastHashLoc
- Location of recent included file, used for line number.
- private int EnteredCommandLineIncludeFiles = 0
- Counts current number of command line included files, which were entered and were not exited yet.
- private clang::MacroPPCallbacks::FileScopeStatus Status
- private llvm::SmallVector<llvm::DIMacroFile*, 4> Scopes
- Parent contains all entered files that were not exited yet according to the inclusion order.
Method Overview
- public void FileChanged(clang::SourceLocation Loc, clang::PPCallbacks::FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, clang::FileID PrevFID = clang::FileID())
- private void FileEntered(clang::SourceLocation Loc)
- private void FileExited(clang::SourceLocation Loc)
- public void InclusionDirective(clang::SourceLocation HashLoc, const clang::Token & IncludeTok, llvm::StringRef FileName, bool IsAngled, clang::CharSourceRange FilenameRange, Optional<clang::FileEntryRef> File, llvm::StringRef SearchPath, llvm::StringRef RelativePath, const clang::Module * Imported, SrcMgr::CharacteristicKind FileType)
- public void MacroDefined(const clang::Token & MacroNameTok, const clang::MacroDirective * MD)
- public MacroPPCallbacks(clang::CodeGenerator * Gen, clang::Preprocessor & PP)
- public void MacroUndefined(const clang::Token & MacroNameTok, const clang::MacroDefinition & MD, const clang::MacroDirective * Undef)
- private clang::SourceLocation getCorrectLocation(clang::SourceLocation Loc)
- private llvm::DIMacroFile * getCurrentScope()
- private void updateStatusToNextScope()
- private static void writeMacroDefinition(const clang::IdentifierInfo & II, const clang::MacroInfo & MI, clang::Preprocessor & PP, llvm::raw_ostream & Name, llvm::raw_ostream & Value)
Inherited from PPCallbacks:
- public Defined
- public Elif
- public Elifdef
- public Elifdef
- public Elifndef
- public Elifndef
- public Else
- public EndOfMainFile
- public Endif
- public EnteredSubmodule
- public FileChanged
- public FileSkipped
- public HasInclude
- public Ident
- public If
- public Ifdef
- public Ifndef
- public InclusionDirective
- public LeftSubmodule
- public LexedFileChanged
- public MacroDefined
- public MacroExpands
- public MacroUndefined
- public PragmaAssumeNonNullBegin
- public PragmaAssumeNonNullEnd
- public PragmaComment
- public PragmaDebug
- public PragmaDetectMismatch
- public PragmaDiagnostic
- public PragmaDiagnosticPop
- public PragmaDiagnosticPush
- public PragmaDirective
- public PragmaExecCharsetPop
- public PragmaExecCharsetPush
- public PragmaMark
- public PragmaMessage
- public PragmaOpenCLExtension
- public PragmaWarning
- public PragmaWarningPop
- public PragmaWarningPush
- public SourceRangeSkipped
- public moduleImport
Methods
¶void FileChanged(
clang::SourceLocation Loc,
clang::PPCallbacks::FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
clang::FileID PrevFID = clang::FileID())
void FileChanged(
clang::SourceLocation Loc,
clang::PPCallbacks::FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
clang::FileID PrevFID = clang::FileID())
Description
Callback invoked whenever a source file is entered or exited.
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:96
Parameters
- clang::SourceLocation Loc
- Indicates the new location.
- clang::PPCallbacks::FileChangeReason Reason
- SrcMgr::CharacteristicKind FileType
- clang::FileID PrevFID = clang::FileID()
- the file that was exited if \p Reason is ExitFile.
¶void FileEntered(clang::SourceLocation Loc)
void FileEntered(clang::SourceLocation Loc)
Description
Handle the case when entering a file.
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:82
Parameters
- clang::SourceLocation Loc
- Indicates the new location.
¶void FileExited(clang::SourceLocation Loc)
void FileExited(clang::SourceLocation Loc)
Description
Handle the case when exiting a file.
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:87
Parameters
- clang::SourceLocation Loc
- Indicates the new location.
¶void InclusionDirective(
clang::SourceLocation HashLoc,
const clang::Token& IncludeTok,
llvm::StringRef FileName,
bool IsAngled,
clang::CharSourceRange FilenameRange,
Optional<clang::FileEntryRef> File,
llvm::StringRef SearchPath,
llvm::StringRef RelativePath,
const clang::Module* Imported,
SrcMgr::CharacteristicKind FileType)
void InclusionDirective(
clang::SourceLocation HashLoc,
const clang::Token& IncludeTok,
llvm::StringRef FileName,
bool IsAngled,
clang::CharSourceRange FilenameRange,
Optional<clang::FileEntryRef> File,
llvm::StringRef SearchPath,
llvm::StringRef RelativePath,
const clang::Module* Imported,
SrcMgr::CharacteristicKind FileType)
Description
Callback invoked whenever a directive (#xxx) is processed.
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:101
Parameters
- clang::SourceLocation HashLoc
- const clang::Token& IncludeTok
- llvm::StringRef FileName
- bool IsAngled
- clang::CharSourceRange FilenameRange
- Optional<clang::FileEntryRef> File
- llvm::StringRef SearchPath
- llvm::StringRef RelativePath
- const clang::Module* Imported
- SrcMgr::CharacteristicKind FileType
¶void MacroDefined(
const clang::Token& MacroNameTok,
const clang::MacroDirective* MD)
void MacroDefined(
const clang::Token& MacroNameTok,
const clang::MacroDirective* MD)
Description
Hook called whenever a macro definition is seen.
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:109
Parameters
- const clang::Token& MacroNameTok
- const clang::MacroDirective* MD
¶MacroPPCallbacks(clang::CodeGenerator* Gen,
clang::Preprocessor& PP)
MacroPPCallbacks(clang::CodeGenerator* Gen,
clang::Preprocessor& PP)
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:90
Parameters
¶void MacroUndefined(
const clang::Token& MacroNameTok,
const clang::MacroDefinition& MD,
const clang::MacroDirective* Undef)
void MacroUndefined(
const clang::Token& MacroNameTok,
const clang::MacroDefinition& MD,
const clang::MacroDirective* Undef)
Description
Hook called whenever a macro # undef is seen. MD is released immediately following this callback.
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:115
Parameters
- const clang::Token& MacroNameTok
- const clang::MacroDefinition& MD
- const clang::MacroDirective* Undef
¶clang::SourceLocation getCorrectLocation(
clang::SourceLocation Loc)
clang::SourceLocation getCorrectLocation(
clang::SourceLocation Loc)
Description
Get current line location or invalid location.
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:61
Parameters
- clang::SourceLocation Loc
- current line location.
Returns
current line location \p `Loc`, or invalid location if it's in a skipped file scope.
¶llvm::DIMacroFile* getCurrentScope()
llvm::DIMacroFile* getCurrentScope()
Description
Get current DIMacroFile scope.
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:55
Returns
current DIMacroFile scope or nullptr if there is no such scope.
¶void updateStatusToNextScope()
void updateStatusToNextScope()
Description
Update current file scope status to next file scope.
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:77
¶static void writeMacroDefinition(
const clang::IdentifierInfo& II,
const clang::MacroInfo& MI,
clang::Preprocessor& PP,
llvm::raw_ostream& Name,
llvm::raw_ostream& Value)
static void writeMacroDefinition(
const clang::IdentifierInfo& II,
const clang::MacroInfo& MI,
clang::Preprocessor& PP,
llvm::raw_ostream& Name,
llvm::raw_ostream& Value)
Description
Use the passed preprocessor to write the macro name and value from the given macro info and identifier info into the given \p `Name` and \p `Value` output streams.
Declared at: clang/lib/CodeGen/MacroPPCallbacks.h:72
Parameters
- const clang::IdentifierInfo& II
- Identifier info, used to get the Macro name.
- const clang::MacroInfo& MI
- Macro info, used to get the Macro argumets and values.
- clang::Preprocessor& PP
- Preprocessor.
- llvm::raw_ostream& Name
- Place holder for returned macro name and arguments.
- llvm::raw_ostream& Value
- Place holder for returned macro value.