diff options
author | Anders Carlsson <andersca@mac.com> | 2010-10-27 13:34:43 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-10-27 13:34:43 +0000 |
commit | b00c2144b3ab0086adebca90cbaa070def7c4bed (patch) | |
tree | 8db5da7e40d8e9cb8fd368c8326d16533f065154 /clang/lib/CodeGen/CGExprCXX.cpp | |
parent | a7911fa3d75a564356bdb3dae96f6c295f521b74 (diff) | |
download | bcm5719-llvm-b00c2144b3ab0086adebca90cbaa070def7c4bed.tar.gz bcm5719-llvm-b00c2144b3ab0086adebca90cbaa070def7c4bed.zip |
Also devirtualize calls to a member functions where the containing class has been marked final.
llvm-svn: 117445
Diffstat (limited to 'clang/lib/CodeGen/CGExprCXX.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index e3b5f71b271..a03a1fe3626 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/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<FinalAttr>()) 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<FinalAttr>()) + return true; + if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) { if (const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) { // This is a record decl. We know the type and can devirtualize it. |