DriverOptions.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 OPTTABLE_VALUES_CODE
  17. #include "clang/Driver/Options.inc"
  18. #undef OPTTABLE_VALUES_CODE
  19. #define PREFIX(NAME, VALUE) \
  20. static constexpr llvm::StringLiteral NAME##_init[] = VALUE; \
  21. static constexpr llvm::ArrayRef<llvm::StringLiteral> NAME( \
  22. NAME##_init, std::size(NAME##_init) - 1);
  23. #include "clang/Driver/Options.inc"
  24. #undef PREFIX
  25. static constexpr const llvm::StringLiteral PrefixTable_init[] =
  26. #define PREFIX_UNION(VALUES) VALUES
  27. #include "clang/Driver/Options.inc"
  28. #undef PREFIX_UNION
  29. ;
  30. static constexpr const llvm::ArrayRef<llvm::StringLiteral>
  31. PrefixTable(PrefixTable_init, std::size(PrefixTable_init) - 1);
  32. static constexpr OptTable::Info InfoTable[] = {
  33. #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
  34. HELPTEXT, METAVAR, VALUES) \
  35. {PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, \
  36. PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES},
  37. #include "clang/Driver/Options.inc"
  38. #undef OPTION
  39. };
  40. namespace {
  41. class DriverOptTable : public PrecomputedOptTable {
  42. public:
  43. DriverOptTable() : PrecomputedOptTable(InfoTable, PrefixTable) {}
  44. };
  45. }
  46. const llvm::opt::OptTable &clang::driver::getDriverOptTable() {
  47. static DriverOptTable Table;
  48. return Table;
  49. }