@@ -27,27 +27,26 @@ AST_MATCHER_P(QualType, hasCleanType, Matcher<QualType>, InnerMatcher) {
2727 Finder, Builder);
2828}
2929
30- AST_MATCHER_P2 (Expr, constructFrom, Matcher<QualType>, TypeMatcher,
31- Matcher<Expr>, ArgumentMatcher) {
32- std::array<StringRef, 2 > NameList{
33- " ::std::make_unique" ,
34- " ::std::make_shared" ,
35- };
36- return expr (anyOf (
37- // construct optional
38- cxxConstructExpr (argumentCountIs (1U ), hasType (TypeMatcher),
39- hasArgument (0U , ArgumentMatcher)),
40- // known template methods in std
41- callExpr (
42- argumentCountIs (1 ),
43- callee (functionDecl (
44- matchers::matchesAnyListedName (NameList),
45- hasTemplateArgument (0 , refersToType (TypeMatcher)))),
46- hasArgument (0 , ArgumentMatcher))),
47- unless (
48- anyOf (hasAncestor (typeLoc ()),
49- hasAncestor (expr (matchers::hasUnevaluatedContext ())))))
50- .matches (Node, Finder, Builder);
30+ constexpr std::array<StringRef, 2 > NameList{
31+ " ::std::make_unique" ,
32+ " ::std::make_shared" ,
33+ };
34+
35+ Matcher<Expr> constructFrom (Matcher<QualType> TypeMatcher,
36+ Matcher<Expr> ArgumentMatcher) {
37+ return expr (
38+ anyOf (
39+ // construct optional
40+ cxxConstructExpr (argumentCountIs (1U ), hasType (TypeMatcher),
41+ hasArgument (0U , ArgumentMatcher)),
42+ // known template methods in std
43+ callExpr (argumentCountIs (1 ),
44+ callee (functionDecl (
45+ matchers::matchesAnyListedName (NameList),
46+ hasTemplateArgument (0 , refersToType (TypeMatcher)))),
47+ hasArgument (0 , ArgumentMatcher))),
48+ unless (anyOf (hasAncestor (typeLoc ()),
49+ hasAncestor (expr (matchers::hasUnevaluatedContext ())))));
5150}
5251
5352} // namespace
0 commit comments