Skip to content

Commit a897257

Browse files
committed
[silgen] Add a new private API on CleanupManager called isFormalAccessCleanup.
I am going to use this in ManagedValue.
1 parent d7be399 commit a897257

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/SILGen/Cleanup.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ void CleanupManager::setCleanupState(CleanupsDepth depth, CleanupState state) {
220220
popTopDeadCleanups();
221221
}
222222

223+
bool CleanupManager::isFormalAccessCleanup(CleanupHandle depth) {
224+
using RawTy = std::underlying_type<Cleanup::Flags>::type;
225+
auto state = getFlagsAndWritebackBuffer(depth);
226+
return RawTy(std::get<0>(state)) & RawTy(Cleanup::Flags::FormalAccessCleanup);
227+
}
228+
223229
std::tuple<Cleanup::Flags, llvm::Optional<SILValue>>
224230
CleanupManager::getFlagsAndWritebackBuffer(CleanupHandle depth) {
225231
auto iter = stack.find(depth);

lib/SILGen/Cleanup.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ class LLVM_LIBRARY_VISIBILITY CleanupManager {
294294
// cleanup at \p depth. If
295295
std::tuple<Cleanup::Flags, llvm::Optional<SILValue>>
296296
getFlagsAndWritebackBuffer(CleanupHandle depth);
297+
298+
bool isFormalAccessCleanup(CleanupHandle depth);
297299
};
298300

299301
/// An RAII object that allows the state of a cleanup to be

0 commit comments

Comments
 (0)