# HG changeset patch # User mir3636 # Date 1470391492 -32400 # Node ID 95b91bc9a2f8961336e288a01e9bf028892435eb # Parent a6d007e4e7a3ba0fb1cc41117071867308337c25 cleanupflag diff -r a6d007e4e7a3 -r 95b91bc9a2f8 tools/clang/lib/CodeGen/CGCall.cpp --- 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(*EHStack.begin()); + auto *CleanupSource = reinterpret_cast(Scope.getCleanupBuffer()); + llvm::AlignedCharArray CleanupBufferStack; + std::unique_ptr CleanupBufferHeap; + size_t CleanupSize = Scope.getCleanupSize(); + EHScopeStack::Cleanup *Fn; + + if (CleanupSize <= sizeof(CleanupBufferStack)) { + memcpy(CleanupBufferStack.buffer, CleanupSource, CleanupSize); + Fn = reinterpret_cast(CleanupBufferStack.buffer); + } else { + CleanupBufferHeap.reset(new char[CleanupSize]); + memcpy(CleanupBufferHeap.get(), CleanupSource, CleanupSize); + Fn = reinterpret_cast(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);