diff options
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 10 | ||||
-rw-r--r-- | clang/lib/AST/MicrosoftMangle.cpp | 9 |
2 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 049eebd82b6..e88ea946e72 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1866,6 +1866,16 @@ CharUnits ASTContext::getAlignOfGlobalVarInChars(QualType T) const { return toCharUnitsFromBits(getAlignOfGlobalVar(T)); } +CharUnits ASTContext::getOffsetOfBaseWithVBPtr(const CXXRecordDecl *RD) const { + CharUnits Offset = CharUnits::Zero(); + const ASTRecordLayout *Layout = &getASTRecordLayout(RD); + while (const CXXRecordDecl *Base = Layout->getBaseSharingVBPtr()) { + Offset += Layout->getBaseClassOffset(Base); + Layout = &getASTRecordLayout(Base); + } + return Offset; +} + /// DeepCollectObjCIvars - /// This routine first collects all declared, but not synthesized, ivars in /// super class and then collects all ivars, including those synthesized for diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 26894bb91eb..c50db60abe5 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -502,6 +502,9 @@ void MicrosoftCXXNameMangler::mangleMemberDataPointer(const CXXRecordDecl *RD, FieldOffset /= getASTContext().getCharWidth(); VBTableOffset = 0; + + if (IM == MSInheritanceAttr::Keyword_virtual_inheritance) + FieldOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity(); } else { FieldOffset = RD->nullFieldOffsetIsZero() ? 0 : -1; @@ -570,6 +573,10 @@ MicrosoftCXXNameMangler::mangleMemberFunctionPointer(const CXXRecordDecl *RD, mangleName(MD); mangleFunctionEncoding(MD, /*ShouldMangle=*/true); } + + if (VBTableOffset == 0 && + IM == MSInheritanceAttr::Keyword_virtual_inheritance) + NVOffset -= getASTContext().getOffsetOfBaseWithVBPtr(RD).getQuantity(); } else { // Null single inheritance member functions are encoded as a simple nullptr. if (IM == MSInheritanceAttr::Keyword_single_inheritance) { @@ -582,7 +589,7 @@ MicrosoftCXXNameMangler::mangleMemberFunctionPointer(const CXXRecordDecl *RD, } if (MSInheritanceAttr::hasNVOffsetField(/*IsMemberFunction=*/true, IM)) - mangleNumber(NVOffset); + mangleNumber(static_cast<uint32_t>(NVOffset)); if (MSInheritanceAttr::hasVBPtrOffsetField(IM)) mangleNumber(VBPtrOffset); if (MSInheritanceAttr::hasVBTableOffsetField(IM)) |