clang  10.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"
20 #include "llvm/Support/Error.h"
21 #include "llvm/Support/FileSystem.h"
22 #include <string>
23 
24 namespace clang {
25 
26 class DependencyOutputOptions;
27 
28 namespace tooling {
29 namespace dependencies {
30 
31 class DependencyScanningWorkerFilesystem;
32 
34 public:
35  virtual ~DependencyConsumer() {}
36 
37  virtual void handleFileDependency(const DependencyOutputOptions &Opts,
38  StringRef Filename) = 0;
39 
40  virtual void handleModuleDependency(ModuleDeps MD) = 0;
41 
42  virtual void handleContextHash(std::string Hash) = 0;
43 };
44 
45 /// An individual dependency scanning worker that is able to run on its own
46 /// thread.
47 ///
48 /// The worker computes the dependencies for the input files by preprocessing
49 /// sources either using a fast mode where the source files are minimized, or
50 /// using the regular processing run.
52 public:
54 
55  /// Run the dependency scanning tool for a given clang driver invocation (as
56  /// specified for the given Input in the CDB), and report the discovered
57  /// dependencies to the provided consumer.
58  ///
59  /// \returns A \c StringError with the diagnostic output if clang errors
60  /// occurred, success otherwise.
61  llvm::Error computeDependencies(const std::string &Input,
62  StringRef WorkingDirectory,
63  const CompilationDatabase &CDB,
64  DependencyConsumer &Consumer);
65 
66 private:
68  std::shared_ptr<PCHContainerOperations> PCHContainerOps;
69  std::unique_ptr<ExcludedPreprocessorDirectiveSkipMapping> PPSkipMappings;
70 
72  /// The file system that is used by each worker when scanning for
73  /// dependencies. This filesystem persists accross multiple compiler
74  /// invocations.
76  /// The file manager that is reused accross multiple invocations by this
77  /// worker. If null, the file manager will not be reused.
79  ScanningOutputFormat Format;
80 };
81 
82 } // end namespace dependencies
83 } // end namespace tooling
84 } // end namespace clang
85 
86 #endif // LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_WORKER_H
Defines the clang::FileManager interface and associated types.
The dependency scanning service contains the shared state that is used by the invidual dependency sca...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
virtual void handleModuleDependency(ModuleDeps MD)=0
StringRef Filename
Definition: Format.cpp:1825
Interface for compilation databases.
DependencyOutputOptions - Options for controlling the compiler dependency file generation.
An individual dependency scanning worker that is able to run on its own thread.
Dataflow Directional Tag Classes.
virtual void handleContextHash(std::string Hash)=0
ScanningOutputFormat
The format that is output by the dependency scanner.
virtual void handleFileDependency(const DependencyOutputOptions &Opts, StringRef Filename)=0