From 83ccfc3cf035fae158358776910b617a188471c7 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 3 Oct 2009 17:40:22 +0000 Subject: [PATCH] Create CXXMemberCallExpr for pointer-to-member calls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83268 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 7b7ee820c5..e7b074b43c 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2902,6 +2902,28 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc, return Owned(BuildCallToMemberFunction(S, Fn, LParenLoc, Args, NumArgs, CommaLocs, RParenLoc)); } + + // Determine whether this is a call to a pointer-to-member function. + if (BinaryOperator *BO = dyn_cast(Fn->IgnoreParens())) { + if (BO->getOpcode() == BinaryOperator::PtrMemD || + BO->getOpcode() == BinaryOperator::PtrMemI) { + const FunctionProtoType *FPT = cast(BO->getType()); + QualType ReturnTy = FPT->getResultType(); + + CXXMemberCallExpr *CE = + new (Context) CXXMemberCallExpr(Context, BO, Args, NumArgs, + ReturnTy.getNonReferenceType(), + RParenLoc); + + ExprOwningPtr TheCall(this, CE); + + if (ConvertArgumentsForCall(&*TheCall, BO, 0, FPT, Args, NumArgs, + RParenLoc)) + return ExprError(); + + return Owned(MaybeBindToTemporary(TheCall.release()).release()); + } + } } // If we're directly calling a function, get the appropriate declaration. -- 2.40.0