OptSpecifier.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //===- OptSpecifier.h - Option Specifiers -----------------------*- C++ -*-===//
  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. #ifndef LLVM_OPTION_OPTSPECIFIER_H
  9. #define LLVM_OPTION_OPTSPECIFIER_H
  10. namespace llvm {
  11. namespace opt {
  12. class Option;
  13. /// OptSpecifier - Wrapper class for abstracting references to option IDs.
  14. class OptSpecifier {
  15. unsigned ID = 0;
  16. public:
  17. OptSpecifier() = default;
  18. explicit OptSpecifier(bool) = delete;
  19. /*implicit*/ OptSpecifier(unsigned ID) : ID(ID) {}
  20. /*implicit*/ OptSpecifier(const Option *Opt);
  21. bool isValid() const { return ID != 0; }
  22. unsigned getID() const { return ID; }
  23. bool operator==(OptSpecifier Opt) const { return ID == Opt.getID(); }
  24. bool operator!=(OptSpecifier Opt) const { return !(*this == Opt); }
  25. };
  26. } // end namespace opt
  27. } // end namespace llvm
  28. #endif // LLVM_OPTION_OPTSPECIFIER_H