[cfe-commits] r83268 - /cfe/trunk/lib/Sema/SemaExpr.cpp

Anders Carlsson andersca at mac.com
Sat Oct 3 10:40:22 PDT 2009


Author: andersca
Date: Sat Oct  3 12:40:22 2009
New Revision: 83268

URL: http://llvm.org/viewvc/llvm-project?rev=83268&view=rev
Log:
Create CXXMemberCallExpr for pointer-to-member calls.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=83268&r1=83267&r2=83268&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Oct  3 12:40:22 2009
@@ -2902,6 +2902,28 @@
         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<BinaryOperator>(Fn->IgnoreParens())) {
+      if (BO->getOpcode() == BinaryOperator::PtrMemD ||
+          BO->getOpcode() == BinaryOperator::PtrMemI) {
+        const FunctionProtoType *FPT = cast<FunctionProtoType>(BO->getType());
+        QualType ReturnTy = FPT->getResultType();
+      
+        CXXMemberCallExpr *CE = 
+          new (Context) CXXMemberCallExpr(Context, BO, Args, NumArgs,
+                                          ReturnTy.getNonReferenceType(),
+                                          RParenLoc);
+        
+        ExprOwningPtr<CXXMemberCallExpr> 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.





More information about the cfe-commits mailing list