diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-12-13 21:53:04 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-12-13 21:53:04 +0000 |
commit | 6010880bd13b11ea687658d8f5bc4913bc62eb27 (patch) | |
tree | b65f59e8515805d5b1301f1a443568677ff4f897 /clang/lib/CodeGen/CGExprCXX.cpp | |
parent | 14318c5b318cd90123029fd1622dfcd024caeff4 (diff) | |
download | bcm5719-llvm-6010880bd13b11ea687658d8f5bc4913bc62eb27.tar.gz bcm5719-llvm-6010880bd13b11ea687658d8f5bc4913bc62eb27.zip |
IRGen: When performing CFI checks, load vtable pointer from vbase when necessary.
Under the Microsoft ABI, it is possible for an object not to have
a virtual table pointer of its own if all of its virtual functions
were introduced by virtual bases. In that case, we need to load the
vtable pointer from one of the virtual bases and perform the type
check using its type.
Differential Revision: https://reviews.llvm.org/D41036
llvm-svn: 320638
Diffstat (limited to 'clang/lib/CodeGen/CGExprCXX.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 3eb4bd6b901..41bb199ffde 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -368,9 +368,11 @@ RValue CodeGenFunction::EmitCXXMemberOrOperatorMemberCallExpr( } else { if (SanOpts.has(SanitizerKind::CFINVCall) && MD->getParent()->isDynamicClass()) { - llvm::Value *VTable = GetVTablePtr(This, Int8PtrTy, MD->getParent()); - EmitVTablePtrCheckForCall(MD->getParent(), VTable, CFITCK_NVCall, - CE->getLocStart()); + llvm::Value *VTable; + const CXXRecordDecl *RD; + std::tie(VTable, RD) = + CGM.getCXXABI().LoadVTablePtr(*this, This, MD->getParent()); + EmitVTablePtrCheckForCall(RD, VTable, CFITCK_NVCall, CE->getLocStart()); } if (getLangOpts().AppleKext && MD->isVirtual() && HasQualifier) |