Mercurial > hg > CbC > CbC_llvm
changeset 115:95b91bc9a2f8
cleanupflag
author | mir3636 |
---|---|
date | Fri, 05 Aug 2016 19:04:52 +0900 |
parents | a6d007e4e7a3 |
children | a609e5c42ecc |
files | tools/clang/lib/CodeGen/CGCall.cpp |
diffstat | 1 files changed, 24 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/clang/lib/CodeGen/CGCall.cpp Thu Aug 04 19:27:15 2016 +0900 +++ b/tools/clang/lib/CodeGen/CGCall.cpp Fri Aug 05 19:04:52 2016 +0900 @@ -3460,8 +3460,30 @@ IRCallArgs[IRFunctionArgs.getInallocaArgNo()] = Arg; } #ifndef noCbC - if (CGF.FnRetTy.getTypePtr()->is__CodeType()) // - Fn->Emit(CGF, flags); + if (CGF.FnRetTy.getTypePtr()->is__CodeType()) { + EHCleanupScope &Scope = cast<EHCleanupScope>(*EHStack.begin()); + auto *CleanupSource = reinterpret_cast<char *>(Scope.getCleanupBuffer()); + llvm::AlignedCharArray<EHScopeStack::ScopeStackAlignment, 8 * sizeof(void *)> CleanupBufferStack; + std::unique_ptr<char[]> CleanupBufferHeap; + size_t CleanupSize = Scope.getCleanupSize(); + EHScopeStack::Cleanup *Fn; + + if (CleanupSize <= sizeof(CleanupBufferStack)) { + memcpy(CleanupBufferStack.buffer, CleanupSource, CleanupSize); + Fn = reinterpret_cast<EHScopeStack::Cleanup *>(CleanupBufferStack.buffer); + } else { + CleanupBufferHeap.reset(new char[CleanupSize]); + memcpy(CleanupBufferHeap.get(), CleanupSource, CleanupSize); + Fn = reinterpret_cast<EHScopeStack::Cleanup *>(CleanupBufferHeap.get()); + } + + EHScopeStack::Cleanup::Flags cleanupFlags; + if (Scope.isNormalCleanup()) + cleanupFlags.setIsNormalCleanupKind(); + if (Scope.isEHCleanup()) + cleanupFlags.setIsEHCleanupKind(); + Fn->Emit(CGF, cleanupFlags); + } #endif if (!CallArgs.getCleanupsToDeactivate().empty()) deactivateArgCleanupsBeforeCall(*this, CallArgs);