[clang] 691e556 - [Driver] BuildCompilation: remove unused BaseArg. NFC
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 29 21:03:45 PST 2024
Author: Fangrui Song
Date: 2024-11-29T21:03:38-08:00
New Revision: 691e55643daa3470ff19b02a55e3e2503d2de0c9
URL: https://github.com/llvm/llvm-project/commit/691e55643daa3470ff19b02a55e3e2503d2de0c9
DIFF: https://github.com/llvm/llvm-project/commit/691e55643daa3470ff19b02a55e3e2503d2de0c9.diff
LOG: [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
Added:
Modified:
clang/lib/Driver/Driver.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index fdf21e35356ad8..7de8341b8d2d61 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
diff erent 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<InputArgList> NewOptions = std::make_unique<InputArgList>(
+ auto NewOptions = std::make_unique<InputArgList>(
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<const char *> 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<const char *> ArgList) {
ContainsError));
if (!ContainsError)
- for (auto *Opt : *CLModePassThroughOptions) {
- appendOneArg(Args, Opt, nullptr);
- }
+ for (auto *Opt : *CLModePassThroughOptions)
+ appendOneArg(Args, Opt);
}
}
More information about the cfe-commits
mailing list