diff options
author | Timur Iskhodzhanov <timurrrr@google.com> | 2013-10-30 11:55:43 +0000 |
---|---|---|
committer | Timur Iskhodzhanov <timurrrr@google.com> | 2013-10-30 11:55:43 +0000 |
commit | c70cc5d90403f99ccce5cab3a6c022ad9cdcb66c (patch) | |
tree | 480f9a9a347c482edbdabadbe19bbf1fb334d77d /include/clang/Basic/ABI.h | |
parent | 74b7363bcfc502dec34092af434da787cf9d5b9f (diff) | |
download | clang-c70cc5d90403f99ccce5cab3a6c022ad9cdcb66c.tar.gz clang-c70cc5d90403f99ccce5cab3a6c022ad9cdcb66c.tar.bz2 clang-c70cc5d90403f99ccce5cab3a6c022ad9cdcb66c.tar.xz |
Make thunk this/return adjustment ABI-specific. Also, fix the return adjustment when using -cxx-abi microsoft
Reviewed at http://llvm-reviews.chandlerc.com/D2026
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193679 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/ABI.h')
-rw-r--r-- | include/clang/Basic/ABI.h | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/include/clang/Basic/ABI.h b/include/clang/Basic/ABI.h index 7c76ec130e..9f214f3d34 100644 --- a/include/clang/Basic/ABI.h +++ b/include/clang/Basic/ABI.h @@ -39,19 +39,52 @@ struct ReturnAdjustment { /// \brief The non-virtual adjustment from the derived object to its /// nearest virtual base. int64_t NonVirtual; + + /// \brief Holds the ABI-specific information about the virtual return + /// adjustment, if needed. + union VirtualAdjustment { + // Itanium ABI + struct { + /// \brief The offset (in bytes), relative to the address point + /// of the virtual base class offset. + int64_t VBaseOffsetOffset; + } Itanium; + + // Microsoft ABI + struct { + /// \brief The offset (in bytes) of the vbptr, relative to the beginning + /// of the derived class. + uint32_t VBPtrOffset; + + /// \brief Index of the virtual base in the vbtable. + uint32_t VBIndex; + } Microsoft; + + VirtualAdjustment() { + memset(this, 0, sizeof(*this)); + } + + bool Equals(const VirtualAdjustment &Other) const { + return memcmp(this, &Other, sizeof(Other)) == 0; + } + + bool isEmpty() const { + VirtualAdjustment Zero; + return Equals(Zero); + } + + bool Less(const VirtualAdjustment &RHS) const { + return memcmp(this, &RHS, sizeof(RHS)) < 0; + } + } Virtual; - /// \brief The offset (in bytes), relative to the address point - /// of the virtual base class offset. - int64_t VBaseOffsetOffset; - - ReturnAdjustment() : NonVirtual(0), VBaseOffsetOffset(0) { } + ReturnAdjustment() : NonVirtual(0) {} - bool isEmpty() const { return !NonVirtual && !VBaseOffsetOffset; } + bool isEmpty() const { return !NonVirtual && Virtual.isEmpty(); } friend bool operator==(const ReturnAdjustment &LHS, const ReturnAdjustment &RHS) { - return LHS.NonVirtual == RHS.NonVirtual && - LHS.VBaseOffsetOffset == RHS.VBaseOffsetOffset; + return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Equals(RHS.Virtual); } friend bool operator!=(const ReturnAdjustment &LHS, const ReturnAdjustment &RHS) { @@ -62,9 +95,8 @@ struct ReturnAdjustment { const ReturnAdjustment &RHS) { if (LHS.NonVirtual < RHS.NonVirtual) return true; - - return LHS.NonVirtual == RHS.NonVirtual && - LHS.VBaseOffsetOffset < RHS.VBaseOffsetOffset; + + return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Less(RHS.Virtual); } }; |