xref: /freebsd/contrib/llvm-project/llvm/include/llvm/Option/OptSpecifier.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
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 
9 #ifndef LLVM_OPTION_OPTSPECIFIER_H
10 #define LLVM_OPTION_OPTSPECIFIER_H
11 
12 #include "llvm/Support/Compiler.h"
13 
14 namespace llvm {
15 namespace opt {
16 
17 class Option;
18 
19 /// OptSpecifier - Wrapper class for abstracting references to option IDs.
20 class OptSpecifier {
21   unsigned ID = 0;
22 
23 public:
24   OptSpecifier() = default;
25   explicit OptSpecifier(bool) = delete;
OptSpecifier(unsigned ID)26   /*implicit*/ OptSpecifier(unsigned ID) : ID(ID) {}
27   /*implicit*/ LLVM_ABI OptSpecifier(const Option *Opt);
28 
isValid()29   bool isValid() const { return ID != 0; }
30 
getID()31   unsigned getID() const { return ID; }
32 
33   bool operator==(OptSpecifier Opt) const { return ID == Opt.getID(); }
34   bool operator!=(OptSpecifier Opt) const { return !(*this == Opt); }
35 };
36 
37 } // end namespace opt
38 } // end namespace llvm
39 
40 #endif // LLVM_OPTION_OPTSPECIFIER_H
41