clang 24.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
15#include "clang/Basic/LLVM.h"
20#include "llvm/ADT/IntrusiveRefCntPtr.h"
21#include "llvm/Support/FileSystem.h"
22#include "llvm/Support/MemoryBufferRef.h"
23#include "llvm/Support/VirtualFileSystem.h"
24#include <optional>
25#include <string>
26
27namespace clang {
28
30
31namespace tooling {
33}
34
35namespace dependencies {
36
37class DependencyConsumer;
38class DependencyScanningWorkerFilesystem;
39
40/// An individual dependency scanning worker that is able to run on its own
41/// thread.
42///
43/// The worker computes the dependencies for the input files by preprocessing
44/// sources either using a fast mode where the source files are minimized, or
45/// using the regular processing run.
47public:
48 /// Construct a dependency scanning worker.
49 ///
50 /// @param Service The parent service. Must outlive the worker.
52
54
55 /// Run the dependency scanning tool for all given frontend command-lines,
56 /// and report the discovered dependencies to the provided consumer. The
57 /// \c OverlayFS will be used to call \c makeEffectiveVFS().
58 ///
59 /// \returns false if any errors occurred (with diagnostics reported to
60 /// \c DiagConsumer), true otherwise.
62 StringRef WorkingDirectory, ArrayRef<ArrayRef<std::string>> CommandLines,
63 DependencyConsumer &DepConsumer, DependencyActionController &Controller,
64 DiagnosticConsumer &DiagConsumer,
66
67 /// Creates the effective VFS that will be used for the scan.
68 ///
69 /// If provided, OverlayFS will be overlaid on top of the Worker's dependency
70 /// scanning file-system and can be used to provide any input specified on the
71 /// command-line as in-memory file. If no overlay file-system is provided, the
72 /// Worker's dependency scanning file-system is used directly.
74 StringRef WorkingDirectory,
75 IntrusiveRefCntPtr<llvm::vfs::FileSystem> OverlayFS = nullptr) const;
76
77 /// Returns the worker tracing VFS, if it was requested via the service.
78 llvm::vfs::TracingFileSystem *getTracingVFS() const {
79 return TracingFS.get();
80 }
81
82private:
83 /// The parent dependency scanning service.
85 std::shared_ptr<PCHContainerOperations> PCHContainerOps;
86 /// This is the caching (and optionally dependency-directives-providing) VFS
87 /// overlaid on top of the base VFS.
89 /// The tracing VFS overlaid on top of the base VFS.
91
93};
94} // end namespace dependencies
95} // end namespace clang
96
97#endif // LLVM_CLANG_DEPENDENCYSCANNING_DEPENDENCYSCANNINGWORKER_H
Defines a logger where each line is written atomically to the file.
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.