================ @@ -104,14 +104,16 @@ AST_MATCHER_FUNCTION_P(StatementMatcher, hasArgument(0, hasType(ReceiverType))))); } +AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); } + AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) { // Only allow initialization of a const reference from a free function if it // has no arguments. Otherwise it could return an alias to one of its // arguments and the arguments need to be checked for const use as well. return callExpr(callee(functionDecl(returns(hasCanonicalType( matchers::isReferenceToConst()))) .bind(FunctionDeclId)), - argumentCountIs(0), unless(callee(cxxMethodDecl()))) + argumentCountIs(0), unless(callee(cxxMethodDecl(unless(isStatic()))))) ---------------- 5chmidti wrote:
Please change `of a free function` to `from a call to a free function or static member function` in the comment above. You can also move the check for the method and static inward: ``` callExpr(callee(functionDecl(returns(hasCanonicalType(matchers::isReferenceToConst())), unless(cxxMethodDecl(unless(isStatic())))) .bind(FunctionDeclId)), argumentCountIs(0)) ``` Unrelated to this PR, but if you reorder anyway: please move the `argumentCountIs` to the front inside `callExpr`. https://github.com/llvm/llvm-project/pull/119974 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits