From d66f42856539bf1c764c13fba41758228fc4cb9b Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 27 Oct 2010 13:34:43 +0000 Subject: Also devirtualize calls to a member functions where the containing class has been marked final. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117445 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprCXX.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/CodeGen/CGExprCXX.cpp') diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index e3b5f71b27..a03a1fe362 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -59,10 +59,15 @@ static bool canDevirtualizeMemberFunctionCalls(const Expr *Base, const CXXMethodDecl *MD) { // If the member function has the "final" attribute, we know that it can't be - // overridden and can therefor devirtualize it. + // overridden and can therefore devirtualize it. if (MD->hasAttr()) return true; - + + // Similarly, if the class itself has the "final" attribute it can't be + // overridden and we can therefore devirtualize the member function call. + if (MD->getParent()->hasAttr()) + return true; + if (const DeclRefExpr *DRE = dyn_cast(Base)) { if (const VarDecl *VD = dyn_cast(DRE->getDecl())) { // This is a record decl. We know the type and can devirtualize it. -- cgit v1.2.3