Skip to content

Commit

Permalink
[Driver] BuildCompilation: remove unused BaseArg. NFC
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MaskRay committed Nov 30, 2024
1 parent b9ac390 commit 691e556
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 691e556

Please sign in to comment.