================
@@ -415,4 +416,31 @@ bool isCopyAssignmentArgument(const DeclRefExpr &DeclRef,
const Decl &Decl,
return !Matches.empty();
}
+bool isPerfectlyForwardedArgument(const DeclRefExpr &DeclRef, const Decl &Decl,
+ ASTContext &Context) {
+ auto UsedAsArg = forEachArgumentWithParam(
+ ignoringParenImpCasts(declRefExpr(equalsNode(&DeclRef))),
+ parmVarDecl().bind("param"));
+ auto Matches =
+ match(decl(hasDescendant(invocation(UsedAsArg).bind("invocationExpr"))),
+ Decl, Context);
+ return std::any_of(Matches.begin(), Matches.end(), [](const auto &M) {
+ if (const auto *P = M.template getNodeAs<ParmVarDecl>("param")) {
+ if (P->getType()->isRValueReferenceType())
+ return true;
----------------
HerrCai0907 wrote:
when P is rvalue ref, it is also possible that P is a normal `T&&` instead of
perfectly forwarded argument
https://github.com/llvm/llvm-project/pull/180806
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits