add a common base class "PointerLikeType" for PointerType and ReferenceType,
allowing them to be treated the same in some contexts. A suggestion for a
better name is welcome :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49100 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 9497ece..cc7d8e9 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -213,7 +213,7 @@
return EmitSizeAlignOf(E->getSubExpr()->getType(), E->getType(), false);
}
Value *EmitSizeAlignOf(QualType TypeToSize, QualType RetType,
- bool isSizeOf);
+ bool isSizeOf);
Value *VisitUnaryReal (const UnaryOperator *E);
Value *VisitUnaryImag (const UnaryOperator *E);
Value *VisitUnaryExtension(const UnaryOperator *E) {
@@ -537,7 +537,7 @@
} else if (E->getType()->isReferenceType()) {
assert(cast<ReferenceType>(E->getType().getCanonicalType())->
- getReferenceeType() ==
+ getPointeeType() ==
Op->getType().getCanonicalType() && "Incompatible types!");
return EmitLValue(Op).getAddress();
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index a16543e..4e8d46c 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -206,15 +206,11 @@
ConvertType(cast<ComplexType>(Ty).getElementType());
return llvm::StructType::get(EltTy, EltTy, NULL);
}
+ case Type::Reference:
case Type::Pointer: {
- const PointerType &P = cast<PointerType>(Ty);
- QualType ETy = P.getPointeeType();
+ QualType ETy = cast<PointerLikeType>(Ty).getPointeeType();
return llvm::PointerType::get(ConvertType(ETy), ETy.getAddressSpace());
}
- case Type::Reference: {
- const ReferenceType &R = cast<ReferenceType>(Ty);
- return llvm::PointerType::getUnqual(ConvertType(R.getReferenceeType()));
- }
case Type::VariableArray: {
const VariableArrayType &A = cast<VariableArrayType>(Ty);