@@ -85,21 +85,26 @@ void OptionalValueConversionCheck::registerMatchers(MatchFinder *Finder) {
85
85
// known template methods in std
86
86
callExpr (
87
87
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)))),
91
103
hasArgument (0 , OptionalDerefMatcher)),
92
104
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
+
99
106
argumentCountIs (1 ),
100
- callee (functionDecl (templateArgumentCountIs (1 ),
101
- hasName (MakeOptional),
102
- returns (BindOptionalType))),
107
+
103
108
hasArgument (0 , OptionalDerefMatcher))),
104
109
unless (anyOf (hasAncestor (typeLoc ()),
105
110
hasAncestor (expr (matchers::hasUnevaluatedContext ())))))
0 commit comments