aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGClass.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2021-10-08 19:06:22 -0700
committerRichard Smith <richard@metafoo.co.uk>2021-10-08 19:59:42 -0700
commit7eae8c6e62b2a91e71aade19324b9d2242bcb4ab (patch)
tree634f8db5d66290354a8dd04e1284de2742dfdf81 /clang/lib/CodeGen/CGClass.cpp
parent85e565898ff36e5e50ff6e7ed6bf82b1cfbf89d6 (diff)
downloadllvm-7eae8c6e62b2a91e71aade19324b9d2242bcb4ab.zip
llvm-7eae8c6e62b2a91e71aade19324b9d2242bcb4ab.tar.gz
llvm-7eae8c6e62b2a91e71aade19324b9d2242bcb4ab.tar.bz2
Don't update the vptr at the start of the destructor of a final class.
In this case, we know statically that we're destroying the most-derived class, so the vptr must already point to the current class and never needs to be updated.
Diffstat (limited to 'clang/lib/CodeGen/CGClass.cpp')
-rw-r--r--clang/lib/CodeGen/CGClass.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 828dd71..0df64d4 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -1424,6 +1424,11 @@ static bool CanSkipVTablePointerInitialization(CodeGenFunction &CGF,
if (!ClassDecl->isDynamicClass())
return true;
+ // For a final class, the vtable pointer is known to already point to the
+ // class's vtable.
+ if (ClassDecl->isEffectivelyFinal())
+ return true;
+
if (!Dtor->hasTrivialBody())
return false;