@@ -127,74 +127,6 @@ PolySubsequenceMatcher<Args...> HasSubsequence(Args &&... M) {
127
127
llvm::consumeError (ComputedValue.takeError ()); \
128
128
} while (false )
129
129
130
- // Implements the HasValue(m) matcher for matching an Optional whose
131
- // value matches matcher m.
132
- template <typename InnerMatcher> class OptionalMatcher {
133
- public:
134
- explicit OptionalMatcher (const InnerMatcher &matcher) : matcher_(matcher) {}
135
- OptionalMatcher (const OptionalMatcher&) = default ;
136
- OptionalMatcher &operator =(const OptionalMatcher&) = delete ;
137
-
138
- // This type conversion operator template allows Optional(m) to be
139
- // used as a matcher for any Optional type whose value type is
140
- // compatible with the inner matcher.
141
- //
142
- // The reason we do this instead of relying on
143
- // MakePolymorphicMatcher() is that the latter is not flexible
144
- // enough for implementing the DescribeTo() method of Optional().
145
- template <typename Optional> operator Matcher<Optional>() const {
146
- return MakeMatcher (new Impl<Optional>(matcher_));
147
- }
148
-
149
- private:
150
- // The monomorphic implementation that works for a particular optional type.
151
- template <typename Optional>
152
- class Impl : public ::testing::MatcherInterface<Optional> {
153
- public:
154
- using Value = typename std::remove_const<
155
- typename std::remove_reference<Optional>::type>::type::value_type;
156
-
157
- explicit Impl (const InnerMatcher &matcher)
158
- : matcher_(::testing::MatcherCast<const Value &>(matcher)) {}
159
-
160
- Impl (const Impl&) = default ;
161
- Impl &operator =(const Impl&) = delete ;
162
-
163
- virtual void DescribeTo (::std::ostream *os) const {
164
- *os << " has a value that " ;
165
- matcher_.DescribeTo (os);
166
- }
167
-
168
- virtual void DescribeNegationTo (::std::ostream *os) const {
169
- *os << " does not have a value that " ;
170
- matcher_.DescribeTo (os);
171
- }
172
-
173
- virtual bool
174
- MatchAndExplain (Optional optional,
175
- ::testing::MatchResultListener *listener) const {
176
- if (!optional)
177
- return false ;
178
-
179
- *listener << " which has a value " ;
180
- return MatchPrintAndExplain (*optional, matcher_, listener);
181
- }
182
-
183
- private:
184
- const Matcher<const Value &> matcher_;
185
- };
186
-
187
- const InnerMatcher matcher_;
188
- };
189
-
190
- // Creates a matcher that matches an Optional that has a value
191
- // that matches inner_matcher.
192
- template <typename InnerMatcher>
193
- inline OptionalMatcher<InnerMatcher>
194
- HasValue (const InnerMatcher &inner_matcher) {
195
- return OptionalMatcher<InnerMatcher>(inner_matcher);
196
- }
197
-
198
130
} // namespace clangd
199
131
} // namespace clang
200
132
#endif
0 commit comments