diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-04 08:33:23 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-04 08:33:23 +0000 |
commit | 2c6f6f3c170502c5b810102cf85f05732a2aa9d0 (patch) | |
tree | 9b60aa209aa4ea9b4fd9bcb135871b86f8614758 /include/clang/Driver/Options.h | |
parent | 7f0f5dce3adcfce88d5c9a0ad0146a33c01a1e8f (diff) | |
download | clang-2c6f6f3c170502c5b810102cf85f05732a2aa9d0.tar.gz |
Driver: More Option implementation.
- Add Options.def file, collects option information.
- Actual option instantiation is handled lazily by OptTable to allow
the driver to not need to instantiate all options.
- cast<> support for Option, other minor tweaks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66028 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Driver/Options.h')
-rw-r--r-- | include/clang/Driver/Options.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/include/clang/Driver/Options.h b/include/clang/Driver/Options.h new file mode 100644 index 0000000000..ad737635c4 --- /dev/null +++ b/include/clang/Driver/Options.h @@ -0,0 +1,55 @@ +//===--- Options.h - Option info & table ------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_DRIVER_OPTIONS_H_ +#define CLANG_DRIVER_OPTIONS_H_ + +namespace clang { +namespace driver { +namespace options { + enum ID { + NotOption = 0, // This is not an option ID. +#define OPTION(ID, KIND, NAME, GROUP, ALIAS, FLAGS, PARAM) ID, +#include "clang/Driver/Options.def" + LastOption +#undef OPTION + }; +} + + class Option; + + /// OptTable - Provide access to the Option info table. + /// + /// The OptTable class provides a layer of indirection which allows + /// Option instance to be created lazily. In the common case, only a + /// few options will be needed at runtime; the OptTable class + /// maintains enough information to parse command lines without + /// instantiating Options, while letting other parts of the driver + /// still use Option instances where convient. + class OptTable { + mutable Option **Options; + + Option *constructOption(options::ID id) const; + + public: + OptTable(); + ~OptTable(); + + unsigned getNumOptions() const; + + const char *getOptionName(options::ID id) const; + + /// getOption - Get the given \arg id's Option instance, lazily + /// creating it if necessary. + const Option *getOption(options::ID id) const; + }; +} +} + +#endif |