Skip to content

Commit bb16e83

Browse files
committed
[NFC] [Coroutines] Use llvm::make_scope_exit to replace self-defined RTTIHelper
1 parent 6fcc19a commit bb16e83

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "CoroInternal.h"
1818
#include "llvm/ADT/BitVector.h"
19+
#include "llvm/ADT/ScopeExit.h"
1920
#include "llvm/ADT/SmallString.h"
2021
#include "llvm/Analysis/PtrUseVisitor.h"
2122
#include "llvm/Analysis/StackLifetime.h"
@@ -576,13 +577,8 @@ void FrameTypeBuilder::addFieldForAllocas(const Function &F,
576577
using AllocaSetType = SmallVector<AllocaInst *, 4>;
577578
SmallVector<AllocaSetType, 4> NonOverlapedAllocas;
578579

579-
// We need to add field for allocas at the end of this function. However, this
580-
// function has multiple exits, so we use this helper to avoid redundant code.
581-
struct RTTIHelper {
582-
std::function<void()> func;
583-
RTTIHelper(std::function<void()> &&func) : func(func) {}
584-
~RTTIHelper() { func(); }
585-
} Helper([&]() {
580+
// We need to add field for allocas at the end of this function.
581+
auto AddFieldForAllocasAtExit = make_scope_exit([&]() {
586582
for (auto AllocaList : NonOverlapedAllocas) {
587583
auto *LargestAI = *AllocaList.begin();
588584
FieldIDType Id = addFieldForAlloca(LargestAI);

0 commit comments

Comments
 (0)