================
@@ -125,16 +116,33 @@ class DependencyScanningWorker {
       DependencyConsumer &Consumer, DependencyActionController &Controller,
       std::optional<llvm::MemoryBufferRef> TUBuffer = std::nullopt);
 
-  /// Run the dependency scanning tool for a given clang driver command-line
-  /// for a specific module.
-  ///
-  /// \returns A \c StringError with the diagnostic output if clang errors
-  /// occurred, success otherwise.
-  llvm::Error computeDependencies(StringRef WorkingDirectory,
-                                  const std::vector<std::string> &CommandLine,
-                                  DependencyConsumer &Consumer,
-                                  DependencyActionController &Controller,
-                                  StringRef ModuleName);
+  /// The three method below implements a new interface for by name
+  /// dependency scanning. They together enable the dependency scanning worker
+  /// to more effectively perform scanning for a sequence of modules
+  /// by name when the CWD and CommandLine do not change across the queries.
+
+  /// @brief Initializing the context and the compiler instance.
+  /// @param CWD The current working directory used during the scan.
+  /// @param CommandLine The commandline used for the scan.
+  /// @return Error if the initializaiton fails.
+  llvm::Error initializeCompilerInstanceWithContext(
----------------
qiongsiwu wrote:

I took a closer look at this, and realize that it probably makes more sense to 
return `llvm::Error` for these particular APIs. The reason has to do with 
Swift. 

The initialization/query/finalize C++ APIs are intended to be called by Swift 
directly. For example, we intend to call the new 
`computeDependenciesByNameWithContext` 
[method](https://github.com/llvm/llvm-project/pull/164345/files#diff-144204c8f165a4edb783303bab89861e92fd798fd8da1b20fd837c8d09c01bd0R182)
 
[here](https://github.com/swiftlang/swift/blob/57cf4ce563f700bba42d89259f269692c35e47bb/lib/DependencyScan/ModuleDependencyScanner.cpp#L322)
 in Swift. It seems that Swift has its own diagnostics system, and its own 
[consumer 
type](https://github.com/swiftlang/swift/blob/d322b9e919d81b49f8d330076451f4268f7fdd6f/include/swift/AST/DiagnosticConsumer.h#L97).
 It does not seem easy to feed the consumer directly to the API. 

That said, maybe we can make some adapting changes on the Swift side so we 
_can_ feed the diagnostics consumer to our API? I can make these changes in 
followup PRs. 

https://github.com/llvm/llvm-project/pull/164345
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to