DriverOptions.cpp revision 1.1 1 1.1 joerg //===--- DriverOptions.cpp - Driver Options Table -------------------------===//
2 1.1 joerg //
3 1.1 joerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 1.1 joerg // See https://llvm.org/LICENSE.txt for license information.
5 1.1 joerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 1.1 joerg //
7 1.1 joerg //===----------------------------------------------------------------------===//
8 1.1 joerg
9 1.1 joerg #include "clang/Driver/Options.h"
10 1.1 joerg #include "llvm/ADT/STLExtras.h"
11 1.1 joerg #include "llvm/Option/OptTable.h"
12 1.1 joerg #include "llvm/Option/Option.h"
13 1.1 joerg #include <cassert>
14 1.1 joerg
15 1.1 joerg using namespace clang::driver;
16 1.1 joerg using namespace clang::driver::options;
17 1.1 joerg using namespace llvm::opt;
18 1.1 joerg
19 1.1 joerg #define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE;
20 1.1 joerg #include "clang/Driver/Options.inc"
21 1.1 joerg #undef PREFIX
22 1.1 joerg
23 1.1 joerg static const OptTable::Info InfoTable[] = {
24 1.1 joerg #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
25 1.1 joerg HELPTEXT, METAVAR, VALUES) \
26 1.1 joerg {PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, \
27 1.1 joerg PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES},
28 1.1 joerg #include "clang/Driver/Options.inc"
29 1.1 joerg #undef OPTION
30 1.1 joerg };
31 1.1 joerg
32 1.1 joerg namespace {
33 1.1 joerg
34 1.1 joerg class DriverOptTable : public OptTable {
35 1.1 joerg public:
36 1.1 joerg DriverOptTable()
37 1.1 joerg : OptTable(InfoTable) {}
38 1.1 joerg };
39 1.1 joerg
40 1.1 joerg }
41 1.1 joerg
42 1.1 joerg const llvm::opt::OptTable &clang::driver::getDriverOptTable() {
43 1.1 joerg static const DriverOptTable *Table = []() {
44 1.1 joerg auto Result = std::make_unique<DriverOptTable>();
45 1.1 joerg // Options.inc is included in DriverOptions.cpp, and calls OptTable's
46 1.1 joerg // addValues function.
47 1.1 joerg // Opt is a variable used in the code fragment in Options.inc.
48 1.1 joerg OptTable &Opt = *Result;
49 1.1 joerg #define OPTTABLE_ARG_INIT
50 1.1 joerg #include "clang/Driver/Options.inc"
51 1.1 joerg #undef OPTTABLE_ARG_INIT
52 1.1 joerg return Result.release();
53 1.1 joerg }();
54 1.1 joerg return *Table;
55 1.1 joerg }
56