https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/126101
Summary: Currently the `-Xarch` argument needs to re-parse the option, which goes through every single registered argument. This causes errors when trying to pass `-O1` through it because it thinks it's a DXC option. This patch changes the behavior to only allow `clang` options. Concievably we could detect the driver mode to make this more robust, but I don't know if there are other users for this. Fixes: https://github.com/llvm/llvm-project/issues/110325 >From 02f99f1bd5f434c2553446b530b8714d9cf56e34 Mon Sep 17 00:00:00 2001 From: Joseph Huber <hube...@outlook.com> Date: Thu, 6 Feb 2025 11:37:09 -0600 Subject: [PATCH] [Clang] Only allow `clang` arguments to `-Xarch` Summary: Currently the `-Xarch` argument needs to re-parse the option, which goes through every single registered argument. This causes errors when trying to pass `-O1` through it because it thinks it's a DXC option. This patch changes the behavior to only allow `clang` options. Concievably we could detect the driver mode to make this more robust, but I don't know if there are other users for this. Fixes: https://github.com/llvm/llvm-project/issues/110325 --- clang/lib/Driver/ToolChain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index c25d1b6be14b50d..56bc500da66b9f5 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -1651,7 +1651,8 @@ void ToolChain::TranslateXarchArgs( const InputArgList &BaseArgs = Args.getBaseArgs(); unsigned Index = BaseArgs.MakeIndex(A->getValue(ValuePos)); unsigned Prev = Index; - std::unique_ptr<llvm::opt::Arg> XarchArg(Opts.ParseOneArg(Args, Index)); + std::unique_ptr<llvm::opt::Arg> XarchArg(Opts.ParseOneArg( + Args, Index, llvm::opt::Visibility(clang::driver::options::ClangOption))); // If the argument parsing failed or more than one argument was // consumed, the -Xarch_ argument's parameter tried to consume _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits