Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Many matchers define convenience wrappers for both string-like types and for `::testing::Matcher<string>`, where the wrappers for string-like types instantiates our own internal `NameMatcher` that gives nice messages specific to IR names. Because string-like types are also convertible to `::testing::Matcher<string>`, this often led to cases where the overload was ambiguous. This change defines wrappers using the following pattern: ``` template <typename T> inline ::testing::Matcher<Node*> Wrapper(..., T name, ...) requires(std::is_convertible_v<T, std::string_view>) { return WrappedMatcher(..., internal::NameMatcher(std::string_view{T}), ...); } ``` resolving the ambiguous overload to prefer using the `NameMatcher`. Also, we remove many cases where an argument had `std::optional<T> arg = std::nullopt` and instead make an overload with `T` and another overload without the argument to aid template deduction. For `FunctionBase` matchers we tweak how `MatchAndExplain()` are defined for bare pointers (don't need to be templated) vs. `std::unique_ptr<>` (template them on `std::is_base_of<FunctionBase, T>`). PiperOrigin-RevId: 611554596
- Loading branch information