Add support for init lists for complex variables.

llvm-svn: 51080
This commit is contained in:
Eli Friedman 2008-05-13 23:11:35 +00:00
parent 20a44ed730
commit dd7406e65c
1 changed files with 13 additions and 0 deletions

View File

@ -177,6 +177,8 @@ public:
ComplexPairTy VisitConditionalOperator(const ConditionalOperator *CO);
ComplexPairTy VisitChooseExpr(ChooseExpr *CE);
ComplexPairTy VisitInitListExpr(InitListExpr *E);
};
} // end anonymous namespace.
@ -500,6 +502,17 @@ ComplexPairTy ComplexExprEmitter::VisitChooseExpr(ChooseExpr *E) {
return Visit(E->isConditionTrue(CGF.getContext()) ? E->getLHS() :E->getRHS());
}
ComplexPairTy ComplexExprEmitter::VisitInitListExpr(InitListExpr *E) {
if (E->getNumInits())
return Visit(E->getInit(0));
// Empty init list intializes to null
QualType Ty = E->getType()->getAsComplexType()->getElementType();
const llvm::Type* LTy = CGF.ConvertType(Ty);
llvm::Value* zeroConstant = llvm::Constant::getNullValue(LTy);
return ComplexPairTy(zeroConstant, zeroConstant);
}
//===----------------------------------------------------------------------===//
// Entry Point into this File
//===----------------------------------------------------------------------===//