================
@@ -74,13 +79,131 @@ class MakeDependencyPrinterConsumer : public
DependencyConsumer {
};
} // anonymous namespace
+static std::pair<std::unique_ptr<driver::Driver>,
+ std::unique_ptr<driver::Compilation>>
+buildCompilation(ArrayRef<std::string> CommandLine, DiagnosticsEngine &Diags,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
+ llvm::BumpPtrAllocator &Alloc) {
+ auto Argv = llvm::map_to_vector<256>(
+ CommandLine, [](const auto &Arg) { return Arg.c_str(); });
+
+ std::unique_ptr<driver::Driver> Driver = std::make_unique<driver::Driver>(
+ Argv[0], llvm::sys::getDefaultTargetTriple(), Diags,
+ "clang LLVM compiler", FS);
+ Driver->setTitle("clang_based_tool");
+
+ bool CLMode = driver::IsClangCL(
+ driver::getDriverMode(Argv[0], ArrayRef(Argv).slice(1)));
+
+ if (llvm::Error E =
+ driver::expandResponseFiles(Argv, CLMode, Alloc, FS.get())) {
+ Diags.Report(diag::err_drv_expand_response_file)
+ << llvm::toString(std::move(E));
+ return std::make_pair(nullptr, nullptr);
+ }
+
+ std::unique_ptr<driver::Compilation> Compilation(
+ Driver->BuildCompilation(Argv));
+ if (!Compilation)
+ return std::make_pair(nullptr, nullptr);
+
+ if (Compilation->containsError())
+ return std::make_pair(nullptr, nullptr);
+
+ if (Compilation->getJobs().empty()) {
+ Diags.Report(diag::err_fe_expected_compiler_job)
+ << llvm::join(CommandLine, " ");
+ return std::make_pair(nullptr, nullptr);
+ }
----------------
jansvoboda11 wrote:
This seems to be the better place to report this error, nice!
https://github.com/llvm/llvm-project/pull/172347
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits