36 const auto NonNrvoConstLocalVariable =
37 varDecl(hasLocalStorage(), unless(hasType(lValueReferenceType())),
38 unless(isNRVOVariable()),
41 hasCanonicalType(matchers::isExpensiveToCopy()),
42 unless(hasDeclaration(namedDecl(
48 const auto LValueRefCtor = cxxConstructorDecl(
49 hasParameter(0, hasType(hasCanonicalType(
50 lValueReferenceType(pointee(type().bind(
"SrcT")))))),
51 ofClass(cxxRecordDecl(hasMethod(cxxConstructorDecl(
52 hasParameter(0, hasType(hasCanonicalType(rValueReferenceType(
53 pointee(type(equalsBoundNode(
"SrcT"))))))))))));
57 const auto ConstRefRefCtor = cxxConstructorDecl(
60 hasType(rValueReferenceType(pointee(isConstQualified())))));
65 returnStmt(hasReturnValue(
66 ignoringElidableConstructorCall(ignoringParenImpCasts(
68 hasDeclaration(anyOf(LValueRefCtor, ConstRefRefCtor)),
71 ignoringParenImpCasts(declRefExpr(
72 to(NonNrvoConstLocalVariable),
73 unless(refersToEnclosingVariableOrCapture())))))
74 .bind(
"ctor_call")))))),
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.