diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-10-03 01:08:28 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-10-03 01:08:28 +0000 |
commit | 7bb26114006b4252089d33156b2d3f6bb8f0375b (patch) | |
tree | ad391e740138f57c51de6a90e56cf58bdcd61212 /clang/lib/CodeGen/CGExprScalar.cpp | |
parent | c7b2aeebb707da53075188bdf71bac6072d18127 (diff) | |
download | bcm5719-llvm-7bb26114006b4252089d33156b2d3f6bb8f0375b.tar.gz bcm5719-llvm-7bb26114006b4252089d33156b2d3f6bb8f0375b.zip |
Teach getCXXRecordDeclForPointerType about references.
Then, rename it getPointeeCXXRecordDecl and give it a nice doc comment,
and actually use it.
No intended functionality change.
llvm-svn: 165077
Diffstat (limited to 'clang/lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 28062456ccb..6d25642d02b 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1056,19 +1056,18 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { return Visit(const_cast<Expr*>(E)); case CK_BaseToDerived: { - const CXXRecordDecl *DerivedClassDecl = - DestTy->getCXXRecordDeclForPointerType(); - - return CGF.GetAddressOfDerivedClass(Visit(E), DerivedClassDecl, + const CXXRecordDecl *DerivedClassDecl = DestTy->getPointeeCXXRecordDecl(); + assert(DerivedClassDecl && "BaseToDerived arg isn't a C++ object pointer!"); + + return CGF.GetAddressOfDerivedClass(Visit(E), DerivedClassDecl, CE->path_begin(), CE->path_end(), ShouldNullCheckClassCastValue(CE)); } case CK_UncheckedDerivedToBase: case CK_DerivedToBase: { - const RecordType *DerivedClassTy = - E->getType()->getAs<PointerType>()->getPointeeType()->getAs<RecordType>(); - CXXRecordDecl *DerivedClassDecl = - cast<CXXRecordDecl>(DerivedClassTy->getDecl()); + const CXXRecordDecl *DerivedClassDecl = + E->getType()->getPointeeCXXRecordDecl(); + assert(DerivedClassDecl && "DerivedToBase arg isn't a C++ object pointer!"); return CGF.GetAddressOfBaseClass(Visit(E), DerivedClassDecl, CE->path_begin(), CE->path_end(), |