clang 20.0.0git
Public Member Functions | Protected Member Functions | List of all members
clang::DependencyFileGenerator Class Reference

Builds a dependency file when attached to a Preprocessor (for includes) and ASTReader (for module imports), and writes it out at the end of processing a source file. More...

#include "clang/Frontend/Utils.h"

Inheritance diagram for clang::DependencyFileGenerator:
Inheritance graph
[legend]

Public Member Functions

 DependencyFileGenerator (const DependencyOutputOptions &Opts)
 
void attachToPreprocessor (Preprocessor &PP) override
 
void finishedMainFile (DiagnosticsEngine &Diags) override
 Called when the end of the main file is reached.
 
bool needSystemDependencies () final
 Return true if system files should be passed to sawDependency().
 
bool sawDependency (StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsMissing) final
 Called when a new file is seen.
 
- Public Member Functions inherited from clang::DependencyCollector
virtual ~DependencyCollector ()
 
virtual void attachToPreprocessor (Preprocessor &PP)
 
virtual void attachToASTReader (ASTReader &R)
 
ArrayRef< std::string > getDependencies () const
 
virtual bool sawDependency (StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsMissing)
 Called when a new file is seen.
 
virtual void finishedMainFile (DiagnosticsEngine &Diags)
 Called when the end of the main file is reached.
 
virtual bool needSystemDependencies ()
 Return true if system files should be passed to sawDependency().
 
virtual void maybeAddDependency (StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsMissing)
 Add a dependency Filename if it has not been seen before and sawDependency() returns true.
 

Protected Member Functions

void outputDependencyFile (llvm::raw_ostream &OS)
 
- Protected Member Functions inherited from clang::DependencyCollector
bool addDependency (StringRef Filename)
 Return true if the filename was added to the list of dependencies, false otherwise.
 

Detailed Description

Builds a dependency file when attached to a Preprocessor (for includes) and ASTReader (for module imports), and writes it out at the end of processing a source file.

Users should attach to the ast reader whenever a module is loaded.

Definition at line 104 of file Utils.h.

Constructor & Destructor Documentation

◆ DependencyFileGenerator()

DependencyFileGenerator::DependencyFileGenerator ( const DependencyOutputOptions Opts)

Member Function Documentation

◆ attachToPreprocessor()

void DependencyFileGenerator::attachToPreprocessor ( Preprocessor PP)
overridevirtual

◆ finishedMainFile()

void DependencyFileGenerator::finishedMainFile ( DiagnosticsEngine Diags)
overridevirtual

Called when the end of the main file is reached.

Reimplemented from clang::DependencyCollector.

Definition at line 263 of file DependencyFile.cpp.

References outputDependencyFile().

◆ needSystemDependencies()

bool clang::DependencyFileGenerator::needSystemDependencies ( )
inlinefinalvirtual

Return true if system files should be passed to sawDependency().

Reimplemented from clang::DependencyCollector.

Definition at line 112 of file Utils.h.

◆ outputDependencyFile()

void DependencyFileGenerator::outputDependencyFile ( llvm::raw_ostream &  OS)
protected

◆ sawDependency()

bool DependencyFileGenerator::sawDependency ( StringRef  Filename,
bool  FromModule,
bool  IsSystem,
bool  IsModuleFile,
bool  IsMissing 
)
finalvirtual

Called when a new file is seen.

Return true if Filename should be added to the list of dependencies.

The default implementation ignores <built-in> and system files.

Reimplemented from clang::DependencyCollector.

Definition at line 241 of file DependencyFile.cpp.

References Filename, and isSpecialFilename().


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