clang  14.0.0git
DependencyScanningWorker.h
Go to the documentation of this file.
1 //===- DependencyScanningWorker.h - clang-scan-deps worker ===---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_WORKER_H
10 #define LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_WORKER_H
11 
14 #include "clang/Basic/LLVM.h"
19 #include "llvm/Support/Error.h"
20 #include "llvm/Support/FileSystem.h"
21 #include <string>
22 
23 namespace clang {
24 
25 class DependencyOutputOptions;
26 
27 namespace tooling {
28 namespace dependencies {
29 
30 class DependencyScanningWorkerFilesystem;
31 
33 public:
34  virtual ~DependencyConsumer() {}
35 
36  virtual void
38 
39  virtual void handleFileDependency(StringRef Filename) = 0;
40 
42 
43  virtual void handleModuleDependency(ModuleDeps MD) = 0;
44 
45  virtual void handleContextHash(std::string Hash) = 0;
46 };
47 
48 /// An individual dependency scanning worker that is able to run on its own
49 /// thread.
50 ///
51 /// The worker computes the dependencies for the input files by preprocessing
52 /// sources either using a fast mode where the source files are minimized, or
53 /// using the regular processing run.
55 public:
57 
58  /// Run the dependency scanning tool for a given clang driver command-line,
59  /// and report the discovered dependencies to the provided consumer. If \p
60  /// ModuleName isn't empty, this function reports the dependencies of module
61  /// \p ModuleName.
62  ///
63  /// \returns A \c StringError with the diagnostic output if clang errors
64  /// occurred, success otherwise.
65  llvm::Error computeDependencies(StringRef WorkingDirectory,
66  const std::vector<std::string> &CommandLine,
67  DependencyConsumer &Consumer,
68  llvm::Optional<StringRef> ModuleName = None);
69 
70 private:
71  std::shared_ptr<PCHContainerOperations> PCHContainerOps;
72  std::unique_ptr<ExcludedPreprocessorDirectiveSkipMapping> PPSkipMappings;
73 
74  /// The physical filesystem overlaid by `InMemoryFS`.
76  /// The in-memory filesystem laid on top the physical filesystem in `RealFS`.
78  /// The file system that is used by each worker when scanning for
79  /// dependencies. This filesystem persists across multiple compiler
80  /// invocations.
82  /// The file manager that is reused across multiple invocations by this
83  /// worker. If null, the file manager will not be reused.
85  ScanningOutputFormat Format;
86  /// Whether to optimize the modules' command-line arguments.
87  bool OptimizeArgs;
88 };
89 
90 } // end namespace dependencies
91 } // end namespace tooling
92 } // end namespace clang
93 
94 #endif // LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_WORKER_H
DependencyScanningService.h
clang::DependencyOutputOptions
DependencyOutputOptions - Options for controlling the compiler dependency file generation.
Definition: DependencyOutputOptions.h:33
clang::tooling::dependencies::DependencyConsumer::handlePrebuiltModuleDependency
virtual void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD)=0
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::tooling::dependencies::DependencyConsumer
Definition: DependencyScanningWorker.h:32
Filename
StringRef Filename
Definition: Format.cpp:2379
clang::tooling::dependencies::DependencyConsumer::handleModuleDependency
virtual void handleModuleDependency(ModuleDeps MD)=0
llvm::Optional
Definition: LLVM.h:40
clang::tooling::dependencies::DependencyConsumer::~DependencyConsumer
virtual ~DependencyConsumer()
Definition: DependencyScanningWorker.h:34
clang::tooling::dependencies::ScanningOutputFormat
ScanningOutputFormat
The format that is output by the dependency scanner.
Definition: DependencyScanningService.h:34
clang::tooling::dependencies::PrebuiltModuleDep
Modular dependency that has already been built prior to the dependency scan.
Definition: ModuleDepCollector.h:32
PreprocessorExcludedConditionalDirectiveSkipMapping.h
clang::tooling::dependencies::DependencyScanningWorker::computeDependencies
llvm::Error computeDependencies(StringRef WorkingDirectory, const std::vector< std::string > &CommandLine, DependencyConsumer &Consumer, llvm::Optional< StringRef > ModuleName=None)
Run the dependency scanning tool for a given clang driver command-line, and report the discovered dep...
Definition: DependencyScanningWorker.cpp:329
clang::tooling::dependencies::DependencyScanningWorker::DependencyScanningWorker
DependencyScanningWorker(DependencyScanningService &Service)
Definition: DependencyScanningWorker.cpp:284
ModuleDepCollector.h
clang::tooling::dependencies::DependencyScanningWorker
An individual dependency scanning worker that is able to run on its own thread.
Definition: DependencyScanningWorker.h:54
clang::tooling::dependencies::ModuleDeps
Definition: ModuleDepCollector.h:68
LLVM.h
clang::tooling::dependencies::DependencyScanningService
The dependency scanning service contains the shared state that is used by the invidual dependency sca...
Definition: DependencyScanningService.h:47
PCHContainerOperations.h
clang
Definition: CalledOnceCheck.h:17
clang::tooling::dependencies::DependencyConsumer::handleContextHash
virtual void handleContextHash(std::string Hash)=0
DiagnosticOptions.h
FileManager.h
clang::tooling::dependencies::DependencyConsumer::handleFileDependency
virtual void handleFileDependency(StringRef Filename)=0
clang::tooling::dependencies::DependencyConsumer::handleDependencyOutputOpts
virtual void handleDependencyOutputOpts(const DependencyOutputOptions &Opts)=0
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem >