aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Option.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2012-10-10 21:48:26 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2012-10-10 21:48:26 +0000
commit0464fd5e4ce2193e786e5adcab6b828f9366dae3 (patch)
tree72b476462a53dc48deb42a48fc89285a11e28517 /lib/Driver/Option.cpp
parentcf9030e480f77ab349672f00ad302e216c26c92c (diff)
[Options] make Option a value type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165663 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Option.cpp')
-rw-r--r--lib/Driver/Option.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp
index 117021b880..a250d8740a 100644
--- a/lib/Driver/Option.cpp
+++ b/lib/Driver/Option.cpp
@@ -23,7 +23,8 @@ Option::Option(const OptTable::Info *info, const OptTable *owner)
// Multi-level aliases are not supported, and alias options cannot
// have groups. This just simplifies option tracking, it is not an
// inherent limitation.
- assert((!getAlias() || (!getAlias()->getAlias() && !getGroup())) &&
+ assert((!getAlias().isValid() || (!getAlias().getAlias().isValid() &&
+ !getGroup().isValid())) &&
"Multi-level aliases and aliases with groups are unsupported.");
}
@@ -49,16 +50,16 @@ void Option::dump() const {
llvm::errs() << " Name:\"" << getName() << '"';
- const Option *Group = getGroup();
- if (Group) {
+ const Option Group = getGroup();
+ if (Group.isValid()) {
llvm::errs() << " Group:";
- Group->dump();
+ Group.dump();
}
- const Option *Alias = getAlias();
- if (Alias) {
+ const Option Alias = getAlias();
+ if (Alias.isValid()) {
llvm::errs() << " Alias:";
- Alias->dump();
+ Alias.dump();
}
if (getKind() == MultiArgClass)
@@ -69,17 +70,17 @@ void Option::dump() const {
bool Option::matches(OptSpecifier Opt) const {
// Aliases are never considered in matching, look through them.
- const Option *Alias = getAlias();
- if (Alias)
- return Alias->matches(Opt);
+ const Option Alias = getAlias();
+ if (Alias.isValid())
+ return Alias.matches(Opt);
// Check exact match.
if (getID() == Opt.getID())
return true;
- const Option *Group = getGroup();
- if (Group)
- return Group->matches(Opt);
+ const Option Group = getGroup();
+ if (Group.isValid())
+ return Group.matches(Opt);
return false;
}
@@ -155,7 +156,7 @@ Arg *Option::accept(const ArgList &Args, unsigned &Index) const {
// FIXME: Avoid strlen.
if (getName().size() != strlen(Args.getArgString(Index))) {
const char *Value = Args.getArgString(Index) + getName().size();
- return new Arg(this, Index++, Value);
+ return new Arg(*this, Index++, Value);
}
// Otherwise it must be separate.