[clang] [clang] Fix handling of explicit-`this` functions as template arguments (PR #133748)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 31 14:10:51 PDT 2025
================
@@ -7558,6 +7558,18 @@ ExprResult Sema::BuildExpressionFromDeclTemplateArgument(
} else {
assert(ParamType->isReferenceType() &&
"unexpected type for decl template argument");
+
+ if (auto *Method = dyn_cast<CXXMethodDecl>(VD);
+ Method && Method->isExplicitObjectMemberFunction()) {
+ // If the argument is an explicit object member function,
+ // RefExpr is currently a prvalue. Make it an lvalue.
+ RefExpr = ImplicitCastExpr::Create(
+ Context, RefExpr.get()->getType(), CK_NoOp, RefExpr.get(),
----------------
efriedma-quic wrote:
I don't think CK_NoOp is the right CastKind, even if it appears to work for simple cases. Either we should just use UO_Deref, or we should create a new CastKind.
https://github.com/llvm/llvm-project/pull/133748
More information about the cfe-commits
mailing list