DriverOptions.cpp 1.7 KB

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