#define CLANG_DRIVER_OPTION_H_
#include "clang/Driver/OptSpecifier.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
using llvm::isa;
using llvm::cast;
OptSpecifier ID;
/// The option name.
- const char *Name;
+ llvm::StringRef Name;
/// Group this option is a member of, if any.
const OptionGroup *Group;
unsigned getID() const { return ID.getID(); }
OptionClass getKind() const { return Kind; }
- const char *getName() const { return Name; }
+ llvm::StringRef getName() const { return Name; }
const OptionGroup *getGroup() const { return Group; }
const Option *getAlias() const { return Alias; }
/// getRenderName - Return the name to use when rendering this
/// option.
- const char *getRenderName() const {
+ llvm::StringRef getRenderName() const {
return getUnaliasedOption()->getName();
}
Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option *Opt,
llvm::StringRef Value) const {
- unsigned Index = BaseArgs.MakeIndex(Opt->getName() + Value.str());
+ unsigned Index = BaseArgs.MakeIndex(Opt->getName().str() + Value.str());
Arg *A = new Arg(Opt, Index,
- BaseArgs.getArgString(Index) + strlen(Opt->getName()),
+ BaseArgs.getArgString(Index) + Opt->getName().size(),
BaseArg);
SynthesizedArgs.push_back(A);
return A;
Arg *FlagOption::accept(const ArgList &Args, unsigned &Index) const {
// Matches iff this is an exact match.
// FIXME: Avoid strlen.
- if (strlen(getName()) != strlen(Args.getArgString(Index)))
+ if (getName().size() != strlen(Args.getArgString(Index)))
return 0;
return new Arg(getUnaliasedOption(), Index++);
Arg *JoinedOption::accept(const ArgList &Args, unsigned &Index) const {
// Always matches.
- const char *Value = Args.getArgString(Index) + strlen(getName());
+ const char *Value = Args.getArgString(Index) + getName().size();
return new Arg(getUnaliasedOption(), Index++, Value);
}
Arg *CommaJoinedOption::accept(const ArgList &Args,
unsigned &Index) const {
// Always matches.
- const char *Str = Args.getArgString(Index) + strlen(getName());
+ const char *Str = Args.getArgString(Index) + getName().size();
Arg *A = new Arg(getUnaliasedOption(), Index++);
// Parse out the comma separated values.
Arg *SeparateOption::accept(const ArgList &Args, unsigned &Index) const {
// Matches iff this is an exact match.
// FIXME: Avoid strlen.
- if (strlen(getName()) != strlen(Args.getArgString(Index)))
+ if (getName().size() != strlen(Args.getArgString(Index)))
return 0;
Index += 2;
Arg *MultiArgOption::accept(const ArgList &Args, unsigned &Index) const {
// Matches iff this is an exact match.
// FIXME: Avoid strlen.
- if (strlen(getName()) != strlen(Args.getArgString(Index)))
+ if (getName().size() != strlen(Args.getArgString(Index)))
return 0;
Index += 1 + NumArgs;
unsigned &Index) const {
// If this is not an exact match, it is a joined arg.
// FIXME: Avoid strlen.
- if (strlen(getName()) != strlen(Args.getArgString(Index))) {
- const char *Value = Args.getArgString(Index) + strlen(getName());
+ if (getName().size() != strlen(Args.getArgString(Index))) {
+ const char *Value = Args.getArgString(Index) + getName().size();
return new Arg(this, Index++, Value);
}
return 0;
return new Arg(getUnaliasedOption(), Index - 2,
- Args.getArgString(Index-2)+strlen(getName()),
+ Args.getArgString(Index-2)+getName().size(),
Args.getArgString(Index-1));
}