From 691e55643daa3470ff19b02a55e3e2503d2de0c9 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 29 Nov 2024 21:03:38 -0800 Subject: [PATCH] [Driver] BuildCompilation: remove unused BaseArg. NFC setBaseArg, only used by -XArch_* options, are called in BuildJobs. When processing --config and CL /clang:, BaseArg is always nullptr. The unneeded parameter was introduced in https://reviews.llvm.org/D24933 --- clang/lib/Driver/Driver.cpp | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index fdf21e35356ad8f..7de8341b8d2d611 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -998,14 +998,12 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // } -static void appendOneArg(InputArgList &Args, const Arg *Opt, - const Arg *BaseArg) { +static void appendOneArg(InputArgList &Args, const Arg *Opt) { // The args for config files or /clang: flags belong to different InputArgList // objects than Args. This copies an Arg from one of those other InputArgLists // to the ownership of Args. unsigned Index = Args.MakeIndex(Opt->getSpelling()); - Arg *Copy = new llvm::opt::Arg(Opt->getOption(), Args.getArgString(Index), - Index, BaseArg); + Arg *Copy = new Arg(Opt->getOption(), Args.getArgString(Index), Index); Copy->getValues() = Opt->getValues(); if (Opt->isClaimed()) Copy->claim(); @@ -1052,7 +1050,7 @@ bool Driver::readConfigFile(StringRef FileName, llvm::SmallString<128> CfgFileName(FileName); llvm::sys::path::native(CfgFileName); bool ContainErrors; - std::unique_ptr NewOptions = std::make_unique( + auto NewOptions = std::make_unique( ParseArgStrings(NewCfgArgs, /*UseDriverMode=*/true, ContainErrors)); if (ContainErrors) return true; @@ -1066,12 +1064,8 @@ bool Driver::readConfigFile(StringRef FileName, CfgOptions = std::move(NewOptions); else { // If this is a subsequent config file, append options to the previous one. - for (auto *Opt : *NewOptions) { - const Arg *BaseArg = &Opt->getBaseArg(); - if (BaseArg == Opt) - BaseArg = nullptr; - appendOneArg(*CfgOptions, Opt, BaseArg); - } + for (auto *Opt : *NewOptions) + appendOneArg(*CfgOptions, Opt); } ConfigFiles.push_back(std::string(CfgFileName)); return false; @@ -1256,14 +1250,9 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) { : std::move(*CLOptions)); if (HasConfigFile) - for (auto *Opt : *CLOptions) { - if (Opt->getOption().matches(options::OPT_config)) - continue; - const Arg *BaseArg = &Opt->getBaseArg(); - if (BaseArg == Opt) - BaseArg = nullptr; - appendOneArg(Args, Opt, BaseArg); - } + for (auto *Opt : *CLOptions) + if (!Opt->getOption().matches(options::OPT_config)) + appendOneArg(Args, Opt); // In CL mode, look for any pass-through arguments if (IsCLMode() && !ContainsError) { @@ -1281,9 +1270,8 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) { ContainsError)); if (!ContainsError) - for (auto *Opt : *CLModePassThroughOptions) { - appendOneArg(Args, Opt, nullptr); - } + for (auto *Opt : *CLModePassThroughOptions) + appendOneArg(Args, Opt); } }