diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/Expr.cpp | 7 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 5 |
3 files changed, 6 insertions, 12 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 22d15be6a87..15cf6602b71 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -33,7 +33,7 @@ #include <cstring> using namespace clang; -const CXXRecordDecl *Expr::getMostDerivedClassDeclForType() const { +const CXXRecordDecl *Expr::getBestDynamicClassType() const { const Expr *E = this; while (true) { @@ -51,15 +51,10 @@ const CXXRecordDecl *Expr::getMostDerivedClassDeclForType() const { } QualType DerivedType = E->getType(); - if (DerivedType->isDependentType()) - return NULL; if (const PointerType *PTy = DerivedType->getAs<PointerType>()) DerivedType = PTy->getPointeeType(); const RecordType *Ty = DerivedType->castAs<RecordType>(); - if (!Ty) - return NULL; - Decl *D = Ty->getDecl(); return cast<CXXRecordDecl>(D); } diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 372eb5407c9..30324b97ef1 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -102,8 +102,7 @@ static bool canDevirtualizeMemberFunctionCalls(ASTContext &Context, // b->f(); // } // - const CXXRecordDecl *MostDerivedClassDecl = - Base->getMostDerivedClassDeclForType(); + const CXXRecordDecl *MostDerivedClassDecl = Base->getBestDynamicClassType(); if (MostDerivedClassDecl->hasAttr<FinalAttr>()) return true; @@ -228,8 +227,7 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE, bool UseVirtualCall = MD->isVirtual() && !ME->hasQualifier() && !canDevirtualizeMemberFunctionCalls(getContext(), Base, MD); - const CXXRecordDecl *MostDerivedClassDecl = - Base->getMostDerivedClassDeclForType(); + const CXXRecordDecl *MostDerivedClassDecl = Base->getBestDynamicClassType(); llvm::Value *Callee; if (const CXXDestructorDecl *Dtor = dyn_cast<CXXDestructorDecl>(MD)) { diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index bc77e6fae7e..2a7a8b9f195 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -10854,8 +10854,9 @@ static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, if (!MD) return; const Expr *Base = ME->getBase(); - const CXXRecordDecl *MostDerivedClassDecl - = Base->getMostDerivedClassDeclForType(); + if (Base->getType()->isDependentType()) + return; + const CXXRecordDecl *MostDerivedClassDecl = Base->getBestDynamicClassType(); if (!MostDerivedClassDecl) return; CXXMethodDecl *DM = MD->getCorrespondingMethodInClass(MostDerivedClassDecl); |