clang 23.0.0git
DependencyScanningWorker.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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_DEPENDENCYSCANNING_DEPENDENCYSCANNINGWORKER_H
10#define LLVM_CLANG_DEPENDENCYSCANNING_DEPENDENCYSCANNINGWORKER_H
11
14#include "clang/Basic/LLVM.h"
19#include "llvm/ADT/IntrusiveRefCntPtr.h"
20#include "llvm/Support/FileSystem.h"
21#include "llvm/Support/MemoryBufferRef.h"
22#include "llvm/Support/VirtualFileSystem.h"
23#include <optional>
24#include <string>
25
26namespace clang {
27
29
30namespace tooling {
32}
33
34namespace dependencies {
35
36class DependencyConsumer;
37class DependencyScanningWorkerFilesystem;
38
39/// An individual dependency scanning worker that is able to run on its own
40/// thread.
41///
42/// The worker computes the dependencies for the input files by preprocessing
43/// sources either using a fast mode where the source files are minimized, or
44/// using the regular processing run.
46public:
47 /// Construct a dependency scanning worker.
48 ///
49 /// @param Service The parent service. Must outlive the worker.
51
53
54 /// Run the dependency scanning tool for all given frontend command-lines,
55 /// and report the discovered dependencies to the provided consumer. The
56 /// \c OverlayFS will be used to call \c makeEffectiveVFS().
57 ///
58 /// \returns false if any errors occurred (with diagnostics reported to
59 /// \c DiagConsumer), true otherwise.
61 StringRef WorkingDirectory, ArrayRef<ArrayRef<std::string>> CommandLines,
62 DependencyConsumer &DepConsumer, DependencyActionController &Controller,
63 DiagnosticConsumer &DiagConsumer,
65
66 /// Creates the effective VFS that will be used for the scan.
67 ///
68 /// If provided, OverlayFS will be overlaid on top of the Worker's dependency
69 /// scanning file-system and can be used to provide any input specified on the
70 /// command-line as in-memory file. If no overlay file-system is provided, the
71 /// Worker's dependency scanning file-system is used directly.
73 StringRef WorkingDirectory,
74 IntrusiveRefCntPtr<llvm::vfs::FileSystem> OverlayFS = nullptr) const;
75
76 /// Returns the worker tracing VFS, if it was requested via the service.
77 llvm::vfs::TracingFileSystem *getTracingVFS() const {
78 return TracingFS.get();
79 }
80
81private:
82 /// The parent dependency scanning service.
84 std::shared_ptr<PCHContainerOperations> PCHContainerOps;
85 /// This is the caching (and optionally dependency-directives-providing) VFS
86 /// overlaid on top of the base VFS.
88 /// The tracing VFS overlaid on top of the base VFS.
90
92};
93} // end namespace dependencies
94} // end namespace clang
95
96#endif // LLVM_CLANG_DEPENDENCYSCANNING_DEPENDENCYSCANNINGWORKER_H
Defines the clang::FileManager interface and associated types.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
DependencyOutputOptions - Options for controlling the compiler dependency file generation.
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
Dependency scanner callbacks that are used during scanning to influence the behaviour of the scan - f...
The dependency scanning service contains shared configuration and state that is used by the individua...
DependencyScanningWorker(DependencyScanningService &Service)
Construct a dependency scanning worker.
llvm::vfs::TracingFileSystem * getTracingVFS() const
Returns the worker tracing VFS, if it was requested via the service.
bool computeDependencies(StringRef WorkingDirectory, ArrayRef< ArrayRef< std::string > > CommandLines, DependencyConsumer &DepConsumer, DependencyActionController &Controller, DiagnosticConsumer &DiagConsumer, IntrusiveRefCntPtr< llvm::vfs::FileSystem > OverlayFS=nullptr)
Run the dependency scanning tool for all given frontend command-lines, and report the discovered depe...
IntrusiveRefCntPtr< llvm::vfs::FileSystem > makeEffectiveVFS(StringRef WorkingDirectory, IntrusiveRefCntPtr< llvm::vfs::FileSystem > OverlayFS=nullptr) const
Creates the effective VFS that will be used for the scan.
The JSON file list parser is used to communicate input to InstallAPI.