summaryrefslogtreecommitdiff
path: root/include/llvm/Option
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Option')
-rw-r--r--include/llvm/Option/ArgList.h9
-rw-r--r--include/llvm/Option/OptParser.td8
-rw-r--r--include/llvm/Option/OptTable.h32
-rw-r--r--include/llvm/Option/Option.h18
4 files changed, 55 insertions, 12 deletions
diff --git a/include/llvm/Option/ArgList.h b/include/llvm/Option/ArgList.h
index d3accfe7f1e02..06ba679c2b553 100644
--- a/include/llvm/Option/ArgList.h
+++ b/include/llvm/Option/ArgList.h
@@ -222,8 +222,17 @@ public:
/// negation are present, the last one wins.
bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default=true) const;
+ /// hasFlag - Given an option \p Pos, an alias \p PosAlias and its negative
+ /// form \p Neg, return true if the option or its alias is present, false if
+ /// the negation is present, and \p Default if none of the options are
+ /// given. If multiple options are present, the last one wins.
+ bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
+ bool Default = true) const;
+
/// AddLastArg - Render only the last argument match \p Id0, if present.
void AddLastArg(ArgStringList &Output, OptSpecifier Id0) const;
+ void AddLastArg(ArgStringList &Output, OptSpecifier Id0,
+ OptSpecifier Id1) const;
/// AddAllArgs - Render all arguments matching the given ids.
void AddAllArgs(ArgStringList &Output, OptSpecifier Id0,
diff --git a/include/llvm/Option/OptParser.td b/include/llvm/Option/OptParser.td
index e781fa02d75bc..963389f0bc6fd 100644
--- a/include/llvm/Option/OptParser.td
+++ b/include/llvm/Option/OptParser.td
@@ -14,10 +14,10 @@
// Define the kinds of options.
-class OptionKind<string name, int predecence = 0, bit sentinel = 0> {
+class OptionKind<string name, int precedence = 0, bit sentinel = 0> {
string Name = name;
// The kind precedence, kinds with lower precedence are matched first.
- int Precedence = predecence;
+ int Precedence = precedence;
// Indicate a sentinel option.
bit Sentinel = sentinel;
}
@@ -44,6 +44,8 @@ def KIND_JOINED_OR_SEPARATE : OptionKind<"JoinedOrSeparate">;
// An option which is both joined to its (first) value, and followed by its
// (second) value.
def KIND_JOINED_AND_SEPARATE : OptionKind<"JoinedAndSeparate">;
+// An option which consumes all remaining arguments if there are any.
+def KIND_REMAINING_ARGS : OptionKind<"RemainingArgs">;
// Define the option flags.
@@ -89,6 +91,7 @@ class Option<list<string> prefixes, string name, OptionKind kind> {
list<OptionFlag> Flags = [];
OptionGroup Group = ?;
Option Alias = ?;
+ list<string> AliasArgs = [];
}
// Helpers for defining options.
@@ -113,6 +116,7 @@ class JoinedAndSeparate<list<string> prefixes, string name>
// Mix-ins for adding optional attributes.
class Alias<Option alias> { Option Alias = alias; }
+class AliasArgs<list<string> aliasargs> { list<string> AliasArgs = aliasargs; }
class EnumName<string name> { string EnumName = name; }
class Flags<list<OptionFlag> flags> { list<OptionFlag> Flags = flags; }
class Group<OptionGroup group> { OptionGroup Group = group; }
diff --git a/include/llvm/Option/OptTable.h b/include/llvm/Option/OptTable.h
index a93acbf11e9b5..5035940af06ba 100644
--- a/include/llvm/Option/OptTable.h
+++ b/include/llvm/Option/OptTable.h
@@ -44,12 +44,14 @@ public:
unsigned short Flags;
unsigned short GroupID;
unsigned short AliasID;
+ const char *AliasArgs;
};
private:
/// \brief The static option information table.
const Info *OptionInfos;
unsigned NumOptionInfos;
+ bool IgnoreCase;
unsigned TheInputOptionID;
unsigned TheUnknownOptionID;
@@ -71,7 +73,8 @@ private:
}
protected:
- OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos);
+ OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos,
+ bool _IgnoreCase = false);
public:
~OptTable();
@@ -99,9 +102,6 @@ public:
return getInfo(id).GroupID;
}
- /// \brief Should the help for the given option be hidden by default.
- bool isOptionHelpHidden(OptSpecifier id) const;
-
/// \brief Get the help text to use to describe this option.
const char *getOptionHelpText(OptSpecifier id) const {
return getInfo(id).HelpText;
@@ -119,11 +119,17 @@ public:
/// \param [in,out] Index - The current parsing position in the argument
/// string list; on return this will be the index of the next argument
/// string to parse.
+ /// \param [in] FlagsToInclude - Only parse options with any of these flags.
+ /// Zero is the default which includes all flags.
+ /// \param [in] FlagsToExclude - Don't parse options with this flag. Zero
+ /// is the default and means exclude nothing.
///
/// \return The parsed argument, or 0 if the argument is missing values
/// (in which case Index still points at the conceptual next argument string
/// to parse).
- Arg *ParseOneArg(const ArgList &Args, unsigned &Index) const;
+ Arg *ParseOneArg(const ArgList &Args, unsigned &Index,
+ unsigned FlagsToInclude = 0,
+ unsigned FlagsToExclude = 0) const;
/// \brief Parse an list of arguments into an InputArgList.
///
@@ -139,19 +145,31 @@ public:
/// \param MissingArgIndex - On error, the index of the option which could
/// not be parsed.
/// \param MissingArgCount - On error, the number of missing options.
+ /// \param FlagsToInclude - Only parse options with any of these flags.
+ /// Zero is the default which includes all flags.
+ /// \param FlagsToExclude - Don't parse options with this flag. Zero
+ /// is the default and means exclude nothing.
/// \return An InputArgList; on error this will contain all the options
/// which could be parsed.
InputArgList *ParseArgs(const char* const *ArgBegin,
const char* const *ArgEnd,
unsigned &MissingArgIndex,
- unsigned &MissingArgCount) const;
+ unsigned &MissingArgCount,
+ unsigned FlagsToInclude = 0,
+ unsigned FlagsToExclude = 0) const;
/// \brief Render the help text for an option table.
///
/// \param OS - The stream to write the help text to.
/// \param Name - The name to use in the usage line.
/// \param Title - The title to use in the usage line.
- /// \param ShowHidden - Whether help-hidden arguments should be shown.
+ /// \param FlagsToInclude - If non-zero, only include options with any
+ /// of these flags set.
+ /// \param FlagsToExclude - Exclude options with any of these flags set.
+ void PrintHelp(raw_ostream &OS, const char *Name,
+ const char *Title, unsigned FlagsToInclude,
+ unsigned FlagsToExclude) const;
+
void PrintHelp(raw_ostream &OS, const char *Name,
const char *Title, bool ShowHidden = false) const;
};
diff --git a/include/llvm/Option/Option.h b/include/llvm/Option/Option.h
index 541aa8d99185b..03d4774829fbc 100644
--- a/include/llvm/Option/Option.h
+++ b/include/llvm/Option/Option.h
@@ -50,6 +50,7 @@ public:
FlagClass,
JoinedClass,
SeparateClass,
+ RemainingArgsClass,
CommaJoinedClass,
MultiArgClass,
JoinedOrSeparateClass,
@@ -103,6 +104,16 @@ public:
return Owner->getOption(Info->AliasID);
}
+ /// \brief Get the alias arguments as a \0 separated list.
+ /// E.g. ["foo", "bar"] would be returned as "foo\0bar\0".
+ const char *getAliasArgs() const {
+ assert(Info && "Must have a valid info!");
+ assert((!Info->AliasArgs || Info->AliasArgs[0] != 0) &&
+ "AliasArgs should be either 0 or non-empty.");
+
+ return Info->AliasArgs;
+ }
+
/// \brief Get the default prefix for this option.
StringRef getPrefix() const {
const char *Prefix = *Info->Prefixes;
@@ -139,6 +150,7 @@ public:
case SeparateClass:
case MultiArgClass:
case JoinedOrSeparateClass:
+ case RemainingArgsClass:
return RenderSeparateStyle;
}
llvm_unreachable("Unexpected kind!");
@@ -179,9 +191,9 @@ public:
/// Index to the position where argument parsing should resume
/// (even if the argument is missing values).
///
- /// \parm ArgSize The number of bytes taken up by the matched Option prefix
- /// and name. This is used to determine where joined values
- /// start.
+ /// \param ArgSize The number of bytes taken up by the matched Option prefix
+ /// and name. This is used to determine where joined values
+ /// start.
Arg *accept(const ArgList &Args, unsigned &Index, unsigned ArgSize) const;
void dump() const;