clang  14.0.0git
Public Member Functions | List of all members
clang::tooling::dependencies::ModuleDepCollectorPP Class Referencefinal

Callback that records textual includes and direct modular includes/imports during preprocessing. More...

#include "clang/Tooling/DependencyScanning/ModuleDepCollector.h"

Inheritance diagram for clang::tooling::dependencies::ModuleDepCollectorPP:
Inheritance graph
[legend]
Collaboration diagram for clang::tooling::dependencies::ModuleDepCollectorPP:
Collaboration graph
[legend]

Public Member Functions

 ModuleDepCollectorPP (ModuleDepCollector &MDC)
 
void FileChanged (SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID) override
 Callback invoked whenever a source file is entered or exited. More...
 
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. More...
 
void moduleImport (SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported) override
 Callback invoked whenever there was an explicit module-import syntax. More...
 
void EndOfMainFile () override
 Callback invoked when the end of the main file is reached. More...
 
- Public Member Functions inherited from clang::PPCallbacks
virtual ~PPCallbacks ()
 
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 bool FileNotFound (StringRef FileName, SmallVectorImpl< char > &RecoveryPath)
 Callback invoked whenever an inclusion directive results in a file-not-found error. 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 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...
 

Additional Inherited Members

- Public Types inherited from clang::PPCallbacks
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 }
 

Detailed Description

Callback that records textual includes and direct modular includes/imports during preprocessing.

At the end of the main file, it also collects transitive modular dependencies and passes everything to the DependencyConsumer of the parent ModuleDepCollector.

Definition at line 142 of file ModuleDepCollector.h.

Constructor & Destructor Documentation

◆ ModuleDepCollectorPP()

clang::tooling::dependencies::ModuleDepCollectorPP::ModuleDepCollectorPP ( ModuleDepCollector MDC)
inline

Definition at line 144 of file ModuleDepCollector.h.

Member Function Documentation

◆ EndOfMainFile()

void ModuleDepCollectorPP::EndOfMainFile ( )
overridevirtual

◆ FileChanged()

void ModuleDepCollectorPP::FileChanged ( SourceLocation  Loc,
FileChangeReason  Reason,
SrcMgr::CharacteristicKind  FileType,
FileID  PrevFID 
)
overridevirtual

Callback invoked whenever a source file is entered or exited.

Parameters
LocIndicates the new location.
PrevFIDthe file that was exited if Reason is ExitFile.

Reimplemented from clang::PPCallbacks.

Definition at line 129 of file ModuleDepCollector.cpp.

References clang::PPCallbacks::EnterFile, Filename, clang::CompilerInstance::getInvocation(), clang::CompilerInvocation::getModuleHash(), clang::CompilerInstance::getSourceManager(), clang::tooling::dependencies::DependencyConsumer::handleContextHash(), SM, and string().

◆ InclusionDirective()

void ModuleDepCollectorPP::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 
)
overridevirtual

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.

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.
FilenameRangeThe character range of the quotes or angle brackets for the written file name.
FileThe actual file that may be included by this 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.
ImportedThe module, whenever an inclusion directive was automatically turned into a module import or null otherwise.
FileTypeThe 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 from clang::PPCallbacks.

Definition at line 154 of file ModuleDepCollector.cpp.

References clang::File, and string().

◆ moduleImport()

void ModuleDepCollectorPP::moduleImport ( SourceLocation  ImportLoc,
ModuleIdPath  Path,
const Module Imported 
)
overridevirtual

Callback invoked whenever there was an explicit module-import syntax.

Parameters
ImportLocThe location of import directive token.
PathThe identifiers (and their locations) of the module "path", e.g., "std.vector" would be split into "std" and "vector".
ImportedThe imported module; can be null if importing failed.

Reimplemented from clang::PPCallbacks.

Definition at line 167 of file ModuleDepCollector.cpp.


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