summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-02-12 06:15:07 +0000
committerJohn McCall <rjmccall@apple.com>2010-02-12 06:15:07 +0000
commit84c416b9f64c977cf29ef800ac83bb0a25ff4212 (patch)
tree812cf79289d70b22763b983e087012fe7d6fb855 /clang/lib
parent87b4b4184ceb7b4324808cbc2e4ff3eed463e13f (diff)
downloadbcm5719-llvm-84c416b9f64c977cf29ef800ac83bb0a25ff4212.tar.gz
bcm5719-llvm-84c416b9f64c977cf29ef800ac83bb0a25ff4212.zip
Fix a bug causing an assertion when a covariant return type differed from
an overriden type only by reduced qualification. llvm-svn: 95968
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGVtable.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGVtable.cpp b/clang/lib/CodeGen/CGVtable.cpp
index 1c5384767ef..e2ea4736d30 100644
--- a/clang/lib/CodeGen/CGVtable.cpp
+++ b/clang/lib/CodeGen/CGVtable.cpp
@@ -64,8 +64,8 @@ static bool
TypeConversionRequiresAdjustment(ASTContext &Ctx,
QualType DerivedType, QualType BaseType) {
// Canonicalize the types.
- QualType CanDerivedType = Ctx.getCanonicalType(DerivedType);
- QualType CanBaseType = Ctx.getCanonicalType(BaseType);
+ CanQualType CanDerivedType = Ctx.getCanonicalType(DerivedType);
+ CanQualType CanBaseType = Ctx.getCanonicalType(BaseType);
assert(CanDerivedType->getTypeClass() == CanBaseType->getTypeClass() &&
"Types must have same type class!");
@@ -75,26 +75,29 @@ TypeConversionRequiresAdjustment(ASTContext &Ctx,
return false;
}
- if (const ReferenceType *RT = CanDerivedType->getAs<ReferenceType>()) {
- CanDerivedType = RT->getPointeeType();
+ if (isa<ReferenceType>(CanDerivedType)) {
+ CanDerivedType = CanDerivedType->getAs<ReferenceType>()->getPointeeType();
CanBaseType = CanBaseType->getAs<ReferenceType>()->getPointeeType();
- } else if (const PointerType *PT = CanDerivedType->getAs<PointerType>()) {
- CanDerivedType = PT->getPointeeType();
+ } else if (isa<PointerType>(CanDerivedType)) {
+ CanDerivedType = CanDerivedType->getAs<PointerType>()->getPointeeType();
CanBaseType = CanBaseType->getAs<PointerType>()->getPointeeType();
} else {
assert(false && "Unexpected return type!");
}
- if (CanDerivedType == CanBaseType) {
+ // We need to compare unqualified types here; consider
+ // const T *Base::foo();
+ // T *Derived::foo();
+ if (CanDerivedType.getUnqualifiedType() == CanBaseType.getUnqualifiedType()) {
// No adjustment needed.
return false;
}
const CXXRecordDecl *DerivedDecl =
- cast<CXXRecordDecl>(CanDerivedType->getAs<RecordType>()->getDecl());
+ cast<CXXRecordDecl>(cast<RecordType>(CanDerivedType)->getDecl());
const CXXRecordDecl *BaseDecl =
- cast<CXXRecordDecl>(CanBaseType->getAs<RecordType>()->getDecl());
+ cast<CXXRecordDecl>(cast<RecordType>(CanBaseType)->getDecl());
return TypeConversionRequiresAdjustment(Ctx, DerivedDecl, BaseDecl);
}
OpenPOWER on IntegriCloud