15 #ifndef LLVM_CLANG_LEX_PPCALLBACKS_H 16 #define LLVM_CLANG_LEX_PPCALLBACKS_H 23 #include "llvm/ADT/StringRef.h" 28 class MacroDefinition;
62 const Token &FilenameTok,
125 const Token &IncludeTok,
130 StringRef SearchPath,
131 StringRef RelativePath,
210 StringRef Namespace) {
216 StringRef Namespace) {
343 virtual void anchor();
344 std::unique_ptr<PPCallbacks>
First, Second;
348 std::unique_ptr<PPCallbacks> _Second)
349 : First(
std::move(_First)), Second(
std::move(_Second)) {}
353 FileID PrevFID)
override {
354 First->FileChanged(Loc, Reason, FileType, PrevFID);
355 Second->FileChanged(Loc, Reason, FileType, PrevFID);
359 const Token &FilenameTok,
361 First->FileSkipped(SkippedFile, FilenameTok, FileType);
362 Second->FileSkipped(SkippedFile, FilenameTok, FileType);
367 return First->FileNotFound(FileName, RecoveryPath) ||
368 Second->FileNotFound(FileName, RecoveryPath);
372 StringRef FileName,
bool IsAngled,
374 StringRef SearchPath, StringRef RelativePath,
377 First->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled,
378 FilenameRange, File, SearchPath, RelativePath,
380 Second->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled,
381 FilenameRange, File, SearchPath, RelativePath,
386 const Module *Imported)
override {
387 First->moduleImport(ImportLoc, Path, Imported);
388 Second->moduleImport(ImportLoc, Path, Imported);
392 First->EndOfMainFile();
393 Second->EndOfMainFile();
397 First->Ident(Loc, str);
398 Second->Ident(Loc, str);
403 First->PragmaDirective(Loc, Introducer);
404 Second->PragmaDirective(Loc, Introducer);
408 StringRef Str)
override {
409 First->PragmaComment(Loc, Kind, Str);
410 Second->PragmaComment(Loc, Kind, Str);
414 StringRef
Value)
override {
415 First->PragmaDetectMismatch(Loc, Name, Value);
416 Second->PragmaDetectMismatch(Loc, Name, Value);
420 First->PragmaDebug(Loc, DebugType);
421 Second->PragmaDebug(Loc, DebugType);
426 First->PragmaMessage(Loc, Namespace, Kind, Str);
427 Second->PragmaMessage(Loc, Namespace, Kind, Str);
431 First->PragmaDiagnosticPush(Loc, Namespace);
432 Second->PragmaDiagnosticPush(Loc, Namespace);
436 First->PragmaDiagnosticPop(Loc, Namespace);
437 Second->PragmaDiagnosticPop(Loc, Namespace);
442 First->PragmaDiagnostic(Loc, Namespace, mapping, Str);
443 Second->PragmaDiagnostic(Loc, Namespace, mapping, Str);
448 First->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State);
449 Second->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State);
454 First->PragmaWarning(Loc, WarningSpec, Ids);
455 Second->PragmaWarning(Loc, WarningSpec, Ids);
459 First->PragmaWarningPush(Loc, Level);
460 Second->PragmaWarningPush(Loc, Level);
464 First->PragmaWarningPop(Loc);
465 Second->PragmaWarningPop(Loc);
469 First->PragmaAssumeNonNullBegin(Loc);
470 Second->PragmaAssumeNonNullBegin(Loc);
474 First->PragmaAssumeNonNullEnd(Loc);
475 Second->PragmaAssumeNonNullEnd(Loc);
480 First->MacroExpands(MacroNameTok, MD, Range, Args);
481 Second->MacroExpands(MacroNameTok, MD, Range, Args);
486 First->MacroDefined(MacroNameTok, MD);
487 Second->MacroDefined(MacroNameTok, MD);
493 First->MacroUndefined(MacroNameTok, MD, Undef);
494 Second->MacroUndefined(MacroNameTok, MD, Undef);
499 First->Defined(MacroNameTok, MD, Range);
500 Second->Defined(MacroNameTok, MD, Range);
504 First->SourceRangeSkipped(Range, EndifLoc);
505 Second->SourceRangeSkipped(Range, EndifLoc);
511 First->If(Loc, ConditionRange, ConditionValue);
512 Second->If(Loc, ConditionRange, ConditionValue);
518 First->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
519 Second->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
525 First->Ifdef(Loc, MacroNameTok, MD);
526 Second->Ifdef(Loc, MacroNameTok, MD);
532 First->Ifndef(Loc, MacroNameTok, MD);
533 Second->Ifndef(Loc, MacroNameTok, MD);
538 First->Else(Loc, IfLoc);
539 Second->Else(Loc, IfLoc);
544 First->Endif(Loc, IfLoc);
545 Second->Endif(Loc, IfLoc);
void PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace) override
Callback invoked when a #pragma gcc diagnostic push directive is read.
virtual void Elif(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc)
Hook called whenever an #elif is seen.
virtual void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace)
Callback invoked when a #pragma gcc diagnostic pop directive is read.
void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef) override
Hook called whenever a macro #undef is seen.
#pragma GCC error has been invoked.
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 EndOfMainFile()
Callback invoked when the end of the main file is reached.
Defines the SourceManager interface.
void PragmaWarning(SourceLocation Loc, StringRef WarningSpec, ArrayRef< int > Ids) override
Callback invoked when a #pragma warning directive is read.
virtual void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef)
Hook called whenever a macro #undef is seen.
A description of the current definition of a macro.
void If(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue) override
Hook called whenever an #if is seen.
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.
void PragmaWarningPop(SourceLocation Loc) override
Callback invoked when a #pragma warning(pop) directive is read.
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing)...
void Ifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
Hook called whenever an #ifdef is seen.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
This interface provides a way to observe the actions of the preprocessor as it does its thing...
virtual void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD)
Hook called whenever a macro definition is seen.
virtual void Else(SourceLocation Loc, SourceLocation IfLoc)
Hook called whenever an #else is seen.
virtual void If(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue)
Hook called whenever an #if is seen.
One of these records is kept for each identifier that is lexed.
virtual void PragmaDebug(SourceLocation Loc, StringRef DebugType)
Callback invoked when a #pragma clang __debug directive is read.
Token - This structure provides full information about a lexed token.
virtual void Endif(SourceLocation Loc, SourceLocation IfLoc)
Hook called whenever an #endif is seen.
Describes a module or submodule.
PPChainedCallbacks(std::unique_ptr< PPCallbacks > _First, std::unique_ptr< PPCallbacks > _Second)
void FileSkipped(const FileEntry &SkippedFile, const Token &FilenameTok, SrcMgr::CharacteristicKind FileType) override
Callback invoked whenever a source file is skipped as the result of header guard optimization.
PragmaIntroducerKind
Describes how the pragma was introduced, e.g., with #pragma, _Pragma, or __pragma.
virtual void Defined(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range)
Hook called whenever the 'defined' operator is seen.
void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
Hook called whenever an #ifndef is seen.
PragmaMessageKind
Determines the kind of #pragma invoking a call to PragmaMessage.
virtual void PragmaAssumeNonNullBegin(SourceLocation Loc)
Callback invoked when a #pragma clang assume_nonnull begin directive is read.
#pragma GCC warning has been invoked.
virtual void PragmaWarning(SourceLocation Loc, StringRef WarningSpec, ArrayRef< int > Ids)
Callback invoked when a #pragma warning directive is read.
bool FileNotFound(StringRef FileName, SmallVectorImpl< char > &RecoveryPath) override
Callback invoked whenever an inclusion directive results in a file-not-found error.
Represents a character-granular source range.
void Ident(SourceLocation Loc, StringRef str) override
Callback invoked when a #ident or #sccs directive is read.
void PragmaWarningPush(SourceLocation Loc, int Level) override
Callback invoked when a #pragma warning(push) directive is read.
void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID) override
Callback invoked whenever a source file is entered or exited.
MacroArgs - An instance of this class captures information about the formal arguments specified to a ...
void Elif(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc) override
Hook called whenever an #elif is seen.
void PragmaAssumeNonNullBegin(SourceLocation Loc) override
Callback invoked when a #pragma clang assume_nonnull begin directive is read.
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID=FileID())
Callback invoked whenever a source file is entered or exited.
void PragmaMessage(SourceLocation Loc, StringRef Namespace, PragmaMessageKind Kind, StringRef Str) override
Callback invoked when a #pragma message directive is read.
virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, StringRef Str)
Callback invoked when a #pragma comment directive is read.
virtual void PragmaDirective(SourceLocation Loc, PragmaIntroducerKind Introducer)
Callback invoked when start reading any pragma directive.
Simple wrapper class for chaining callbacks.
virtual void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *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.
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
virtual void Ident(SourceLocation Loc, StringRef str)
Callback invoked when a #ident or #sccs directive is read.
Encodes a location in the source.
void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported) override
Callback invoked whenever there was an explicit module-import syntax.
virtual void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args)
Called by Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is found.
#pragma message has been invoked.
void PragmaDebug(SourceLocation Loc, StringRef DebugType) override
Callback invoked when a #pragma clang __debug directive is read.
void PragmaAssumeNonNullEnd(SourceLocation Loc) override
Callback invoked when a #pragma clang assume_nonnull end directive is read.
Cached information about one file (either on disk or in the virtual file system). ...
virtual void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported)
Callback invoked whenever there was an explicit module-import syntax.
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, const Module *Imported, SrcMgr::CharacteristicKind FileType) override
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 Ifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD)
Hook called whenever an #ifdef is seen.
void PragmaDirective(SourceLocation Loc, PragmaIntroducerKind Introducer) override
Callback invoked when start reading any pragma directive.
void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override
Called by Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is found.
virtual void PragmaMessage(SourceLocation Loc, StringRef Namespace, PragmaMessageKind Kind, StringRef Str)
Callback invoked when a #pragma message directive is read.
void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, StringRef Str) override
Callback invoked when a #pragma comment directive is read.
void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, diag::Severity mapping, StringRef Str) override
Callback invoked when a #pragma gcc diagnostic directive is read.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
void Defined(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range) override
Hook called whenever the 'defined' operator is seen.
void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) override
Hook called whenever a macro definition is seen.
Dataflow Directional Tag Classes.
void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace) override
Callback invoked when a #pragma gcc diagnostic pop directive is read.
void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value) override
Callback invoked when a #pragma detect_mismatch directive is read.
virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
Callback invoked when a #pragma detect_mismatch directive is read.
void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name, SourceLocation StateLoc, unsigned State) override
Called when an OpenCL extension is either disabled or enabled with a pragma.
void EndOfMainFile() override
Callback invoked when the end of the main file is reached.
virtual bool FileNotFound(StringRef FileName, SmallVectorImpl< char > &RecoveryPath)
Callback invoked whenever an inclusion directive results in a file-not-found error.
virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD)
Hook called whenever an #ifndef is seen.
virtual void PragmaAssumeNonNullEnd(SourceLocation Loc)
Callback invoked when a #pragma clang assume_nonnull end directive is read.
Defines the clang::SourceLocation class and associated facilities.
void Endif(SourceLocation Loc, SourceLocation IfLoc) override
Hook called whenever an #endif is seen.
virtual void PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace)
Callback invoked when a #pragma gcc diagnostic push directive is read.
Defines the Diagnostic IDs-related interfaces.
virtual void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, diag::Severity mapping, StringRef Str)
Callback invoked when a #pragma gcc diagnostic directive is read.
void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override
Hook called when a source range is skipped.
A trivial tuple used to represent a source range.
void Else(SourceLocation Loc, SourceLocation IfLoc) override
Hook called whenever an #else is seen.
virtual void FileSkipped(const FileEntry &SkippedFile, const Token &FilenameTok, SrcMgr::CharacteristicKind FileType)
Callback invoked whenever a source file is skipped as the result of header guard optimization.
virtual void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc)
Hook called when a source range is skipped.