@@ -50,45 +50,46 @@ class OptionSet {
50
50
51
51
public:
52
52
// / Create an empty option set.
53
- OptionSet () : Storage() { }
53
+ constexpr OptionSet () : Storage() {}
54
54
55
55
// / Create an empty option set.
56
- OptionSet (llvm::NoneType) : Storage() { }
56
+ constexpr OptionSet (llvm::NoneType) : Storage() {}
57
57
58
58
// / Create an option set with only the given option set.
59
- OptionSet (Flags flag) : Storage(static_cast <StorageType>(flag)) { }
59
+ constexpr OptionSet (Flags flag) : Storage(static_cast <StorageType>(flag)) {}
60
60
61
61
// / Create an option set from raw storage.
62
- explicit OptionSet (StorageType storage) : Storage(storage) { }
62
+ explicit constexpr OptionSet (StorageType storage) : Storage(storage) {}
63
63
64
64
// / Check whether an option set is non-empty.
65
- explicit operator bool () const { return Storage != 0 ; }
65
+ explicit constexpr operator bool () const { return Storage != 0 ; }
66
66
67
67
// / Explicitly convert an option set to its underlying storage.
68
- explicit operator StorageType () const { return Storage; }
68
+ explicit constexpr operator StorageType () const { return Storage; }
69
69
70
70
// / Explicitly convert an option set to intptr_t, for use in
71
71
// / llvm::PointerIntPair.
72
72
// /
73
73
// / This member is not present if the underlying type is bigger than
74
74
// / a pointer.
75
75
template <typename T = std::intptr_t >
76
- explicit operator typename std::enable_if<sizeof (StorageType) <= sizeof (T),
77
- std::intptr_t >::type () const {
76
+ explicit constexpr
77
+ operator typename std::enable_if<sizeof (StorageType) <= sizeof (T),
78
+ std::intptr_t >::type() const {
78
79
return static_cast <intptr_t >(Storage);
79
80
}
80
81
81
82
// / Retrieve the "raw" representation of this option set.
82
83
StorageType toRaw () const { return Storage; }
83
-
84
+
84
85
// / Determine whether this option set contains all of the options in the
85
86
// / given set.
86
- bool contains (OptionSet set) const {
87
+ constexpr bool contains (OptionSet set) const {
87
88
return !static_cast <bool >(set - *this );
88
89
}
89
90
90
91
// / Check if this option set contains the exact same options as the given set.
91
- bool containsOnly (OptionSet set) const {
92
+ constexpr bool containsOnly (OptionSet set) const {
92
93
return Storage == set.Storage ;
93
94
}
94
95
@@ -97,34 +98,34 @@ class OptionSet {
97
98
// want '==' behavior, use 'containsOnly'.
98
99
99
100
// / Produce the union of two option sets.
100
- friend OptionSet operator |(OptionSet lhs, OptionSet rhs) {
101
+ friend constexpr OptionSet operator |(OptionSet lhs, OptionSet rhs) {
101
102
return OptionSet (lhs.Storage | rhs.Storage );
102
103
}
103
104
104
105
// / Produce the union of two option sets.
105
- friend OptionSet &operator |=(OptionSet &lhs, OptionSet rhs) {
106
+ friend constexpr OptionSet &operator |=(OptionSet &lhs, OptionSet rhs) {
106
107
lhs.Storage |= rhs.Storage ;
107
108
return lhs;
108
- }
109
+ }
109
110
110
111
// / Produce the intersection of two option sets.
111
- friend OptionSet operator &(OptionSet lhs, OptionSet rhs) {
112
+ friend constexpr OptionSet operator &(OptionSet lhs, OptionSet rhs) {
112
113
return OptionSet (lhs.Storage & rhs.Storage );
113
114
}
114
115
115
116
// / Produce the intersection of two option sets.
116
- friend OptionSet &operator &=(OptionSet &lhs, OptionSet rhs) {
117
+ friend constexpr OptionSet &operator &=(OptionSet &lhs, OptionSet rhs) {
117
118
lhs.Storage &= rhs.Storage ;
118
119
return lhs;
119
120
}
120
121
121
122
// / Produce the difference of two option sets.
122
- friend OptionSet operator -(OptionSet lhs, OptionSet rhs) {
123
+ friend constexpr OptionSet operator -(OptionSet lhs, OptionSet rhs) {
123
124
return OptionSet (lhs.Storage & ~rhs.Storage );
124
125
}
125
126
126
127
// / Produce the difference of two option sets.
127
- friend OptionSet &operator -=(OptionSet &lhs, OptionSet rhs) {
128
+ friend constexpr OptionSet &operator -=(OptionSet &lhs, OptionSet rhs) {
128
129
lhs.Storage &= ~rhs.Storage ;
129
130
return lhs;
130
131
}
0 commit comments