================
@@ -111,19 +111,105 @@ class DependencyScanningTool {
const llvm::DenseSet<dependencies::ModuleID> &AlreadySeen,
dependencies::LookupModuleOutputCallback LookupModuleOutput);
- /// The following two methods provide a new interface to perform
- /// by name dependency scan. The new interface's intention is to improve
- /// dependency scanning performance when a sequence of name is looked up
- /// with the same current working directory and the command line.
+ llvm::vfs::FileSystem &getWorkerVFS() const { return Worker.getVFS(); }
+
+private:
+ dependencies::DependencyScanningWorker Worker;
+
+ friend class CompilerInstanceWithContext;
+};
+
+/// Run the dependency scanning worker for the given driver or frontend
+/// command-line, and report the discovered dependencies to the provided
+/// consumer.
+///
+/// OverlayFS should be based on the Worker's dependency scanning file-system
+/// and can be used to provide any input specified on the command-line as
+/// in-memory file. If no overlay file-system is provided, the Worker's
+/// dependency scanning file-system is used instead.
+///
+/// \returns false if any errors occurred (with diagnostics reported to
+/// \c DiagConsumer), true otherwise.
+bool computeDependencies(
+ dependencies::DependencyScanningWorker &Worker, StringRef WorkingDirectory,
+ ArrayRef<std::string> CommandLine,
+ dependencies::DependencyConsumer &Consumer,
+ dependencies::DependencyActionController &Controller,
+ DiagnosticConsumer &DiagConsumer,
+ llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS =
nullptr);
+
+class CompilerInstanceWithContext {
+ // Context
+ dependencies::DependencyScanningWorker &Worker;
+ llvm::StringRef CWD;
+ std::vector<std::string> CommandLine;
+
+ // Context - Diagnostics engine.
+ DiagnosticConsumer *DiagConsumer = nullptr;
+ std::unique_ptr<dependencies::DiagnosticsEngineWithDiagOpts>
+ DiagEngineWithCmdAndOpts;
+ std::unique_ptr<dependencies::TextDiagnosticsPrinterWithOutput>
+ DiagPrinterWithOS;
+
+ // Context - compiler invocation
+ std::unique_ptr<CompilerInvocation> OriginalInvocation;
+
+ // Context - output options
+ std::unique_ptr<DependencyOutputOptions> OutputOpts;
+
+ // Context - stable directory handling
+ llvm::SmallVector<StringRef> StableDirs;
+ dependencies::PrebuiltModulesAttrsMap PrebuiltModuleASTMap;
+
+ // Compiler Instance
+ std::unique_ptr<CompilerInstance> CIPtr;
+
+ // Source location offset.
+ int32_t SrcLocOffset = 0;
+
+ CompilerInstanceWithContext(dependencies::DependencyScanningWorker &Worker,
+ StringRef CWD, ArrayRef<std::string> CommandLine)
+ : Worker(Worker), CWD(CWD), CommandLine(std::move(CommandLine)) {};
----------------
naveen-seth wrote:
Sounds good. thanks!
https://github.com/llvm/llvm-project/pull/184376
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits