aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-07-26 22:37:01 +0000
committerChris Lattner <sabre@nondot.org>2008-07-26 22:37:01 +0000
commit9619662a1d42e2008b865d3459c0677e149dad1b (patch)
tree0714b13525e4c45644753ff246259e78f6775fd5
parent8b51fd76319d8b71f401cc6ad56e6f4f7be77958 (diff)
remove uses of QualType::getCanonicalType() from codegen for PR2189
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54107 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGExpr.cpp8
-rw-r--r--lib/CodeGen/CGExprAgg.cpp41
-rw-r--r--lib/CodeGen/CGExprComplex.cpp11
-rw-r--r--lib/CodeGen/CGExprConstant.cpp9
-rw-r--r--lib/CodeGen/CGExprScalar.cpp21
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp8
6 files changed, 46 insertions, 52 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 448f7ec97c..3b5eba84dc 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -404,7 +404,7 @@ LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
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 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
// 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 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
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 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType FnType,
// 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;
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index b9e850a473..ac2e6dec90 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -180,20 +180,15 @@ void AggExprEmitter::EmitAggLoadOfLValue(const Expr *E) {
// 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 @@ void AggExprEmitter::VisitCallExpr(const CallExpr *E)
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 @@ void AggExprEmitter::VisitObjCMessageExpr(ObjCMessageExpr *E)
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 @@ void AggExprEmitter::VisitOverloadExpr(const OverloadExpr *E)
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 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
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) {
diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp
index 6bf0d48c1e..2ea0a48a75 100644
--- a/lib/CodeGen/CGExprComplex.cpp
+++ b/lib/CodeGen/CGExprComplex.cpp
@@ -259,8 +259,8 @@ ComplexPairTy ComplexExprEmitter::EmitComplexToComplexCast(ComplexPairTy Val,
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 @@ ComplexPairTy ComplexExprEmitter::EmitCast(Expr *Op, QualType DestTy) {
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 @@ EmitCompoundAssign(const CompoundAssignOperator *E,
}
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());
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index 813bcfb855..2aaf2979bc 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -627,8 +627,8 @@ public:
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 @@ public:
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)));
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index da8350b19f..c44af4b8f1 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -345,8 +345,8 @@ Value *ScalarExprEmitter::EmitConversionToBool(Value *Src, QualType SrcType) {
/// 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 @@ Value *ScalarExprEmitter::
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 @@ Value *ScalarExprEmitter::VisitImplicitCastExpr(const ImplicitCastExpr *E) {
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 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
// 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 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
// 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 *ScalarExprEmitter::VisitBinSub(const BinaryOperator *E) {
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 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc,
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()) {
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index 41ec2dd0f7..db053aebb8 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -94,16 +94,18 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T) {
}
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 @@ static const llvm::Type* getTypeForFormat(const llvm::fltSemantics &format) {
}
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.