blob: 11e7e4c8fe2bd596e971b72b499cc6cadfe00a71 [file] [log] [blame]
Nick Lewycky6da90772010-12-31 17:31:54 +00001//===--- DriverOptions.cpp - Driver Options Table -------------------------===//
Daniel Dunbaraa767372009-11-19 00:15:11 +00002//
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 Toppere5ce8312013-07-15 03:38:40 +000011#include "llvm/ADT/STLExtras.h"
Reid Kleckner898229a2013-06-14 17:17:23 +000012#include "llvm/Option/OptTable.h"
13#include "llvm/Option/Option.h"
Yuka Takahashi24bc6a42017-08-29 00:09:31 +000014#include <cassert>
Daniel Dunbaraa767372009-11-19 00:15:11 +000015
16using namespace clang::driver;
17using namespace clang::driver::options;
Reid Kleckner898229a2013-06-14 17:17:23 +000018using namespace llvm::opt;
Daniel Dunbaraa767372009-11-19 00:15:11 +000019
Hans Wennborgfb624ce2013-07-17 16:54:06 +000020#define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE;
Michael J. Spencer929fccd2012-10-22 22:13:48 +000021#include "clang/Driver/Options.inc"
Michael J. Spencer929fccd2012-10-22 22:13:48 +000022#undef PREFIX
23
Nuno Lopes221c1fd2009-12-10 00:07:02 +000024static const OptTable::Info InfoTable[] = {
Yuka Takahashiba5d4af2017-06-20 16:31:31 +000025#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 Dunbar46fffee2009-11-19 01:03:50 +000029#include "clang/Driver/Options.inc"
Hans Wennborgfb624ce2013-07-17 16:54:06 +000030#undef OPTION
Daniel Dunbaraa767372009-11-19 00:15:11 +000031};
32
33namespace {
34
35class DriverOptTable : public OptTable {
36public:
37 DriverOptTable()
Craig Topper2f6e21e2015-10-21 16:31:33 +000038 : OptTable(InfoTable) {}
Daniel Dunbaraa767372009-11-19 00:15:11 +000039};
40
41}
42
David Blaikie0aaa7622017-01-13 17:34:15 +000043std::unique_ptr<OptTable> clang::driver::createDriverOptTable() {
Yuka Takahashi24bc6a42017-08-29 00:09:31 +000044 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 Dunbaraa767372009-11-19 00:15:11 +000053}