forked from OSchip/llvm-project
Driver: Store Option ID field as unsigned to drop dependency on the options
type. llvm-svn: 89232
This commit is contained in:
parent
24cfcf15c3
commit
f324fa7095
|
@ -10,8 +10,6 @@
|
|||
#ifndef CLANG_DRIVER_OPTION_H_
|
||||
#define CLANG_DRIVER_OPTION_H_
|
||||
|
||||
#include "Options.h"
|
||||
|
||||
#include "llvm/Support/Casting.h"
|
||||
using llvm::isa;
|
||||
using llvm::cast;
|
||||
|
@ -54,7 +52,7 @@ namespace driver {
|
|||
private:
|
||||
OptionClass Kind;
|
||||
|
||||
options::ID ID;
|
||||
unsigned ID;
|
||||
|
||||
/// The option name.
|
||||
const char *Name;
|
||||
|
@ -89,12 +87,12 @@ namespace driver {
|
|||
bool NoArgumentUnused : 1;
|
||||
|
||||
protected:
|
||||
Option(OptionClass Kind, options::ID ID, const char *Name,
|
||||
Option(OptionClass Kind, unsigned ID, const char *Name,
|
||||
const OptionGroup *Group, const Option *Alias);
|
||||
public:
|
||||
virtual ~Option();
|
||||
|
||||
options::ID getId() const { return ID; }
|
||||
unsigned getId() const { return ID; }
|
||||
OptionClass getKind() const { return Kind; }
|
||||
const char *getName() const { return Name; }
|
||||
const OptionGroup *getGroup() const { return Group; }
|
||||
|
@ -139,7 +137,7 @@ namespace driver {
|
|||
/// matches - Predicate for whether this option is part of the
|
||||
/// given option (which may be a group).
|
||||
bool matches(const Option *Opt) const;
|
||||
bool matches(options::ID Id) const;
|
||||
bool matches(unsigned Id) const;
|
||||
|
||||
/// accept - Potentially accept the current argument, returning a
|
||||
/// new Arg instance, or 0 if the option does not accept this
|
||||
|
@ -159,7 +157,7 @@ namespace driver {
|
|||
/// by the driver.
|
||||
class OptionGroup : public Option {
|
||||
public:
|
||||
OptionGroup(options::ID ID, const char *Name, const OptionGroup *Group);
|
||||
OptionGroup(unsigned ID, const char *Name, const OptionGroup *Group);
|
||||
|
||||
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
|
||||
|
||||
|
@ -201,7 +199,7 @@ namespace driver {
|
|||
|
||||
class FlagOption : public Option {
|
||||
public:
|
||||
FlagOption(options::ID ID, const char *Name, const OptionGroup *Group,
|
||||
FlagOption(unsigned ID, const char *Name, const OptionGroup *Group,
|
||||
const Option *Alias);
|
||||
|
||||
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
|
||||
|
@ -214,7 +212,7 @@ namespace driver {
|
|||
|
||||
class JoinedOption : public Option {
|
||||
public:
|
||||
JoinedOption(options::ID ID, const char *Name, const OptionGroup *Group,
|
||||
JoinedOption(unsigned ID, const char *Name, const OptionGroup *Group,
|
||||
const Option *Alias);
|
||||
|
||||
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
|
||||
|
@ -227,7 +225,7 @@ namespace driver {
|
|||
|
||||
class SeparateOption : public Option {
|
||||
public:
|
||||
SeparateOption(options::ID ID, const char *Name, const OptionGroup *Group,
|
||||
SeparateOption(unsigned ID, const char *Name, const OptionGroup *Group,
|
||||
const Option *Alias);
|
||||
|
||||
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
|
||||
|
@ -240,7 +238,7 @@ namespace driver {
|
|||
|
||||
class CommaJoinedOption : public Option {
|
||||
public:
|
||||
CommaJoinedOption(options::ID ID, const char *Name,
|
||||
CommaJoinedOption(unsigned ID, const char *Name,
|
||||
const OptionGroup *Group, const Option *Alias);
|
||||
|
||||
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
|
||||
|
@ -259,7 +257,7 @@ namespace driver {
|
|||
unsigned NumArgs;
|
||||
|
||||
public:
|
||||
MultiArgOption(options::ID ID, const char *Name, const OptionGroup *Group,
|
||||
MultiArgOption(unsigned ID, const char *Name, const OptionGroup *Group,
|
||||
const Option *Alias, unsigned NumArgs);
|
||||
|
||||
unsigned getNumArgs() const { return NumArgs; }
|
||||
|
@ -276,7 +274,7 @@ namespace driver {
|
|||
/// prefixes its (non-empty) value, or is follwed by a value.
|
||||
class JoinedOrSeparateOption : public Option {
|
||||
public:
|
||||
JoinedOrSeparateOption(options::ID ID, const char *Name,
|
||||
JoinedOrSeparateOption(unsigned ID, const char *Name,
|
||||
const OptionGroup *Group, const Option *Alias);
|
||||
|
||||
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
|
||||
|
@ -291,7 +289,7 @@ namespace driver {
|
|||
/// value and is followed by another value.
|
||||
class JoinedAndSeparateOption : public Option {
|
||||
public:
|
||||
JoinedAndSeparateOption(options::ID ID, const char *Name,
|
||||
JoinedAndSeparateOption(unsigned ID, const char *Name,
|
||||
const OptionGroup *Group, const Option *Alias);
|
||||
|
||||
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <algorithm>
|
||||
using namespace clang::driver;
|
||||
|
||||
Option::Option(OptionClass _Kind, options::ID _ID, const char *_Name,
|
||||
Option::Option(OptionClass _Kind, unsigned _ID, const char *_Name,
|
||||
const OptionGroup *_Group, const Option *_Alias)
|
||||
: Kind(_Kind), ID(_ID), Name(_Name), Group(_Group), Alias(_Alias),
|
||||
Unsupported(false), LinkerInput(false), NoOptAsInput(false),
|
||||
|
@ -85,7 +85,7 @@ bool Option::matches(const Option *Opt) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Option::matches(options::ID Id) const {
|
||||
bool Option::matches(unsigned Id) const {
|
||||
// FIXME: Decide what to do here; we should either pull out the
|
||||
// handling of alias on the option for Id from the other matches, or
|
||||
// find some other solution (which hopefully doesn't require using
|
||||
|
@ -101,7 +101,7 @@ bool Option::matches(options::ID Id) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
OptionGroup::OptionGroup(options::ID ID, const char *Name,
|
||||
OptionGroup::OptionGroup(unsigned ID, const char *Name,
|
||||
const OptionGroup *Group)
|
||||
: Option(Option::GroupClass, ID, Name, Group, 0) {
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ Arg *UnknownOption::accept(const InputArgList &Args, unsigned &Index) const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
FlagOption::FlagOption(options::ID ID, const char *Name,
|
||||
FlagOption::FlagOption(unsigned ID, const char *Name,
|
||||
const OptionGroup *Group, const Option *Alias)
|
||||
: Option(Option::FlagClass, ID, Name, Group, Alias) {
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ Arg *FlagOption::accept(const InputArgList &Args, unsigned &Index) const {
|
|||
return new FlagArg(this, Index++);
|
||||
}
|
||||
|
||||
JoinedOption::JoinedOption(options::ID ID, const char *Name,
|
||||
JoinedOption::JoinedOption(unsigned ID, const char *Name,
|
||||
const OptionGroup *Group, const Option *Alias)
|
||||
: Option(Option::JoinedClass, ID, Name, Group, Alias) {
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ Arg *JoinedOption::accept(const InputArgList &Args, unsigned &Index) const {
|
|||
return new JoinedArg(this, Index++);
|
||||
}
|
||||
|
||||
CommaJoinedOption::CommaJoinedOption(options::ID ID, const char *Name,
|
||||
CommaJoinedOption::CommaJoinedOption(unsigned ID, const char *Name,
|
||||
const OptionGroup *Group,
|
||||
const Option *Alias)
|
||||
: Option(Option::CommaJoinedClass, ID, Name, Group, Alias) {
|
||||
|
@ -170,7 +170,7 @@ Arg *CommaJoinedOption::accept(const InputArgList &Args,
|
|||
return new CommaJoinedArg(this, Index++, Suffix);
|
||||
}
|
||||
|
||||
SeparateOption::SeparateOption(options::ID ID, const char *Name,
|
||||
SeparateOption::SeparateOption(unsigned ID, const char *Name,
|
||||
const OptionGroup *Group, const Option *Alias)
|
||||
: Option(Option::SeparateClass, ID, Name, Group, Alias) {
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ Arg *SeparateOption::accept(const InputArgList &Args, unsigned &Index) const {
|
|||
return new SeparateArg(this, Index - 2, 1);
|
||||
}
|
||||
|
||||
MultiArgOption::MultiArgOption(options::ID ID, const char *Name,
|
||||
MultiArgOption::MultiArgOption(unsigned ID, const char *Name,
|
||||
const OptionGroup *Group, const Option *Alias,
|
||||
unsigned _NumArgs)
|
||||
: Option(Option::MultiArgClass, ID, Name, Group, Alias), NumArgs(_NumArgs) {
|
||||
|
@ -208,7 +208,7 @@ Arg *MultiArgOption::accept(const InputArgList &Args, unsigned &Index) const {
|
|||
return new SeparateArg(this, Index - 1 - NumArgs, NumArgs);
|
||||
}
|
||||
|
||||
JoinedOrSeparateOption::JoinedOrSeparateOption(options::ID ID, const char *Name,
|
||||
JoinedOrSeparateOption::JoinedOrSeparateOption(unsigned ID, const char *Name,
|
||||
const OptionGroup *Group,
|
||||
const Option *Alias)
|
||||
: Option(Option::JoinedOrSeparateClass, ID, Name, Group, Alias) {
|
||||
|
@ -229,7 +229,7 @@ Arg *JoinedOrSeparateOption::accept(const InputArgList &Args,
|
|||
return new SeparateArg(this, Index - 2, 1);
|
||||
}
|
||||
|
||||
JoinedAndSeparateOption::JoinedAndSeparateOption(options::ID ID,
|
||||
JoinedAndSeparateOption::JoinedAndSeparateOption(unsigned ID,
|
||||
const char *Name,
|
||||
const OptionGroup *Group,
|
||||
const Option *Alias)
|
||||
|
|
|
@ -365,8 +365,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args,
|
|||
// Sob. These is strictly gcc compatible for the time being. Apple
|
||||
// gcc translates options twice, which means that self-expanding
|
||||
// options add duplicates.
|
||||
options::ID id = A->getOption().getId();
|
||||
switch (id) {
|
||||
switch ((options::ID) A->getOption().getId()) {
|
||||
default:
|
||||
DAL->append(A);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue