mirror of
https://github.com/intel/llvm.git
synced 2026-02-01 17:07:36 +08:00
ir-gen for type convesion of class objects. WIP.
llvm-svn: 80178
This commit is contained in:
@@ -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'");
|
||||
|
||||
@@ -177,7 +177,12 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
|
||||
LValue::MakeAddr(CastPtr, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
if (E->getCastKind() == CastExpr::CK_UserDefinedConversion) {
|
||||
CXXFunctionalCastExpr *CXXFExpr = cast<CXXFunctionalCastExpr>(E);
|
||||
CGF.EmitCXXFunctionalCastExpr(CXXFExpr);
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: Remove the CK_Unknown check here.
|
||||
assert((E->getCastKind() == CastExpr::CK_NoOp ||
|
||||
E->getCastKind() == CastExpr::CK_Unknown) &&
|
||||
|
||||
@@ -227,6 +227,11 @@ public:
|
||||
return llvm::Constant::getNullValue(ConvertType(E->getType()));
|
||||
}
|
||||
Value *VisitCastExpr(const CastExpr *E) {
|
||||
if (E->getCastKind() == CastExpr::CK_UserDefinedConversion) {
|
||||
const CXXFunctionalCastExpr *CXXFExpr = cast<CXXFunctionalCastExpr>(E);
|
||||
return CGF.EmitCXXFunctionalCastExpr(CXXFExpr).getScalarVal();
|
||||
}
|
||||
|
||||
// Make sure to evaluate VLA bounds now so that we have them for later.
|
||||
if (E->getType()->isVariablyModifiedType())
|
||||
CGF.EmitVLASize(E->getType());
|
||||
|
||||
@@ -838,6 +838,8 @@ public:
|
||||
RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E,
|
||||
const CXXMethodDecl *MD);
|
||||
|
||||
RValue EmitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *E);
|
||||
|
||||
RValue EmitBuiltinExpr(const FunctionDecl *FD,
|
||||
unsigned BuiltinID, const CallExpr *E);
|
||||
|
||||
|
||||
@@ -789,6 +789,10 @@ TryStaticImplicitCast(Sema &Self, Expr *SrcExpr, QualType DestType,
|
||||
// check for ambiguity or access.
|
||||
ImplicitConversionSequence ICS = Self.TryImplicitConversion(
|
||||
SrcExpr, DestType);
|
||||
if (ICS.ConversionKind == ImplicitConversionSequence::UserDefinedConversion)
|
||||
if (CXXConversionDecl *CV =
|
||||
dyn_cast<CXXConversionDecl>(ICS.UserDefined.ConversionFunction))
|
||||
ConversionDecl = CV;
|
||||
return ICS.ConversionKind == ImplicitConversionSequence::BadConversion ?
|
||||
TC_NotApplicable : TC_Success;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user