aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Driver/OptTable.h
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2012-10-10 22:34:46 +0000
committerEric Christopher <echristo@gmail.com>2012-10-10 22:34:46 +0000
commitbc0a925caac5e1a8201af4e8500da0bc4bd4d955 (patch)
tree6ba6d4f23fa33ad660c27edbd9ad7e15ea2b2229 /include/clang/Driver/OptTable.h
parent0464fd5e4ce2193e786e5adcab6b828f9366dae3 (diff)
Revert "[Options] make Option a value type."
Author: Michael J. Spencer <bigcheesegs@gmail.com> Date: Wed Oct 10 21:48:26 2012 +0000 [Options] make Option a value type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165663 91177308-0d34-0410-b5e6-96231b3b80d8 This reverts commit 0464fd5e4ce2193e786e5adcab6b828f9366dae3. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165667 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Driver/OptTable.h')
-rw-r--r--include/clang/Driver/OptTable.h23
1 files changed, 22 insertions, 1 deletions
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 {