diff options
Diffstat (limited to 'clang/lib/CodeGen/ItaniumCXXABI.cpp')
-rw-r--r-- | clang/lib/CodeGen/ItaniumCXXABI.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 8fdcaee31c9..201a7534776 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -52,11 +52,7 @@ public: CGCXXABI(CGM), UseARMMethodPtrABI(UseARMMethodPtrABI), UseARMGuardVarABI(UseARMGuardVarABI) { } - bool isReturnTypeIndirect(const CXXRecordDecl *RD) const override { - // Structures with either a non-trivial destructor or a non-trivial - // copy constructor are always indirect. - return !RD->hasTrivialDestructor() || RD->hasNonTrivialCopyConstructor(); - } + bool classifyReturnType(CGFunctionInfo &FI) const override; RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const override { // Structures with either a non-trivial destructor or a non-trivial @@ -761,6 +757,21 @@ ItaniumCXXABI::EmitMemberPointerIsNotNull(CodeGenFunction &CGF, return Result; } +bool ItaniumCXXABI::classifyReturnType(CGFunctionInfo &FI) const { + const CXXRecordDecl *RD = FI.getReturnType()->getAsCXXRecordDecl(); + if (!RD) + return false; + + // Return indirectly if we have a non-trivial copy ctor or non-trivial dtor. + if (RD->hasNonTrivialDestructor() || RD->hasNonTrivialCopyConstructor()) { + FI.getReturnInfo() = ABIArgInfo::getIndirect(0, /*ByVal=*/false); + return true; + } + + // Otherwise, use the normal C ABI rules. + return false; +} + /// The Itanium ABI requires non-zero initialization only for data /// member pointers, for which '0' is a valid offset. bool ItaniumCXXABI::isZeroInitializable(const MemberPointerType *MPT) { |