[clang] [clang] Report an invalid -mllvm or -mmlir argument instead of exiting (PR #229781)
Chen Miao via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 8 18:39:14 PST 2026
================
@@ -736,10 +736,13 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
for (unsigned i = 0; i != NumArgs; ++i)
Args[i + 1] = Asm.LLVMArgs[i].c_str();
Args[NumArgs + 1] = nullptr;
- cl::parseCommandLineOptions(LibraryOptions,
- ArrayRef(Args.get(), NumArgs + 1),
- /*Overview=*/"", /*Errs=*/nullptr,
- /*VFS=*/VFS.get());
+ // 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 (!cl::parseCommandLineOptions(LibraryOptions,
+ ArrayRef(Args.get(), NumArgs + 1),
+ /*Overview=*/"", /*Errs=*/&llvm::errs(),
+ /*VFS=*/VFS.get()))
+ Diags.Report(diag::err_fe_invalid_forwarded_option) << 0;
----------------
ChenMiaoi wrote:
Same
https://github.com/llvm/llvm-project/pull/229781
More information about the cfe-commits
mailing list