Coverage Report

Created: 2021-06-15 06:44

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
Line
Count
Source
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
12
#include "clang/Basic/DiagnosticOptions.h"
13
#include "clang/Basic/FileManager.h"
14
#include "clang/Basic/LLVM.h"
15
#include "clang/Frontend/PCHContainerOperations.h"
16
#include "clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h"
17
#include "clang/Tooling/CompilationDatabase.h"
18
#include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
19
#include "clang/Tooling/DependencyScanning/ModuleDepCollector.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
33
class DependencyConsumer {
34
public:
35
154
  virtual ~DependencyConsumer() {}
36
37
  virtual void
38
  handleDependencyOutputOpts(const DependencyOutputOptions &Opts) = 0;
39
40
  virtual void handleFileDependency(StringRef Filename) = 0;
41
42
  virtual void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD) = 0;
43
44
  virtual void handleModuleDependency(ModuleDeps MD) = 0;
45
46
  virtual void handleContextHash(std::string Hash) = 0;
47
};
48
49
/// An individual dependency scanning worker that is able to run on its own
50
/// thread.
51
///
52
/// The worker computes the dependencies for the input files by preprocessing
53
/// sources either using a fast mode where the source files are minimized, or
54
/// using the regular processing run.
55
class DependencyScanningWorker {
56
public:
57
  DependencyScanningWorker(DependencyScanningService &Service);
58
59
  /// Run the dependency scanning tool for a given clang driver invocation (as
60
  /// specified for the given Input in the CDB), and report the discovered
61
  /// dependencies to the provided consumer.
62
  ///
63
  /// \returns A \c StringError with the diagnostic output if clang errors
64
  /// occurred, success otherwise.
65
  llvm::Error computeDependencies(const std::string &Input,
66
                                  StringRef WorkingDirectory,
67
                                  const CompilationDatabase &CDB,
68
                                  DependencyConsumer &Consumer);
69
70
private:
71
  IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
72
  std::shared_ptr<PCHContainerOperations> PCHContainerOps;
73
  std::unique_ptr<ExcludedPreprocessorDirectiveSkipMapping> PPSkipMappings;
74
75
  llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> RealFS;
76
  /// The file system that is used by each worker when scanning for
77
  /// dependencies. This filesystem persists accross multiple compiler
78
  /// invocations.
79
  llvm::IntrusiveRefCntPtr<DependencyScanningWorkerFilesystem> DepFS;
80
  /// The file manager that is reused accross multiple invocations by this
81
  /// worker. If null, the file manager will not be reused.
82
  llvm::IntrusiveRefCntPtr<FileManager> Files;
83
  ScanningOutputFormat Format;
84
};
85
86
} // end namespace dependencies
87
} // end namespace tooling
88
} // end namespace clang
89
90
#endif // LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_WORKER_H