@@ -85,21 +85,26 @@ void OptionalValueConversionCheck::registerMatchers(MatchFinder *Finder) {
8585 // known template methods in std
8686 callExpr (
8787 argumentCountIs (1 ),
88- callee (functionDecl (
89- matchers::matchesAnyListedName (MakeSmartPtrList),
90- hasTemplateArgument (0 , refersToType (BindOptionalType)))),
88+ anyOf (
89+ // match std::make_unique std::make_shared
90+ callee (functionDecl (
91+ matchers::matchesAnyListedName (MakeSmartPtrList),
92+ hasTemplateArgument (
93+ 0 , refersToType (BindOptionalType)))),
94+ // match first std::make_optional by limit argument count
95+ // (1) and template count (1).
96+ // 1. template< class T > constexpr
97+ // std::optional<decay_t<T>> make_optional(T&& value);
98+ // 2. template< class T, class... Args > constexpr
99+ // std::optional<T> make_optional(Args&&... args);
100+ callee (functionDecl (templateArgumentCountIs (1 ),
101+ hasName (MakeOptional),
102+ returns (BindOptionalType)))),
91103 hasArgument (0 , OptionalDerefMatcher)),
92104 callExpr (
93- // match first std::make_optional by limit argument count (1)
94- // and template count (1).
95- // 1. template< class T > constexpr
96- // std::optional<decay_t<T>> make_optional(T&& value);
97- // 2. template< class T, class... Args > constexpr
98- // std::optional<T> make_optional(Args&&... args);
105+
99106 argumentCountIs (1 ),
100- callee (functionDecl (templateArgumentCountIs (1 ),
101- hasName (MakeOptional),
102- returns (BindOptionalType))),
107+
103108 hasArgument (0 , OptionalDerefMatcher))),
104109 unless (anyOf (hasAncestor (typeLoc ()),
105110 hasAncestor (expr (matchers::hasUnevaluatedContext ())))))
0 commit comments