ArgList: use MakeArgList overloads in subclasses and clean up some calls.

llvm-svn: 211340
This commit is contained in:
Justin Bogner 2014-06-20 04:36:29 +00:00
parent e03a25da70
commit 6f07046808
2 changed files with 13 additions and 15 deletions

View File

@ -328,6 +328,7 @@ public:
unsigned MakeIndex(StringRef String0) const;
unsigned MakeIndex(StringRef String0, StringRef String1) const;
using ArgList::MakeArgString;
const char *MakeArgString(StringRef Str) const override;
/// @}
@ -365,6 +366,7 @@ public:
/// (to be freed).
void AddSynthesizedArg(Arg *A);
using ArgList::MakeArgString;
const char *MakeArgString(StringRef Str) const override;
/// AddFlagArg - Construct a new FlagArg for the given option \p Id and

View File

@ -350,30 +350,27 @@ void DerivedArgList::AddSynthesizedArg(Arg *A) {
}
Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option Opt) const {
SynthesizedArgs.push_back(make_unique<Arg>(
Opt,
ArgList::MakeArgString(Twine(Opt.getPrefix()) + Twine(Opt.getName())),
BaseArgs.MakeIndex(Opt.getName()), BaseArg));
SynthesizedArgs.push_back(
make_unique<Arg>(Opt, MakeArgString(Opt.getPrefix() + Opt.getName()),
BaseArgs.MakeIndex(Opt.getName()), BaseArg));
return SynthesizedArgs.back().get();
}
Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option Opt,
StringRef Value) const {
unsigned Index = BaseArgs.MakeIndex(Value);
SynthesizedArgs.push_back(make_unique<Arg>(
Opt,
ArgList::MakeArgString(Twine(Opt.getPrefix()) + Twine(Opt.getName())),
Index, BaseArgs.getArgString(Index), BaseArg));
SynthesizedArgs.push_back(
make_unique<Arg>(Opt, MakeArgString(Opt.getPrefix() + Opt.getName()),
Index, BaseArgs.getArgString(Index), BaseArg));
return SynthesizedArgs.back().get();
}
Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option Opt,
StringRef Value) const {
unsigned Index = BaseArgs.MakeIndex(Opt.getName(), Value);
SynthesizedArgs.push_back(make_unique<Arg>(
Opt,
ArgList::MakeArgString(Twine(Opt.getPrefix()) + Twine(Opt.getName())),
Index, BaseArgs.getArgString(Index + 1), BaseArg));
SynthesizedArgs.push_back(
make_unique<Arg>(Opt, MakeArgString(Opt.getPrefix() + Opt.getName()),
Index, BaseArgs.getArgString(Index + 1), BaseArg));
return SynthesizedArgs.back().get();
}
@ -381,8 +378,7 @@ Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option Opt,
StringRef Value) const {
unsigned Index = BaseArgs.MakeIndex(Opt.getName().str() + Value.str());
SynthesizedArgs.push_back(make_unique<Arg>(
Opt,
ArgList::MakeArgString(Twine(Opt.getPrefix()) + Twine(Opt.getName())),
Index, BaseArgs.getArgString(Index) + Opt.getName().size(), BaseArg));
Opt, MakeArgString(Opt.getPrefix() + Opt.getName()), Index,
BaseArgs.getArgString(Index) + Opt.getName().size(), BaseArg));
return SynthesizedArgs.back().get();
}