OptSpecifier.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- OptSpecifier.h - Option Specifiers -----------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_OPTION_OPTSPECIFIER_H
  14. #define LLVM_OPTION_OPTSPECIFIER_H
  15. namespace llvm {
  16. namespace opt {
  17. class Option;
  18. /// OptSpecifier - Wrapper class for abstracting references to option IDs.
  19. class OptSpecifier {
  20. unsigned ID = 0;
  21. public:
  22. OptSpecifier() = default;
  23. explicit OptSpecifier(bool) = delete;
  24. /*implicit*/ OptSpecifier(unsigned ID) : ID(ID) {}
  25. /*implicit*/ OptSpecifier(const Option *Opt);
  26. bool isValid() const { return ID != 0; }
  27. unsigned getID() const { return ID; }
  28. bool operator==(OptSpecifier Opt) const { return ID == Opt.getID(); }
  29. bool operator!=(OptSpecifier Opt) const { return !(*this == Opt); }
  30. };
  31. } // end namespace opt
  32. } // end namespace llvm
  33. #endif // LLVM_OPTION_OPTSPECIFIER_H
  34. #ifdef __GNUC__
  35. #pragma GCC diagnostic pop
  36. #endif