diff options
Diffstat (limited to 'include/clang/Driver/OptTable.h')
-rw-r--r-- | include/clang/Driver/OptTable.h | 61 |
1 files changed, 18 insertions, 43 deletions
diff --git a/include/clang/Driver/OptTable.h b/include/clang/Driver/OptTable.h index 27bd119..53d83a0 100644 --- a/include/clang/Driver/OptTable.h +++ b/include/clang/Driver/OptTable.h @@ -12,24 +12,10 @@ #include "clang/Basic/LLVM.h" #include "clang/Driver/OptSpecifier.h" +#include "llvm/ADT/StringSet.h" namespace clang { namespace driver { -namespace options { - enum DriverFlag { - DriverOption = (1 << 0), - HelpHidden = (1 << 1), - LinkerInput = (1 << 2), - NoArgumentUnused = (1 << 3), - NoForward = (1 << 4), - RenderAsInput = (1 << 5), - RenderJoined = (1 << 6), - RenderSeparate = (1 << 7), - Unsupported = (1 << 8), - CC1Option = (1 << 9) - }; -} - class Arg; class ArgList; class InputArgList; @@ -46,9 +32,13 @@ namespace options { public: /// \brief Entry for a single option instance in the option data table. struct Info { + /// A null terminated array of prefix strings to apply to name while + /// matching. + const char *const *Prefixes; const char *Name; const char *HelpText; const char *MetaVar; + unsigned ID; unsigned char Kind; unsigned char Param; unsigned short Flags; @@ -61,19 +51,18 @@ namespace options { const Info *OptionInfos; unsigned NumOptionInfos; - /// \brief The lazily constructed options table, indexed by option::ID - 1. - mutable Option **Options; - - /// \brief Prebound input option instance. - const Option *TheInputOption; - - /// \brief Prebound unknown option instance. - const Option *TheUnknownOption; + unsigned TheInputOptionID; + unsigned TheUnknownOptionID; /// The index of the first option which can be parsed (i.e., is not a /// special option like 'input' or 'unknown', and is not an option group). unsigned FirstSearchableIndex; + /// The union of all option prefixes. If an argument does not begin with + /// one of these, it is an input. + llvm::StringSet<> PrefixesUnion; + std::string PrefixChars; + private: const Info &getInfo(OptSpecifier Opt) const { unsigned id = Opt.getID(); @@ -81,8 +70,6 @@ namespace options { return OptionInfos[id - 1]; } - Option *CreateOption(unsigned id) const; - protected: OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos); public: @@ -95,17 +82,7 @@ namespace options { /// if necessary. /// /// \return The option, or null for the INVALID option id. - const Option *getOption(OptSpecifier Opt) const { - unsigned id = Opt.getID(); - if (id == 0) - return 0; - - assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID."); - Option *&Entry = Options[id - 1]; - if (!Entry) - Entry = CreateOption(id); - return Entry; - } + const Option getOption(OptSpecifier Opt) const; /// \brief Lookup the name of the given option. const char *getOptionName(OptSpecifier id) const { @@ -122,11 +99,6 @@ namespace options { return getInfo(id).GroupID; } - /// \brief Should the help for the given option be hidden by default. - bool isOptionHelpHidden(OptSpecifier id) const { - return getInfo(id).Flags & options::HelpHidden; - } - /// \brief Get the help text to use to describe this option. const char *getOptionHelpText(OptSpecifier id) const { return getInfo(id).HelpText; @@ -176,9 +148,12 @@ namespace options { /// \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, bool ShowHidden = false) const; + const char *Title, unsigned short FlagsToInclude = 0, + unsigned short FlagsToExclude = 0) const; }; } } |