[clang] [clang][deps] Add `-o` flag to specify output path (PR #88767)

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 15 11:03:10 PDT 2024


================
@@ -864,8 +873,24 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) {
       });
 
   SharedStream Errs(llvm::errs());
-  // Print out the dependency results to STDOUT by default.
-  SharedStream DependencyOS(llvm::outs());
+
+  std::optional<llvm::raw_fd_ostream> FileOS;
+  llvm::raw_ostream &ThreadUnsafeDependencyOS = [&]() -> llvm::raw_ostream & {
+    if (OutputFileName == "-")
+      return llvm::outs();
----------------
benlangmuir wrote:

I don't feel strongly about whether you should change this code or not -- maybe it's clearer the way it is? -- but `raw_fd_ostream("-", EC)` is going to be the same as `outs()` anyway.

https://github.com/llvm/llvm-project/pull/88767


More information about the cfe-commits mailing list