diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-08-26 23:31:30 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-08-26 23:31:30 +0000 |
commit | 64e690ecf7ba7ad560b0af631bb6f323c38f6da4 (patch) | |
tree | 4b06e8af2201f522ef3c8ea417ef71965ac076c7 /lib/CodeGen/CGCXX.cpp | |
parent | e9f8eb64ed2d41c23db4a9774768613d4e07a865 (diff) |
ir-gen for type convesion of class objects. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80178 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 680d7357b9..c72eca278c 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -256,6 +256,27 @@ CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, E->arg_begin() + 1, E->arg_end()); } +RValue +CodeGenFunction::EmitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *E) { + assert((E->getCastKind() == CastExpr::CK_UserDefinedConversion) && + "EmitCXXFunctionalCastExpr - called with wrong cast"); + + CXXMethodDecl *MD = E->getTypeConversionMethod(); + const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType(); + llvm::Constant *Callee; + if (CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(MD)) + Callee = CGM.GetAddrOfCXXConstructor(CD, Ctor_Complete); + else { + const llvm::Type *Ty = + CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD), + FPT->isVariadic()); + Callee = CGM.GetAddrOfFunction(GlobalDecl(MD), Ty); + } + llvm::Value *This = EmitLValue(E->getSubExpr()).getAddress(); + + return EmitCXXMemberCall(MD, Callee, This, 0, 0); +} + llvm::Value *CodeGenFunction::LoadCXXThis() { assert(isa<CXXMethodDecl>(CurFuncDecl) && "Must be in a C++ member function decl to load 'this'"); |