diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-10-18 22:42:31 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-10-18 22:42:31 +0000 |
commit | f38523388174760dcbad810ef60d8504d7df6b4c (patch) | |
tree | 336884232711ddc238e70b9acca37f23e12bda96 /include | |
parent | 25dfaacde51df0834f10e3ab1646e6de9e229788 (diff) |
Revert r166223 and the subsequent commits that depend on it, r166230 & r166235.
This seems to have introduced assertion hit when building compiler-rt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166245 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Driver/Arg.h | 13 | ||||
-rw-r--r-- | include/clang/Driver/ArgList.h | 17 | ||||
-rw-r--r-- | include/clang/Driver/OptTable.h | 23 | ||||
-rw-r--r-- | include/clang/Driver/Option.h | 85 |
4 files changed, 70 insertions, 68 deletions
diff --git a/include/clang/Driver/Arg.h b/include/clang/Driver/Arg.h index bd4fa872ea..70f0741520 100644 --- a/include/clang/Driver/Arg.h +++ b/include/clang/Driver/Arg.h @@ -15,8 +15,6 @@ #ifndef CLANG_DRIVER_ARG_H_ #define CLANG_DRIVER_ARG_H_ -#include "clang/Driver/Option.h" - #include "Util.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -25,6 +23,7 @@ namespace clang { namespace driver { class ArgList; + class Option; /// \brief A concrete instance of a particular driver option. /// @@ -39,7 +38,7 @@ namespace driver { private: /// \brief The option this argument is an instance of. - const Option Opt; + const Option *Opt; /// \brief The argument this argument was derived from (during tool chain /// argument translation), if any. @@ -61,14 +60,14 @@ namespace driver { SmallVector<const char *, 2> Values; public: - Arg(const Option Opt, unsigned Index, const Arg *BaseArg = 0); - Arg(const Option Opt, unsigned Index, + Arg(const Option *Opt, unsigned Index, const Arg *BaseArg = 0); + Arg(const Option *Opt, unsigned Index, const char *Value0, const Arg *BaseArg = 0); - Arg(const Option Opt, unsigned Index, + Arg(const Option *Opt, unsigned Index, const char *Value0, const char *Value1, const Arg *BaseArg = 0); ~Arg(); - const Option getOption() const { return Opt; } + const Option &getOption() const { return *Opt; } unsigned getIndex() const { return Index; } /// \brief Return the base argument which generated this arg. diff --git a/include/clang/Driver/ArgList.h b/include/clang/Driver/ArgList.h index 72ed7bf586..b2570b01dd 100644 --- a/include/clang/Driver/ArgList.h +++ b/include/clang/Driver/ArgList.h @@ -11,7 +11,6 @@ #define CLANG_DRIVER_ARGLIST_H_ #include "clang/Basic/LLVM.h" -#include "clang/Driver/Option.h" #include "clang/Driver/OptSpecifier.h" #include "clang/Driver/Util.h" #include "llvm/ADT/SmallVector.h" @@ -375,14 +374,14 @@ namespace driver { /// AddFlagArg - Construct a new FlagArg for the given option \p Id and /// append it to the argument list. - void AddFlagArg(const Arg *BaseArg, const Option Opt) { + void AddFlagArg(const Arg *BaseArg, const Option *Opt) { append(MakeFlagArg(BaseArg, Opt)); } /// AddPositionalArg - Construct a new Positional arg for the given option /// \p Id, with the provided \p Value and append it to the argument /// list. - void AddPositionalArg(const Arg *BaseArg, const Option Opt, + void AddPositionalArg(const Arg *BaseArg, const Option *Opt, StringRef Value) { append(MakePositionalArg(BaseArg, Opt, Value)); } @@ -391,7 +390,7 @@ namespace driver { /// AddSeparateArg - Construct a new Positional arg for the given option /// \p Id, with the provided \p Value and append it to the argument /// list. - void AddSeparateArg(const Arg *BaseArg, const Option Opt, + void AddSeparateArg(const Arg *BaseArg, const Option *Opt, StringRef Value) { append(MakeSeparateArg(BaseArg, Opt, Value)); } @@ -399,28 +398,28 @@ namespace driver { /// AddJoinedArg - Construct a new Positional arg for the given option /// \p Id, with the provided \p Value and append it to the argument list. - void AddJoinedArg(const Arg *BaseArg, const Option Opt, + void AddJoinedArg(const Arg *BaseArg, const Option *Opt, StringRef Value) { append(MakeJoinedArg(BaseArg, Opt, Value)); } /// MakeFlagArg - Construct a new FlagArg for the given option \p Id. - Arg *MakeFlagArg(const Arg *BaseArg, const Option Opt) const; + Arg *MakeFlagArg(const Arg *BaseArg, const Option *Opt) const; /// MakePositionalArg - Construct a new Positional arg for the /// given option \p Id, with the provided \p Value. - Arg *MakePositionalArg(const Arg *BaseArg, const Option Opt, + Arg *MakePositionalArg(const Arg *BaseArg, const Option *Opt, StringRef Value) const; /// MakeSeparateArg - Construct a new Positional arg for the /// given option \p Id, with the provided \p Value. - Arg *MakeSeparateArg(const Arg *BaseArg, const Option Opt, + Arg *MakeSeparateArg(const Arg *BaseArg, const Option *Opt, StringRef Value) const; /// MakeJoinedArg - Construct a new Positional arg for the /// given option \p Id, with the provided \p Value. - Arg *MakeJoinedArg(const Arg *BaseArg, const Option Opt, + Arg *MakeJoinedArg(const Arg *BaseArg, const Option *Opt, StringRef Value) const; /// @} diff --git a/include/clang/Driver/OptTable.h b/include/clang/Driver/OptTable.h index 678d967659..ea7e57b12b 100644 --- a/include/clang/Driver/OptTable.h +++ b/include/clang/Driver/OptTable.h @@ -47,6 +47,15 @@ namespace driver { 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; + /// 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; @@ -58,6 +67,8 @@ namespace driver { return OptionInfos[id - 1]; } + Option *CreateOption(unsigned id) const; + protected: OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos); public: @@ -70,7 +81,17 @@ namespace driver { /// if necessary. /// /// \return The option, or null for the INVALID option id. - const Option getOption(OptSpecifier Opt) const; + 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; + } /// \brief Lookup the name of the given option. const char *getOptionName(OptSpecifier id) const { diff --git a/include/clang/Driver/Option.h b/include/clang/Driver/Option.h index 11e417149d..6fc8bef5da 100644 --- a/include/clang/Driver/Option.h +++ b/include/clang/Driver/Option.h @@ -21,20 +21,15 @@ namespace driver { class ArgList; namespace options { - /// Base flags for all options. Custom flags may be added after. enum DriverFlag { - HelpHidden = (1 << 0), - RenderAsInput = (1 << 1), - RenderJoined = (1 << 2), - RenderSeparate = (1 << 3) - }; - - /// Flags specifically for clang options. - enum ClangFlags { - DriverOption = (1 << 4), - LinkerInput = (1 << 5), - NoArgumentUnused = (1 << 6), - NoForward = (1 << 7), + 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) }; @@ -73,7 +68,7 @@ namespace options { RenderValuesStyle }; - protected: + private: const OptTable::Info *Info; const OptTable *Owner; @@ -81,38 +76,17 @@ namespace options { Option(const OptTable::Info *Info, const OptTable *Owner); ~Option(); - bool isValid() const { - return Info != 0; - } - - unsigned getID() const { - assert(Info && "Must have a valid info!"); - return Info->ID; - } - - OptionClass getKind() const { - assert(Info && "Must have a valid info!"); - return OptionClass(Info->Kind); - } - - StringRef getName() const { - assert(Info && "Must have a valid info!"); - return Info->Name; - } + unsigned getID() const { return Info->ID; } + OptionClass getKind() const { return OptionClass(Info->Kind); } + StringRef getName() const { return Info->Name; } + const Option *getGroup() const { return Owner->getOption(Info->GroupID); } + const Option *getAlias() const { return Owner->getOption(Info->AliasID); } - const Option getGroup() const { - assert(Info && "Must have a valid info!"); - assert(Owner && "Must have a valid owner!"); - return Owner->getOption(Info->GroupID); - } + unsigned getNumArgs() const { return Info->Param; } - const Option getAlias() const { - assert(Info && "Must have a valid info!"); - assert(Owner && "Must have a valid owner!"); - return Owner->getOption(Info->AliasID); - } + bool isUnsupported() const { return Info->Flags & options::Unsupported; } - unsigned getNumArgs() const { return Info->Param; } + bool isLinkerInput() const { return Info->Flags & options::LinkerInput; } bool hasNoOptAsInput() const { return Info->Flags & options::RenderAsInput;} @@ -140,23 +114,32 @@ namespace options { llvm_unreachable("Unexpected kind!"); } - /// Test if this option has the flag \a Val. - bool hasFlag(unsigned Val) const { - return Info->Flags & Val; + bool isDriverOption() const { return Info->Flags & options::DriverOption; } + + bool hasNoArgumentUnused() const { + return Info->Flags & options::NoArgumentUnused; + } + + bool hasNoForward() const { return Info->Flags & options::NoForward; } + + bool isCC1Option() const { return Info->Flags & options::CC1Option; } + + bool hasForwardToGCC() const { + return !hasNoForward() && !isDriverOption() && !isLinkerInput(); } /// getUnaliasedOption - Return the final option this option /// aliases (itself, if the option has no alias). - const Option getUnaliasedOption() const { - const Option Alias = getAlias(); - if (Alias.isValid()) return Alias.getUnaliasedOption(); - return *this; + const Option *getUnaliasedOption() const { + const Option *Alias = getAlias(); + if (Alias) return Alias->getUnaliasedOption(); + return this; } /// getRenderName - Return the name to use when rendering this /// option. StringRef getRenderName() const { - return getUnaliasedOption().getName(); + return getUnaliasedOption()->getName(); } /// matches - Predicate for whether this option is part of the |