Skip to content

Commit d8d45aa

Browse files
authored
[lldb] ifdef IsScratchContextLocked for asserts (#6875)
`IsScratchContextLocked` is racey, but is called only from asserts. Put these functions behind `#ifndef NDEBUG` to make them less likely to be used accidentally.
1 parent 83c3a02 commit d8d45aa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,8 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Pack(
19091909
return true;
19101910
}
19111911

1912-
/// Determine whether the scratch SwiftASTContext has been locked.
1912+
#ifndef NDEBUG
1913+
/// Assert helper to determine if the scratch SwiftASTContext is locked.
19131914
static bool IsScratchContextLocked(Target &target) {
19141915
if (target.GetSwiftScratchContextLock().try_lock()) {
19151916
target.GetSwiftScratchContextLock().unlock();
@@ -1918,10 +1919,11 @@ static bool IsScratchContextLocked(Target &target) {
19181919
return true;
19191920
}
19201921

1921-
/// Determine whether the scratch SwiftASTContext has been locked.
1922+
/// Assert helper to determine if the scratch SwiftASTContext is locked.
19221923
static bool IsScratchContextLocked(TargetSP target) {
19231924
return target ? IsScratchContextLocked(*target) : true;
19241925
}
1926+
#endif
19251927

19261928
static bool IsPrivateNSClass(NodePointer node) {
19271929
if (!node || node->getKind() != Node::Kind::Type ||

0 commit comments

Comments
 (0)