32 const auto NonNrvoConstLocalVariable =
33 varDecl(hasLocalStorage(), unless(hasType(lValueReferenceType())),
34 unless(isNRVOVariable()),
37 hasCanonicalType(matchers::isExpensiveToCopy()),
38 unless(hasDeclaration(namedDecl(
44 const auto LValueRefCtor = cxxConstructorDecl(
45 hasParameter(0, hasType(hasCanonicalType(
46 lValueReferenceType(pointee(type().bind(
"SrcT")))))),
47 ofClass(cxxRecordDecl(hasMethod(cxxConstructorDecl(
48 hasParameter(0, hasType(hasCanonicalType(rValueReferenceType(
49 pointee(type(equalsBoundNode(
"SrcT"))))))))))));
53 const auto ConstRefRefCtor = cxxConstructorDecl(
56 hasType(rValueReferenceType(pointee(isConstQualified())))));
61 returnStmt(hasReturnValue(
62 ignoringElidableConstructorCall(ignoringParenImpCasts(
64 hasDeclaration(anyOf(LValueRefCtor, ConstRefRefCtor)),
65 hasArgument(0, ignoringParenImpCasts(declRefExpr(
66 to(NonNrvoConstLocalVariable)))))
67 .bind(
"ctor_call")))))),
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.