|
clang 22.0.0git
|
The high-level implementation of the dependency discovery tool that runs on an individual worker thread. More...
#include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
Public Member Functions | |
| DependencyScanningTool (DependencyScanningService &Service, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS=llvm::vfs::createPhysicalFileSystem()) | |
| Construct a dependency scanning tool. | |
| llvm::Expected< std::string > | getDependencyFile (const std::vector< std::string > &CommandLine, StringRef CWD) |
| Print out the dependency information into a string using the dependency file format that is specified in the options (-MD is the default) and return it. | |
| llvm::Expected< P1689Rule > | getP1689ModuleDependencyFile (const clang::tooling::CompileCommand &Command, StringRef CWD, std::string &MakeformatOutput, std::string &MakeformatOutputPath) |
| Collect the module dependency in P1689 format for C++20 named modules. | |
| llvm::Expected< P1689Rule > | getP1689ModuleDependencyFile (const clang::tooling::CompileCommand &Command, StringRef CWD) |
| llvm::Expected< TranslationUnitDeps > | getTranslationUnitDependencies (const std::vector< std::string > &CommandLine, StringRef CWD, const llvm::DenseSet< ModuleID > &AlreadySeen, LookupModuleOutputCallback LookupModuleOutput, std::optional< llvm::MemoryBufferRef > TUBuffer=std::nullopt) |
| Given a Clang driver command-line for a translation unit, gather the modular dependencies and return the information needed for explicit build. | |
| llvm::Expected< TranslationUnitDeps > | getModuleDependencies (StringRef ModuleName, const std::vector< std::string > &CommandLine, StringRef CWD, const llvm::DenseSet< ModuleID > &AlreadySeen, LookupModuleOutputCallback LookupModuleOutput) |
| Given a compilation context specified via the Clang driver command-line, gather modular dependencies of module with the given name, and return the information needed for explicit build. | |
| llvm::Error | initializeCompilerInstanceWithContext (StringRef CWD, const std::vector< std::string > &CommandLine) |
| The following three methods provide a new interface to perform by name dependency scan. | |
| llvm::Expected< TranslationUnitDeps > | computeDependenciesByNameWithContext (StringRef ModuleName, const llvm::DenseSet< ModuleID > &AlreadySeen, LookupModuleOutputCallback LookupModuleOutput) |
| Computes the dependeny for the module named ModuleName. | |
| llvm::Error | finalizeCompilerInstanceWithContext () |
| This method finializes the compiler instance. | |
| llvm::vfs::FileSystem & | getWorkerVFS () const |
The high-level implementation of the dependency discovery tool that runs on an individual worker thread.
Definition at line 87 of file DependencyScanningTool.h.
| DependencyScanningTool::DependencyScanningTool | ( | DependencyScanningService & | Service, |
| llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > | FS = llvm::vfs::createPhysicalFileSystem() ) |
Construct a dependency scanning tool.
| Service | The parent service. Must outlive the tool. |
| FS | The filesystem for the tool to use. Defaults to the physical FS. |
Definition at line 17 of file DependencyScanningTool.cpp.
| llvm::Expected< TranslationUnitDeps > DependencyScanningTool::computeDependenciesByNameWithContext | ( | StringRef | ModuleName, |
| const llvm::DenseSet< ModuleID > & | AlreadySeen, | ||
| LookupModuleOutputCallback | LookupModuleOutput ) |
Computes the dependeny for the module named ModuleName.
| ModuleName | The name of the module for which this method computes . dependencies. |
| AlreadySeen | This stores modules which have previously been reported. Use the same instance for all calls to this function for a single DependencyScanningTool in a single build. Note that this parameter is not part of the context because it can be shared across different worker threads and each worker thread may update it. |
| LookupModuleOutput | This function is called to fill in "-fmodule-file=", "-o" and other output arguments for dependencies. |
TranslationUnitDeps if the scan is successful. Otherwise it returns an error. Definition at line 187 of file DependencyScanningTool.cpp.
References clang::Result, and clang::tooling::dependencies::FullDependencyConsumer::takeTranslationUnitDeps().
| llvm::Error DependencyScanningTool::finalizeCompilerInstanceWithContext | ( | ) |
This method finializes the compiler instance.
It finalizes the diagnostics and deletes the compiler instance. Call this method once all names for a same commandline are scanned.
Definition at line 200 of file DependencyScanningTool.cpp.
| llvm::Expected< std::string > DependencyScanningTool::getDependencyFile | ( | const std::vector< std::string > & | CommandLine, |
| StringRef | CWD ) |
Print out the dependency information into a string using the dependency file format that is specified in the options (-MD is the default) and return it.
StringError with the diagnostic output if clang errors occurred, dependency file contents otherwise. Definition at line 74 of file DependencyScanningTool.cpp.
References clang::Result.
| llvm::Expected< TranslationUnitDeps > DependencyScanningTool::getModuleDependencies | ( | StringRef | ModuleName, |
| const std::vector< std::string > & | CommandLine, | ||
| StringRef | CWD, | ||
| const llvm::DenseSet< ModuleID > & | AlreadySeen, | ||
| LookupModuleOutputCallback | LookupModuleOutput ) |
Given a compilation context specified via the Clang driver command-line, gather modular dependencies of module with the given name, and return the information needed for explicit build.
TODO: this method should be removed as soon as Swift and our C-APIs adopt CompilerInstanceWithContext. We are keeping it here so that it is easier to coordinate with Swift and C-API changes.
Definition at line 159 of file DependencyScanningTool.cpp.
References clang::Error, clang::Result, and clang::tooling::dependencies::FullDependencyConsumer::takeTranslationUnitDeps().
|
inline |
Definition at line 122 of file DependencyScanningTool.h.
References getP1689ModuleDependencyFile().
| llvm::Expected< P1689Rule > DependencyScanningTool::getP1689ModuleDependencyFile | ( | const clang::tooling::CompileCommand & | Command, |
| StringRef | CWD, | ||
| std::string & | MakeformatOutput, | ||
| std::string & | MakeformatOutputPath ) |
Collect the module dependency in P1689 format for C++20 named modules.
| MakeformatOutput | The output parameter for dependency information in make format if the command line requires to generate make-format dependency information by -MD -MF <dep_file>. |
| MakeformatOutputPath | The output parameter for the path to |
| MakeformatOutput. |
StringError with the diagnostic output if clang errors occurred, P1689 dependency format rules otherwise. Definition at line 87 of file DependencyScanningTool.cpp.
References clang::Make, and clang::Result.
Referenced by getP1689ModuleDependencyFile().
| llvm::Expected< TranslationUnitDeps > DependencyScanningTool::getTranslationUnitDependencies | ( | const std::vector< std::string > & | CommandLine, |
| StringRef | CWD, | ||
| const llvm::DenseSet< ModuleID > & | AlreadySeen, | ||
| LookupModuleOutputCallback | LookupModuleOutput, | ||
| std::optional< llvm::MemoryBufferRef > | TUBuffer = std::nullopt ) |
Given a Clang driver command-line for a translation unit, gather the modular dependencies and return the information needed for explicit build.
| AlreadySeen | This stores modules which have previously been reported. Use the same instance for all calls to this function for a single DependencyScanningTool in a single build. Use a different one for different tools, and clear it between builds. |
| LookupModuleOutput | This function is called to fill in "-fmodule-file=", "-o" and other output arguments for dependencies. |
| TUBuffer | Optional memory buffer for translation unit input. If TUBuffer is nullopt, the input should be included in the Commandline already. |
StringError with the diagnostic output if clang errors occurred, TranslationUnitDeps otherwise. Definition at line 143 of file DependencyScanningTool.cpp.
References clang::Result, and clang::tooling::dependencies::FullDependencyConsumer::takeTranslationUnitDeps().
|
inline |
Definition at line 203 of file DependencyScanningTool.h.
| llvm::Error DependencyScanningTool::initializeCompilerInstanceWithContext | ( | StringRef | CWD, |
| const std::vector< std::string > & | CommandLine ) |
The following three methods provide a new interface to perform by name dependency scan.
The new interface's intention is to improve dependency scanning performance when a sequence of name is looked up with the same current working directory and the command line.
Initializing the context and the compiler instance. This method must be called before calling computeDependenciesByNameWithContext.
| CWD | The current working directory used during the scan. |
| CommandLine | The commandline used for the scan. |
Definition at line 181 of file DependencyScanningTool.cpp.