[cfe-commits] r54107 - in /cfe/trunk/lib/CodeGen: CGExpr.cpp CGExprAgg.cpp CGExprComplex.cpp CGExprConstant.cpp CGExprScalar.cpp CodeGenTypes.cpp
Chris Lattner
sabre at nondot.org
Sat Jul 26 15:37:02 PDT 2008
Author: lattner
Date: Sat Jul 26 17:37:01 2008
New Revision: 54107
URL: http://llvm.org/viewvc/llvm-project?rev=54107&view=rev
Log:
remove uses of QualType::getCanonicalType() from codegen for PR2189
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=54107&r1=54106&r2=54107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Sat Jul 26 17:37:01 2008
@@ -404,7 +404,7 @@
if (E->getOpcode() == UnaryOperator::Extension)
return EmitLValue(E->getSubExpr());
- QualType ExprTy=CGM.getContext().getCanonicalType(E->getSubExpr()->getType());
+ QualType ExprTy = getContext().getCanonicalType(E->getSubExpr()->getType());
switch (E->getOpcode()) {
default: assert(0 && "Unknown unary operator lvalue!");
case UnaryOperator::Deref:
@@ -503,7 +503,7 @@
// size is a VLA.
if (!E->getType()->isConstantSizeType())
assert(0 && "VLA idx not implemented");
- QualType ExprTy = CGM.getContext().getCanonicalType(E->getBase()->getType());
+ QualType ExprTy = getContext().getCanonicalType(E->getBase()->getType());
return LValue::MakeAddr(Builder.CreateGEP(Base, Idx, "arrayidx"),
ExprTy->getAsPointerType()->getPointeeType()
@@ -560,7 +560,7 @@
if (E->isArrow()) {
BaseValue = EmitScalarExpr(BaseExpr);
const PointerType *PTy =
- cast<PointerType>(BaseExpr->getType().getCanonicalType());
+ cast<PointerType>(getContext().getCanonicalType(BaseExpr->getType()));
if (PTy->getPointeeType()->isUnionType())
isUnion = true;
CVRQualifiers = PTy->getPointeeType().getCVRQualifiers();
@@ -720,7 +720,7 @@
// The callee type will always be a pointer to function type, get the function
// type.
- FnType = cast<PointerType>(FnType.getCanonicalType())->getPointeeType();
+ FnType = FnType->getAsPointerType()->getPointeeType();
QualType ResultType = cast<FunctionType>(FnType)->getResultType();
llvm::SmallVector<llvm::Value*, 16> Args;
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=54107&r1=54106&r2=54107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Sat Jul 26 17:37:01 2008
@@ -180,20 +180,15 @@
// Visitor Methods
//===----------------------------------------------------------------------===//
-void AggExprEmitter::VisitImplicitCastExpr(ImplicitCastExpr *E)
-{
- QualType STy = E->getSubExpr()->getType().getCanonicalType();
- QualType Ty = E->getType().getCanonicalType();
-
+void AggExprEmitter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
assert(CGF.getContext().typesAreCompatible(
- STy.getUnqualifiedType(), Ty.getUnqualifiedType())
- && "Implicit cast types must be compatible");
-
+ E->getSubExpr()->getType().getUnqualifiedType(),
+ E->getType().getUnqualifiedType()) &&
+ "Implicit cast types must be compatible");
Visit(E->getSubExpr());
}
-void AggExprEmitter::VisitCallExpr(const CallExpr *E)
-{
+void AggExprEmitter::VisitCallExpr(const CallExpr *E) {
RValue RV = CGF.EmitCallExpr(E);
assert(RV.isAggregate() && "Return value must be aggregate value!");
@@ -204,8 +199,8 @@
EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
}
-void AggExprEmitter::VisitObjCMessageExpr(ObjCMessageExpr *E)
-{
+
+void AggExprEmitter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
RValue RV = RValue::getAggregate(CGF.EmitObjCMessageExpr(E));
// If the result is ignored, don't copy from the value.
@@ -215,8 +210,7 @@
EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
}
-void AggExprEmitter::VisitOverloadExpr(const OverloadExpr *E)
-{
+void AggExprEmitter::VisitOverloadExpr(const OverloadExpr *E) {
RValue RV = CGF.EmitCallExpr(E->getFn(), E->arg_begin(),
E->arg_end(CGF.getContext()));
@@ -230,8 +224,7 @@
EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
}
-void AggExprEmitter::VisitBinComma(const BinaryOperator *E)
-{
+void AggExprEmitter::VisitBinComma(const BinaryOperator *E) {
CGF.EmitAnyExpr(E->getLHS());
CGF.EmitAggExpr(E->getRHS(), DestPtr, false);
}
@@ -389,17 +382,21 @@
uint64_t NumInitElements = E->getNumInits();
- if (E->getNumInits() > 0 &&
- E->getType().getCanonicalType().getUnqualifiedType() ==
- E->getInit(0)->getType().getCanonicalType().getUnqualifiedType()) {
- EmitAggLoadOfLValue(E->getInit(0));
- return;
+ if (E->getNumInits() > 0) {
+ QualType T1 = E->getType();
+ QualType T2 = E->getInit(0)->getType();
+ if (CGF.getContext().getCanonicalType(T1).getUnqualifiedType() ==
+ CGF.getContext().getCanonicalType(T2).getUnqualifiedType()) {
+ EmitAggLoadOfLValue(E->getInit(0));
+ return;
+ }
}
uint64_t NumArrayElements = AType->getNumElements();
QualType ElementType = E->getType()->getAsArrayType()->getElementType();
- unsigned CVRqualifier = E->getType().getCanonicalType()->getAsArrayType()
+ unsigned CVRqualifier =
+ CGF.getContext().getCanonicalType(E->getType())->getAsArrayType()
->getElementType().getCVRQualifiers();
for (uint64_t i = 0; i != NumArrayElements; ++i) {
Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=54107&r1=54106&r2=54107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Sat Jul 26 17:37:01 2008
@@ -259,8 +259,8 @@
QualType SrcType,
QualType DestType) {
// Get the src/dest element type.
- SrcType = cast<ComplexType>(SrcType.getCanonicalType())->getElementType();
- DestType = cast<ComplexType>(DestType.getCanonicalType())->getElementType();
+ SrcType = SrcType->getAsComplexType()->getElementType();
+ DestType = DestType->getAsComplexType()->getElementType();
// C99 6.3.1.6: When a value of complextype is converted to another
// complex type, both the real and imaginary parts followthe conversion
@@ -282,7 +282,7 @@
llvm::Value *Elt = CGF.EmitScalarExpr(Op);
// Convert the input element to the element type of the complex.
- DestTy = cast<ComplexType>(DestTy.getCanonicalType())->getElementType();
+ DestTy = DestTy->getAsComplexType()->getElementType();
Elt = CGF.EmitScalarConversion(Elt, Op->getType(), DestTy);
// Return (realval, 0).
@@ -437,8 +437,9 @@
}
ComplexPairTy ComplexExprEmitter::VisitBinAssign(const BinaryOperator *E) {
- assert(E->getLHS()->getType().getCanonicalType() ==
- E->getRHS()->getType().getCanonicalType() && "Invalid assignment");
+ assert(CGF.getContext().getCanonicalType(E->getLHS()->getType()) ==
+ CGF.getContext().getCanonicalType(E->getRHS()->getType()) &&
+ "Invalid assignment");
// Emit the RHS.
ComplexPairTy Val = Visit(E->getRHS());
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=54107&r1=54106&r2=54107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Sat Jul 26 17:37:01 2008
@@ -627,8 +627,8 @@
llvm::Constant *EmitConversion(llvm::Constant *Src, QualType SrcType,
QualType DstType) {
- SrcType = SrcType.getCanonicalType();
- DstType = DstType.getCanonicalType();
+ SrcType = CGF->getContext().getCanonicalType(SrcType);
+ DstType = CGF->getContext().getCanonicalType(DstType);
if (SrcType == DstType) return Src;
// Handle conversions to bool first, they are special: comparisons against 0.
@@ -813,9 +813,8 @@
llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
- CodeGenFunction *CGF)
-{
- QualType type = E->getType().getCanonicalType();
+ CodeGenFunction *CGF) {
+ QualType type = Context.getCanonicalType(E->getType());
if (type->isIntegerType()) {
llvm::APSInt Value(static_cast<uint32_t>(Context.getTypeSize(type)));
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=54107&r1=54106&r2=54107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sat Jul 26 17:37:01 2008
@@ -345,8 +345,8 @@
/// specified destination type, both of which are LLVM scalar types.
Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
QualType DstType) {
- SrcType = SrcType.getCanonicalType();
- DstType = DstType.getCanonicalType();
+ SrcType = CGF.getContext().getCanonicalType(SrcType);
+ DstType = CGF.getContext().getCanonicalType(DstType);
if (SrcType == DstType) return Src;
if (DstType->isVoidType()) return 0;
@@ -421,7 +421,7 @@
EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src,
QualType SrcTy, QualType DstTy) {
// Get the source element type.
- SrcTy = cast<ComplexType>(SrcTy.getCanonicalType())->getElementType();
+ SrcTy = SrcTy->getAsComplexType()->getElementType();
// Handle conversions to bool first, they are special: comparisons against 0.
if (DstTy->isBooleanType()) {
@@ -546,10 +546,6 @@
return V;
} else if (E->getType()->isReferenceType()) {
- assert(cast<ReferenceType>(E->getType().getCanonicalType())->
- getPointeeType() ==
- Op->getType().getCanonicalType() && "Incompatible types!");
-
return EmitLValue(Op).getAddress();
}
@@ -819,7 +815,7 @@
// Zero or sign extend the pointer value based on whether the index is
// signed or not.
const llvm::Type *IdxType = llvm::IntegerType::get(CGF.LLVMPointerWidth);
- if (IdxExp->getType().getCanonicalType()->isSignedIntegerType())
+ if (IdxExp->getType()->isSignedIntegerType())
Idx = Builder.CreateSExt(Idx, IdxType, "idx.ext");
else
Idx = Builder.CreateZExt(Idx, IdxType, "idx.ext");
@@ -843,7 +839,7 @@
// Zero or sign extend the pointer value based on whether the index is
// signed or not.
const llvm::Type *IdxType = llvm::IntegerType::get(CGF.LLVMPointerWidth);
- if (Ops.E->getRHS()->getType().getCanonicalType()->isSignedIntegerType())
+ if (Ops.E->getRHS()->getType()->isSignedIntegerType())
Idx = Builder.CreateSExt(Idx, IdxType, "idx.ext");
else
Idx = Builder.CreateZExt(Idx, IdxType, "idx.ext");
@@ -862,8 +858,8 @@
Value *LHS = Visit(E->getLHS());
Value *RHS = Visit(E->getRHS());
- const QualType LHSType = E->getLHS()->getType().getCanonicalType();
- const QualType LHSElementType = cast<PointerType>(LHSType)->getPointeeType();
+ const QualType LHSType = E->getLHS()->getType();
+ const QualType LHSElementType = LHSType->getAsPointerType()->getPointeeType();
uint64_t ElementSize = CGF.getContext().getTypeSize(LHSElementType) / 8;
const llvm::Type *ResultType = ConvertType(E->getType());
@@ -948,8 +944,7 @@
CodeGenFunction::ComplexPairTy LHS = CGF.EmitComplexExpr(E->getLHS());
CodeGenFunction::ComplexPairTy RHS = CGF.EmitComplexExpr(E->getRHS());
- QualType CETy =
- cast<ComplexType>(LHSTy.getCanonicalType())->getElementType();
+ QualType CETy = LHSTy->getAsComplexType()->getElementType();
Value *ResultR, *ResultI;
if (CETy->isRealFloatingType()) {
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=54107&r1=54106&r2=54107&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Sat Jul 26 17:37:01 2008
@@ -94,16 +94,18 @@
}
const llvm::Type *CodeGenTypes::ConvertTypeRecursive(QualType T) {
+ T = Context.getCanonicalType(T);;
+
// See if type is already cached.
llvm::DenseMap<Type *, llvm::PATypeHolder>::iterator
- I = TypeCache.find(T.getCanonicalType().getTypePtr());
+ I = TypeCache.find(T.getTypePtr());
// If type is found in map and this is not a definition for a opaque
// place holder type then use it. Otherwise, convert type T.
if (I != TypeCache.end())
return I->second.get();
const llvm::Type *ResultType = ConvertNewType(T);
- TypeCache.insert(std::make_pair(T.getCanonicalType().getTypePtr(),
+ TypeCache.insert(std::make_pair(T.getTypePtr(),
llvm::PATypeHolder(ResultType)));
return ResultType;
}
@@ -184,7 +186,7 @@
}
const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
- const clang::Type &Ty = *T.getCanonicalType();
+ const clang::Type &Ty = *Context.getCanonicalType(T);
switch (Ty.getTypeClass()) {
case Type::TypeName: // typedef isn't canonical.
More information about the cfe-commits
mailing list