[cfe-commits] r49220 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGExprComplex.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CGStmt.cpp test/CodeGen/complex.c
Chris Lattner
sabre at nondot.org
Fri Apr 4 09:54:42 PDT 2008
Author: lattner
Date: Fri Apr 4 11:54:41 2008
New Revision: 49220
URL: http://llvm.org/viewvc/llvm-project?rev=49220&view=rev
Log:
Since isComplexType() no longer returns true for _Complex integers, the code
generator needs to call isAnyComplexType(). This fixes PR1960.
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/test/CodeGen/complex.c
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=49220&r1=49219&r2=49220&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Apr 4 11:54:41 2008
@@ -123,7 +123,7 @@
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());
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=49220&r1=49219&r2=49220&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Apr 4 11:54:41 2008
@@ -37,7 +37,7 @@
/// 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 @@
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 @@
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 @@
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.
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=49220&r1=49219&r2=49220&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Fri Apr 4 11:54:41 2008
@@ -95,7 +95,7 @@
//===----------------------------------------------------------------------===//
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::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);
Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=49220&r1=49219&r2=49220&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Fri Apr 4 11:54:41 2008
@@ -267,7 +267,7 @@
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 @@
/// 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 @@
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));
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=49220&r1=49219&r2=49220&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Apr 4 11:54:41 2008
@@ -466,7 +466,7 @@
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 @@
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::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 @@
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::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);
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=49220&r1=49219&r2=49220&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Apr 4 11:54:41 2008
@@ -36,7 +36,7 @@
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 @@
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 {
Modified: cfe/trunk/test/CodeGen/complex.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/complex.c?rev=49220&r1=49219&r2=49220&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/complex.c (original)
+++ cfe/trunk/test/CodeGen/complex.c Fri Apr 4 11:54:41 2008
@@ -1,4 +1,4 @@
-// RUN: clang -emit-llvm %s
+// RUN: clang -emit-llvm < %s
int main(void)
{
@@ -46,3 +46,8 @@
(__imag__ cf) = 4.0;
}
+// PR1960
+void t3() {
+ __complex__ long long v = 2;
+}
+
More information about the cfe-commits
mailing list