aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2012-10-03 19:58:10 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2012-10-03 19:58:10 +0000
commit9b7dcdb53cee4234c48bb4ceeef39536419945cf (patch)
treeeb370024d6258b6bc5ee015b129e8762b808986f /lib/Driver
parentfc44e88cbdf013d285f2e4e3962fb80dcad56770 (diff)
[Options] Store the owning OptTable in Option so it can construct Group and Alias.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165150 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver')
-rw-r--r--lib/Driver/OptTable.cpp8
-rw-r--r--lib/Driver/Option.cpp11
2 files changed, 8 insertions, 11 deletions
diff --git a/lib/Driver/OptTable.cpp b/lib/Driver/OptTable.cpp
index a6d3cb3149..680ea9938f 100644
--- a/lib/Driver/OptTable.cpp
+++ b/lib/Driver/OptTable.cpp
@@ -134,13 +134,7 @@ bool OptTable::isOptionHelpHidden(OptSpecifier id) const {
}
Option *OptTable::CreateOption(unsigned id) const {
- const Info &info = getInfo(id);
- const Option *Group = getOption(info.GroupID);
- const Option *Alias = getOption(info.AliasID);
-
- Option *Opt = new Option(&info, Group, Alias);
-
- return Opt;
+ return new Option(&getInfo(id), this);
}
Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index) const {
diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp
index 3be141e61d..117021b880 100644
--- a/lib/Driver/Option.cpp
+++ b/lib/Driver/Option.cpp
@@ -17,14 +17,13 @@
#include <algorithm>
using namespace clang::driver;
-Option::Option(const OptTable::Info *info,
- const Option *_Group, const Option *_Alias)
- : Info(info), Group(_Group), Alias(_Alias) {
+Option::Option(const OptTable::Info *info, const OptTable *owner)
+ : Info(info), Owner(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((!Alias || (!Alias->Alias && !Group)) &&
+ assert((!getAlias() || (!getAlias()->getAlias() && !getGroup())) &&
"Multi-level aliases and aliases with groups are unsupported.");
}
@@ -50,11 +49,13 @@ void Option::dump() const {
llvm::errs() << " Name:\"" << getName() << '"';
+ const Option *Group = getGroup();
if (Group) {
llvm::errs() << " Group:";
Group->dump();
}
+ const Option *Alias = getAlias();
if (Alias) {
llvm::errs() << " Alias:";
Alias->dump();
@@ -68,6 +69,7 @@ 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);
@@ -75,6 +77,7 @@ bool Option::matches(OptSpecifier Opt) const {
if (getID() == Opt.getID())
return true;
+ const Option *Group = getGroup();
if (Group)
return Group->matches(Opt);
return false;