aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h')
-rw-r--r--contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h84
1 files changed, 61 insertions, 23 deletions
diff --git a/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h b/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
index 5903ad13c1d8..0f607862194b 100644
--- a/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
+++ b/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
@@ -6,19 +6,18 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_WORKER_H
-#define LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_WORKER_H
+#ifndef LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGWORKER_H
+#define LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGWORKER_H
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/LLVM.h"
#include "clang/Frontend/PCHContainerOperations.h"
-#include "clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h"
-#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
#include "clang/Tooling/DependencyScanning/ModuleDepCollector.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
+#include <optional>
#include <string>
namespace clang {
@@ -30,10 +29,24 @@ namespace dependencies {
class DependencyScanningWorkerFilesystem;
+/// A command-line tool invocation that is part of building a TU.
+///
+/// \see TranslationUnitDeps::Commands.
+struct Command {
+ std::string Executable;
+ std::vector<std::string> Arguments;
+};
+
class DependencyConsumer {
public:
virtual ~DependencyConsumer() {}
+ virtual void handleProvidedAndRequiredStdCXXModules(
+ std::optional<P1689ModuleInfo> Provided,
+ std::vector<P1689ModuleInfo> Requires) {}
+
+ virtual void handleBuildCommand(Command Cmd) {}
+
virtual void
handleDependencyOutputOpts(const DependencyOutputOptions &Opts) = 0;
@@ -43,9 +56,21 @@ public:
virtual void handleModuleDependency(ModuleDeps MD) = 0;
+ virtual void handleDirectModuleDependency(ModuleID MD) = 0;
+
virtual void handleContextHash(std::string Hash) = 0;
};
+/// Dependency scanner callbacks that are used during scanning to influence the
+/// behaviour of the scan - for example, to customize the scanned invocations.
+class DependencyActionController {
+public:
+ virtual ~DependencyActionController();
+
+ virtual std::string lookupModuleOutput(const ModuleID &ID,
+ ModuleOutputKind Kind) = 0;
+};
+
/// An individual dependency scanning worker that is able to run on its own
/// thread.
///
@@ -54,37 +79,50 @@ public:
/// using the regular processing run.
class DependencyScanningWorker {
public:
- DependencyScanningWorker(DependencyScanningService &Service);
+ DependencyScanningWorker(DependencyScanningService &Service,
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS);
- /// Run the dependency scanning tool for a given clang driver invocation (as
- /// specified for the given Input in the CDB), and report the discovered
- /// dependencies to the provided consumer.
+ /// Run the dependency scanning tool for a given clang driver command-line,
+ /// and report the discovered dependencies to the provided consumer. If \p
+ /// ModuleName isn't empty, this function reports the dependencies of module
+ /// \p ModuleName.
///
+ /// \returns false if clang errors occurred (with diagnostics reported to
+ /// \c DiagConsumer), true otherwise.
+ bool computeDependencies(StringRef WorkingDirectory,
+ const std::vector<std::string> &CommandLine,
+ DependencyConsumer &DepConsumer,
+ DependencyActionController &Controller,
+ DiagnosticConsumer &DiagConsumer,
+ std::optional<StringRef> ModuleName = std::nullopt);
/// \returns A \c StringError with the diagnostic output if clang errors
/// occurred, success otherwise.
- llvm::Error computeDependencies(const std::string &Input,
- StringRef WorkingDirectory,
- const CompilationDatabase &CDB,
- DependencyConsumer &Consumer);
+ llvm::Error computeDependencies(
+ StringRef WorkingDirectory, const std::vector<std::string> &CommandLine,
+ DependencyConsumer &Consumer, DependencyActionController &Controller,
+ std::optional<StringRef> ModuleName = std::nullopt);
+
+ bool shouldEagerLoadModules() const { return EagerLoadModules; }
private:
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
std::shared_ptr<PCHContainerOperations> PCHContainerOps;
- std::unique_ptr<ExcludedPreprocessorDirectiveSkipMapping> PPSkipMappings;
-
- llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> RealFS;
- /// The file system that is used by each worker when scanning for
- /// dependencies. This filesystem persists accross multiple compiler
- /// invocations.
+ /// The file system to be used during the scan.
+ /// This is either \c FS passed in the constructor (when performing canonical
+ /// preprocessing), or \c DepFS (when performing dependency directives scan).
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS;
+ /// When performing dependency directives scan, this is the caching (and
+ /// dependency-directives-extracting) filesystem overlaid on top of \c FS
+ /// (passed in the constructor).
llvm::IntrusiveRefCntPtr<DependencyScanningWorkerFilesystem> DepFS;
- /// The file manager that is reused accross multiple invocations by this
- /// worker. If null, the file manager will not be reused.
- llvm::IntrusiveRefCntPtr<FileManager> Files;
ScanningOutputFormat Format;
+ /// Whether to optimize the modules' command-line arguments.
+ ScanningOptimizations OptimizeArgs;
+ /// Whether to set up command-lines to load PCM files eagerly.
+ bool EagerLoadModules;
};
} // end namespace dependencies
} // end namespace tooling
} // end namespace clang
-#endif // LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_WORKER_H
+#endif // LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGWORKER_H