Nick Lewycky | 6da9077 | 2010-12-31 17:31:54 +0000 | [diff] [blame] | 1 | //===--- DriverOptions.cpp - Driver Options Table -------------------------===// |
Daniel Dunbar | aa76737 | 2009-11-19 00:15:11 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "clang/Driver/Options.h" |
Craig Topper | e5ce831 | 2013-07-15 03:38:40 +0000 | [diff] [blame] | 11 | #include "llvm/ADT/STLExtras.h" |
Reid Kleckner | 898229a | 2013-06-14 17:17:23 +0000 | [diff] [blame] | 12 | #include "llvm/Option/OptTable.h" |
| 13 | #include "llvm/Option/Option.h" |
Yuka Takahashi | 24bc6a4 | 2017-08-29 00:09:31 +0000 | [diff] [blame] | 14 | #include <cassert> |
Daniel Dunbar | aa76737 | 2009-11-19 00:15:11 +0000 | [diff] [blame] | 15 | |
| 16 | using namespace clang::driver; |
| 17 | using namespace clang::driver::options; |
Reid Kleckner | 898229a | 2013-06-14 17:17:23 +0000 | [diff] [blame] | 18 | using namespace llvm::opt; |
Daniel Dunbar | aa76737 | 2009-11-19 00:15:11 +0000 | [diff] [blame] | 19 | |
Hans Wennborg | fb624ce | 2013-07-17 16:54:06 +0000 | [diff] [blame] | 20 | #define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE; |
Michael J. Spencer | 929fccd | 2012-10-22 22:13:48 +0000 | [diff] [blame] | 21 | #include "clang/Driver/Options.inc" |
Michael J. Spencer | 929fccd | 2012-10-22 22:13:48 +0000 | [diff] [blame] | 22 | #undef PREFIX |
| 23 | |
Nuno Lopes | 221c1fd | 2009-12-10 00:07:02 +0000 | [diff] [blame] | 24 | static const OptTable::Info InfoTable[] = { |
Yuka Takahashi | ba5d4af | 2017-06-20 16:31:31 +0000 | [diff] [blame] | 25 | #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ |
| 26 | HELPTEXT, METAVAR, VALUES) \ |
| 27 | {PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, \ |
| 28 | PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES}, |
Daniel Dunbar | 46fffee | 2009-11-19 01:03:50 +0000 | [diff] [blame] | 29 | #include "clang/Driver/Options.inc" |
Hans Wennborg | fb624ce | 2013-07-17 16:54:06 +0000 | [diff] [blame] | 30 | #undef OPTION |
Daniel Dunbar | aa76737 | 2009-11-19 00:15:11 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | namespace { |
| 34 | |
| 35 | class DriverOptTable : public OptTable { |
| 36 | public: |
| 37 | DriverOptTable() |
Craig Topper | 2f6e21e | 2015-10-21 16:31:33 +0000 | [diff] [blame] | 38 | : OptTable(InfoTable) {} |
Daniel Dunbar | aa76737 | 2009-11-19 00:15:11 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | } |
| 42 | |
David Blaikie | 0aaa762 | 2017-01-13 17:34:15 +0000 | [diff] [blame] | 43 | std::unique_ptr<OptTable> clang::driver::createDriverOptTable() { |
Yuka Takahashi | 24bc6a4 | 2017-08-29 00:09:31 +0000 | [diff] [blame] | 44 | auto Result = llvm::make_unique<DriverOptTable>(); |
| 45 | // Options.inc is included in DriverOptions.cpp, and calls OptTable's |
| 46 | // addValues function. |
| 47 | // Opt is a variable used in the code fragment in Options.inc. |
| 48 | OptTable &Opt = *Result; |
| 49 | #define OPTTABLE_ARG_INIT |
| 50 | #include "clang/Driver/Options.inc" |
| 51 | #undef OPTTABLE_ARG_INIT |
| 52 | return std::move(Result); |
Daniel Dunbar | aa76737 | 2009-11-19 00:15:11 +0000 | [diff] [blame] | 53 | } |