================
@@ -1143,10 +1143,13 @@ void CompilerInstance::parseLLVMArgs() {
for (unsigned i = 0; i != NumArgs; ++i)
Args[i + 1] = getFrontendOpts().LLVMArgs[i].c_str();
Args[NumArgs + 1] = nullptr;
- llvm::cl::parseCommandLineOptions(LibraryOptions,
- ArrayRef(Args.get(), NumArgs + 1),
- /*Overview=*/"", /*Errs=*/nullptr,
- /*VFS=*/&getVirtualFileSystem());
+ // With no stream to report to, the parser calls exit(), which ends the
+ // process that embeds clang. Keep its output where it already went.
+ if (!llvm::cl::parseCommandLineOptions(
+ LibraryOptions, ArrayRef(Args.get(), NumArgs + 1),
+ /*Overview=*/"", /*Errs=*/&llvm::errs(),
+ /*VFS=*/&getVirtualFileSystem()))
+ getDiagnostics().Report(diag::err_fe_invalid_forwarded_option) << 0;
----------------
ChenMiaoi wrote:
I think we also need to stop the current invocation and return failure here,
preserving the failure behavior of the original `exit()`.
https://github.com/llvm/llvm-project/pull/229781
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits