forked from OSchip/llvm-project
Since isComplexType() no longer returns true for _Complex integers, the code
generator needs to call isAnyComplexType(). This fixes PR1960. llvm-svn: 49220
This commit is contained in:
parent
50ad37b6d9
commit
f3bc75afcf
|
@ -123,7 +123,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const BlockVarDecl &D) {
|
|||
if (!hasAggregateLLVMType(Init->getType())) {
|
||||
llvm::Value *V = EmitScalarExpr(Init);
|
||||
Builder.CreateStore(V, DeclPtr, D.getType().isVolatileQualified());
|
||||
} else if (Init->getType()->isComplexType()) {
|
||||
} else if (Init->getType()->isAnyComplexType()) {
|
||||
EmitComplexExprIntoAddr(Init, DeclPtr, D.getType().isVolatileQualified());
|
||||
} else {
|
||||
EmitAggExpr(Init, DeclPtr, D.getType().isVolatileQualified());
|
||||
|
|
|
@ -37,7 +37,7 @@ llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(const llvm::Type *Ty,
|
|||
/// expression and compare the result against zero, returning an Int1Ty value.
|
||||
llvm::Value *CodeGenFunction::EvaluateExprAsBool(const Expr *E) {
|
||||
QualType BoolTy = getContext().BoolTy;
|
||||
if (!E->getType()->isComplexType())
|
||||
if (!E->getType()->isAnyComplexType())
|
||||
return EmitScalarConversion(EmitScalarExpr(E), E->getType(), BoolTy);
|
||||
|
||||
return EmitComplexToScalarConversion(EmitComplexExpr(E), E->getType(),BoolTy);
|
||||
|
@ -51,7 +51,7 @@ RValue CodeGenFunction::EmitAnyExpr(const Expr *E, llvm::Value *AggLoc,
|
|||
bool isAggLocVolatile) {
|
||||
if (!hasAggregateLLVMType(E->getType()))
|
||||
return RValue::get(EmitScalarExpr(E));
|
||||
else if (E->getType()->isComplexType())
|
||||
else if (E->getType()->isAnyComplexType())
|
||||
return RValue::getComplex(EmitComplexExpr(E));
|
||||
|
||||
EmitAggExpr(E, AggLoc, isAggLocVolatile);
|
||||
|
@ -620,7 +620,7 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType FnType,
|
|||
if (!hasAggregateLLVMType(ArgTy)) {
|
||||
// Scalar argument is passed by-value.
|
||||
Args.push_back(EmitScalarExpr(ArgExprs[i]));
|
||||
} else if (ArgTy->isComplexType()) {
|
||||
} else if (ArgTy->isAnyComplexType()) {
|
||||
// Make a temporary alloca to pass the argument.
|
||||
llvm::Value *DestMem = CreateTempAlloca(ConvertType(ArgTy));
|
||||
EmitComplexExprIntoAddr(ArgExprs[i], DestMem, false);
|
||||
|
@ -637,7 +637,7 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType FnType,
|
|||
CI->setCallingConv(F->getCallingConv());
|
||||
if (CI->getType() != llvm::Type::VoidTy)
|
||||
CI->setName("call");
|
||||
else if (ResultType->isComplexType())
|
||||
else if (ResultType->isAnyComplexType())
|
||||
return RValue::getComplex(LoadComplexFromAddr(Args[0], false));
|
||||
else if (hasAggregateLLVMType(ResultType))
|
||||
// Struct return.
|
||||
|
|
|
@ -95,7 +95,7 @@ public:
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void AggExprEmitter::EmitAggregateClear(llvm::Value *DestPtr, QualType Ty) {
|
||||
assert(!Ty->isComplexType() && "Shouldn't happen for complex");
|
||||
assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex");
|
||||
|
||||
// Aggregate assignment turns into llvm.memset.
|
||||
const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
|
||||
|
@ -121,7 +121,7 @@ void AggExprEmitter::EmitAggregateClear(llvm::Value *DestPtr, QualType Ty) {
|
|||
|
||||
void AggExprEmitter::EmitAggregateCopy(llvm::Value *DestPtr,
|
||||
llvm::Value *SrcPtr, QualType Ty) {
|
||||
assert(!Ty->isComplexType() && "Shouldn't happen for complex");
|
||||
assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex");
|
||||
|
||||
// Aggregate assignment turns into llvm.memcpy.
|
||||
const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
|
||||
|
|
|
@ -267,7 +267,7 @@ ComplexPairTy ComplexExprEmitter::EmitComplexToComplexCast(ComplexPairTy Val,
|
|||
|
||||
ComplexPairTy ComplexExprEmitter::EmitCast(Expr *Op, QualType DestTy) {
|
||||
// Two cases here: cast from (complex to complex) and (scalar to complex).
|
||||
if (Op->getType()->isComplexType())
|
||||
if (Op->getType()->isAnyComplexType())
|
||||
return EmitComplexToComplexCast(Visit(Op), Op->getType(), DestTy);
|
||||
|
||||
// C99 6.3.1.7: When a value of real type is converted to a complex type, the
|
||||
|
@ -506,7 +506,7 @@ ComplexPairTy ComplexExprEmitter::VisitChooseExpr(ChooseExpr *E) {
|
|||
/// EmitComplexExpr - Emit the computation of the specified expression of
|
||||
/// complex type, ignoring the result.
|
||||
ComplexPairTy CodeGenFunction::EmitComplexExpr(const Expr *E) {
|
||||
assert(E && E->getType()->isComplexType() &&
|
||||
assert(E && E->getType()->isAnyComplexType() &&
|
||||
"Invalid complex expression to emit");
|
||||
|
||||
return ComplexExprEmitter(*this).Visit(const_cast<Expr*>(E));
|
||||
|
@ -517,7 +517,7 @@ ComplexPairTy CodeGenFunction::EmitComplexExpr(const Expr *E) {
|
|||
void CodeGenFunction::EmitComplexExprIntoAddr(const Expr *E,
|
||||
llvm::Value *DestAddr,
|
||||
bool DestIsVolatile) {
|
||||
assert(E && E->getType()->isComplexType() &&
|
||||
assert(E && E->getType()->isAnyComplexType() &&
|
||||
"Invalid complex expression to emit");
|
||||
ComplexExprEmitter Emitter(*this);
|
||||
ComplexPairTy Val = Emitter.Visit(const_cast<Expr*>(E));
|
||||
|
|
|
@ -466,7 +466,7 @@ Value *ScalarExprEmitter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
|
|||
if (!CGF.hasAggregateLLVMType(ArgTy)) {
|
||||
// Scalar argument is passed by-value.
|
||||
Args.push_back(CGF.EmitScalarExpr(ArgExpr));
|
||||
} else if (ArgTy->isComplexType()) {
|
||||
} else if (ArgTy->isAnyComplexType()) {
|
||||
// Make a temporary alloca to pass the argument.
|
||||
llvm::Value *DestMem = CGF.CreateTempAlloca(ConvertType(ArgTy));
|
||||
CGF.EmitComplexExprIntoAddr(ArgExpr, DestMem, false);
|
||||
|
@ -559,7 +559,7 @@ Value *ScalarExprEmitter::EmitCastExpr(const Expr *E, QualType DestTy) {
|
|||
return EmitScalarConversion(Src, E->getType(), DestTy);
|
||||
}
|
||||
|
||||
if (E->getType()->isComplexType()) {
|
||||
if (E->getType()->isAnyComplexType()) {
|
||||
// Handle cases where the source is a complex type.
|
||||
return EmitComplexToScalarConversion(CGF.EmitComplexExpr(E), E->getType(),
|
||||
DestTy);
|
||||
|
@ -669,13 +669,13 @@ Value *ScalarExprEmitter::EmitSizeAlignOf(QualType TypeToSize,
|
|||
|
||||
Value *ScalarExprEmitter::VisitUnaryReal(const UnaryOperator *E) {
|
||||
Expr *Op = E->getSubExpr();
|
||||
if (Op->getType()->isComplexType())
|
||||
if (Op->getType()->isAnyComplexType())
|
||||
return CGF.EmitComplexExpr(Op).first;
|
||||
return Visit(Op);
|
||||
}
|
||||
Value *ScalarExprEmitter::VisitUnaryImag(const UnaryOperator *E) {
|
||||
Expr *Op = E->getSubExpr();
|
||||
if (Op->getType()->isComplexType())
|
||||
if (Op->getType()->isAnyComplexType())
|
||||
return CGF.EmitComplexExpr(Op).second;
|
||||
|
||||
// __imag on a scalar returns zero. Emit it the subexpr to ensure side
|
||||
|
@ -894,7 +894,7 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc,
|
|||
unsigned SICmpOpc, unsigned FCmpOpc) {
|
||||
Value *Result;
|
||||
QualType LHSTy = E->getLHS()->getType();
|
||||
if (!LHSTy->isComplexType()) {
|
||||
if (!LHSTy->isAnyComplexType()) {
|
||||
Value *LHS = Visit(E->getLHS());
|
||||
Value *RHS = Visit(E->getRHS());
|
||||
|
||||
|
@ -1130,7 +1130,7 @@ Value *CodeGenFunction::EmitScalarConversion(Value *Src, QualType SrcTy,
|
|||
Value *CodeGenFunction::EmitComplexToScalarConversion(ComplexPairTy Src,
|
||||
QualType SrcTy,
|
||||
QualType DstTy) {
|
||||
assert(SrcTy->isComplexType() && !hasAggregateLLVMType(DstTy) &&
|
||||
assert(SrcTy->isAnyComplexType() && !hasAggregateLLVMType(DstTy) &&
|
||||
"Invalid complex -> scalar conversion");
|
||||
return ScalarExprEmitter(*this).EmitComplexToScalarConversion(Src, SrcTy,
|
||||
DstTy);
|
||||
|
|
|
@ -36,7 +36,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
|
|||
if (const Expr *E = dyn_cast<Expr>(S)) {
|
||||
if (!hasAggregateLLVMType(E->getType()))
|
||||
EmitScalarExpr(E);
|
||||
else if (E->getType()->isComplexType())
|
||||
else if (E->getType()->isAnyComplexType())
|
||||
EmitComplexExpr(E);
|
||||
else
|
||||
EmitAggExpr(E, 0, false);
|
||||
|
@ -344,7 +344,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
|
|||
Builder.CreateRet(llvm::UndefValue::get(RetTy));
|
||||
} else if (!hasAggregateLLVMType(RV->getType())) {
|
||||
Builder.CreateRet(EmitScalarExpr(RV));
|
||||
} else if (RV->getType()->isComplexType()) {
|
||||
} else if (RV->getType()->isAnyComplexType()) {
|
||||
llvm::Value *SRetPtr = CurFn->arg_begin();
|
||||
EmitComplexExprIntoAddr(RV, SRetPtr, false);
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang -emit-llvm %s
|
||||
// RUN: clang -emit-llvm < %s
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
@ -46,3 +46,8 @@ void t2() {
|
|||
(__imag__ cf) = 4.0;
|
||||
}
|
||||
|
||||
// PR1960
|
||||
void t3() {
|
||||
__complex__ long long v = 2;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue