summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/lib/Option
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/lib/Option')
-rw-r--r--contrib/llvm/lib/Option/Arg.cpp37
-rw-r--r--contrib/llvm/lib/Option/ArgList.cpp40
-rw-r--r--contrib/llvm/lib/Option/OptTable.cpp14
-rw-r--r--contrib/llvm/lib/Option/Option.cpp8
4 files changed, 53 insertions, 46 deletions
diff --git a/contrib/llvm/lib/Option/Arg.cpp b/contrib/llvm/lib/Option/Arg.cpp
index 4c8da58..ac00073 100644
--- a/contrib/llvm/lib/Option/Arg.cpp
+++ b/contrib/llvm/lib/Option/Arg.cpp
@@ -17,22 +17,21 @@
using namespace llvm;
using namespace llvm::opt;
-Arg::Arg(const Option _Opt, StringRef S, unsigned _Index, const Arg *_BaseArg)
- : Opt(_Opt), BaseArg(_BaseArg), Spelling(S), Index(_Index),
- Claimed(false), OwnsValues(false) {
-}
-
-Arg::Arg(const Option _Opt, StringRef S, unsigned _Index,
- const char *Value0, const Arg *_BaseArg)
- : Opt(_Opt), BaseArg(_BaseArg), Spelling(S), Index(_Index),
- Claimed(false), OwnsValues(false) {
+Arg::Arg(const Option Opt, StringRef S, unsigned Index, const Arg *BaseArg)
+ : Opt(Opt), BaseArg(BaseArg), Spelling(S), Index(Index), Claimed(false),
+ OwnsValues(false) {}
+
+Arg::Arg(const Option Opt, StringRef S, unsigned Index, const char *Value0,
+ const Arg *BaseArg)
+ : Opt(Opt), BaseArg(BaseArg), Spelling(S), Index(Index), Claimed(false),
+ OwnsValues(false) {
Values.push_back(Value0);
}
-Arg::Arg(const Option _Opt, StringRef S, unsigned _Index,
- const char *Value0, const char *Value1, const Arg *_BaseArg)
- : Opt(_Opt), BaseArg(_BaseArg), Spelling(S), Index(_Index),
- Claimed(false), OwnsValues(false) {
+Arg::Arg(const Option Opt, StringRef S, unsigned Index, const char *Value0,
+ const char *Value1, const Arg *BaseArg)
+ : Opt(Opt), BaseArg(BaseArg), Spelling(S), Index(Index), Claimed(false),
+ OwnsValues(false) {
Values.push_back(Value0);
Values.push_back(Value1);
}
@@ -83,15 +82,13 @@ void Arg::renderAsInput(const ArgList &Args, ArgStringList &Output) const {
return;
}
- for (unsigned i = 0, e = getNumValues(); i != e; ++i)
- Output.push_back(getValue(i));
+ Output.append(Values.begin(), Values.end());
}
void Arg::render(const ArgList &Args, ArgStringList &Output) const {
switch (getOption().getRenderStyle()) {
case Option::RenderValuesStyle:
- for (unsigned i = 0, e = getNumValues(); i != e; ++i)
- Output.push_back(getValue(i));
+ Output.append(Values.begin(), Values.end());
break;
case Option::RenderCommaJoinedStyle: {
@@ -109,14 +106,12 @@ void Arg::render(const ArgList &Args, ArgStringList &Output) const {
case Option::RenderJoinedStyle:
Output.push_back(Args.GetOrMakeJoinedArgString(
getIndex(), getSpelling(), getValue(0)));
- for (unsigned i = 1, e = getNumValues(); i != e; ++i)
- Output.push_back(getValue(i));
+ Output.append(Values.begin() + 1, Values.end());
break;
case Option::RenderSeparateStyle:
Output.push_back(Args.MakeArgString(getSpelling()));
- for (unsigned i = 0, e = getNumValues(); i != e; ++i)
- Output.push_back(getValue(i));
+ Output.append(Values.begin(), Values.end());
break;
}
}
diff --git a/contrib/llvm/lib/Option/ArgList.cpp b/contrib/llvm/lib/Option/ArgList.cpp
index b1a916d..b771a18 100644
--- a/contrib/llvm/lib/Option/ArgList.cpp
+++ b/contrib/llvm/lib/Option/ArgList.cpp
@@ -63,6 +63,26 @@ Arg *ArgList::getLastArgNoClaim(OptSpecifier Id0, OptSpecifier Id1) const {
return nullptr;
}
+Arg *ArgList::getLastArgNoClaim(OptSpecifier Id0, OptSpecifier Id1,
+ OptSpecifier Id2) const {
+ // FIXME: Make search efficient?
+ for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it)
+ if ((*it)->getOption().matches(Id0) || (*it)->getOption().matches(Id1) ||
+ (*it)->getOption().matches(Id2))
+ return *it;
+ return nullptr;
+}
+
+Arg *ArgList::getLastArgNoClaim(OptSpecifier Id0, OptSpecifier Id1,
+ OptSpecifier Id2, OptSpecifier Id3) const {
+ // FIXME: Make search efficient?
+ for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it)
+ if ((*it)->getOption().matches(Id0) || (*it)->getOption().matches(Id1) ||
+ (*it)->getOption().matches(Id2) || (*it)->getOption().matches(Id3))
+ return *it;
+ return nullptr;
+}
+
Arg *ArgList::getLastArg(OptSpecifier Id) const {
Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
@@ -253,8 +273,8 @@ void ArgList::AddAllArgValues(ArgStringList &Output, OptSpecifier Id0,
OptSpecifier Id1, OptSpecifier Id2) const {
for (auto Arg : filtered(Id0, Id1, Id2)) {
Arg->claim();
- for (unsigned i = 0, e = Arg->getNumValues(); i != e; ++i)
- Output.push_back(Arg->getValue(i));
+ const auto &Values = Arg->getValues();
+ Output.append(Values.begin(), Values.end());
}
}
@@ -285,11 +305,6 @@ void ArgList::ClaimAllArgs() const {
(*it)->claim();
}
-const char *ArgList::MakeArgString(const Twine &T) const {
- SmallString<256> Str;
- return MakeArgString(T.toStringRef(Str));
-}
-
const char *ArgList::GetOrMakeJoinedArgString(unsigned Index,
StringRef LHS,
StringRef RHS) const {
@@ -334,19 +349,18 @@ unsigned InputArgList::MakeIndex(StringRef String0,
return Index0;
}
-const char *InputArgList::MakeArgString(StringRef Str) const {
+const char *InputArgList::MakeArgStringRef(StringRef Str) const {
return getArgString(MakeIndex(Str));
}
//
-DerivedArgList::DerivedArgList(const InputArgList &_BaseArgs)
- : BaseArgs(_BaseArgs) {
-}
+DerivedArgList::DerivedArgList(const InputArgList &BaseArgs)
+ : BaseArgs(BaseArgs) {}
DerivedArgList::~DerivedArgList() {}
-const char *DerivedArgList::MakeArgString(StringRef Str) const {
+const char *DerivedArgList::MakeArgStringRef(StringRef Str) const {
return BaseArgs.MakeArgString(Str);
}
@@ -381,7 +395,7 @@ Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option Opt,
Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option Opt,
StringRef Value) const {
- unsigned Index = BaseArgs.MakeIndex(Opt.getName().str() + Value.str());
+ unsigned Index = BaseArgs.MakeIndex((Opt.getName() + Value).str());
SynthesizedArgs.push_back(make_unique<Arg>(
Opt, MakeArgString(Opt.getPrefix() + Opt.getName()), Index,
BaseArgs.getArgString(Index) + Opt.getName().size(), BaseArg));
diff --git a/contrib/llvm/lib/Option/OptTable.cpp b/contrib/llvm/lib/Option/OptTable.cpp
index dca02c17..96ba183 100644
--- a/contrib/llvm/lib/Option/OptTable.cpp
+++ b/contrib/llvm/lib/Option/OptTable.cpp
@@ -84,15 +84,11 @@ static inline bool operator<(const OptTable::Info &I, const char *Name) {
OptSpecifier::OptSpecifier(const Option *Opt) : ID(Opt->getID()) {}
-OptTable::OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos,
- bool _IgnoreCase)
- : OptionInfos(_OptionInfos),
- NumOptionInfos(_NumOptionInfos),
- IgnoreCase(_IgnoreCase),
- TheInputOptionID(0),
- TheUnknownOptionID(0),
- FirstSearchableIndex(0)
-{
+OptTable::OptTable(const Info *OptionInfos, unsigned NumOptionInfos,
+ bool IgnoreCase)
+ : OptionInfos(OptionInfos), NumOptionInfos(NumOptionInfos),
+ IgnoreCase(IgnoreCase), TheInputOptionID(0), TheUnknownOptionID(0),
+ FirstSearchableIndex(0) {
// Explicitly zero initialize the error to work around a bug in array
// value-initialization on MinGW with gcc 4.3.5.
diff --git a/contrib/llvm/lib/Option/Option.cpp b/contrib/llvm/lib/Option/Option.cpp
index cdc63c3..221414d 100644
--- a/contrib/llvm/lib/Option/Option.cpp
+++ b/contrib/llvm/lib/Option/Option.cpp
@@ -35,9 +35,6 @@ Option::Option(const OptTable::Info *info, const OptTable *owner)
}
}
-Option::~Option() {
-}
-
void Option::dump() const {
llvm::errs() << "<";
switch (getKind()) {
@@ -128,6 +125,11 @@ Arg *Option::accept(const ArgList &Args,
Val += strlen(Val) + 1;
}
}
+
+ if (UnaliasedOption.getKind() == JoinedClass && !getAliasArgs())
+ // A Flag alias for a Joined option must provide an argument.
+ A->getValues().push_back("");
+
return A;
}
case JoinedClass: {
OpenPOWER on IntegriCloud