Skip to content

Commit 6b89a2a

Browse files
committed
Use std::adopt_lock instead of lambda
1 parent b64d0a2 commit 6b89a2a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lldb/source/Target/Target.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,7 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
24312431
// replacing it could cause a use-after-free later on.
24322432
auto &lock = GetSwiftScratchContextLock();
24332433
if (lock.try_lock()) {
2434-
auto unlock = llvm::make_scope_exit([&lock] { lock.unlock(); });
2434+
std::lock_guard<std::shared_mutex> unlock(lock, std::adopt_lock);
24352435
if (m_use_scratch_typesystem_per_module)
24362436
DisplayFallbackSwiftContextErrors(swift_ast_ctx);
24372437
else if (StreamSP errs = GetDebugger().GetAsyncErrorStream()) {
@@ -2768,7 +2768,7 @@ llvm::Optional<SwiftScratchContextReader> Target::GetSwiftScratchContext(
27682768
log->Printf("couldn't acquire scratch context lock\n");
27692769
return;
27702770
}
2771-
auto unlock = llvm::make_scope_exit([&lock] { lock.unlock(); });
2771+
std::lock_guard<std::shared_mutex> unlock(lock, std::adopt_lock);
27722772

27732773
// With the lock held, get the current scratch type system. This ensures
27742774
// the current instance is used even in the unlikely event it was changed

0 commit comments

Comments
 (0)