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
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 680d735..c72eca2 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -256,6 +256,27 @@
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'");