#ifndef LLVM_OPTION_ARG_H
#define LLVM_OPTION_ARG_H
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Option/Option.h"
#include <string>
namespace llvm {
namespace opt {
class ArgList;
class Arg {
Arg(const Arg &) LLVM_DELETED_FUNCTION;
void operator=(const Arg &) LLVM_DELETED_FUNCTION;
private:
const Option Opt;
const Arg *BaseArg;
StringRef Spelling;
unsigned Index;
mutable unsigned Claimed : 1;
mutable unsigned OwnsValues : 1;
SmallVector<const char *, 2> Values;
public:
Arg(const Option Opt, StringRef Spelling, unsigned Index,
const Arg *BaseArg = nullptr);
Arg(const Option Opt, StringRef Spelling, unsigned Index,
const char *Value0, const Arg *BaseArg = nullptr);
Arg(const Option Opt, StringRef Spelling, unsigned Index,
const char *Value0, const char *Value1, const Arg *BaseArg = nullptr);
~Arg();
const Option &getOption() const { return Opt; }
StringRef getSpelling() const { return Spelling; }
unsigned getIndex() const { return Index; }
const Arg &getBaseArg() const {
return BaseArg ? *BaseArg : *this;
}
void setBaseArg(const Arg *_BaseArg) {
BaseArg = _BaseArg;
}
bool getOwnsValues() const { return OwnsValues; }
void setOwnsValues(bool Value) const { OwnsValues = Value; }
bool isClaimed() const { return getBaseArg().Claimed; }
void claim() const { getBaseArg().Claimed = true; }
unsigned getNumValues() const { return Values.size(); }
const char *getValue(unsigned N = 0) const {
return Values[N];
}
SmallVectorImpl<const char*> &getValues() {
return Values;
}
bool containsValue(StringRef Value) const {
for (unsigned i = 0, e = getNumValues(); i != e; ++i)
if (Values[i] == Value)
return true;
return false;
}
void render(const ArgList &Args, ArgStringList &Output) const;
void renderAsInput(const ArgList &Args, ArgStringList &Output) const;
void dump() const;
std::string getAsString(const ArgList &Args) const;
};
} }
#endif