Skip to content

Commit 944fc85

Browse files
authored
[lldb] Check GetSwiftValidateTypeSystem where applicable (#6655)
The `VALIDATE_AND_RETURN` macros do a runtime check of `GetSwiftValidateTypeSystem`, to allow validation to be enabled/disabled. However there are some custom validations that don't use the macro. This change checks `GetSwiftValidateTypeSystem` in those custom validations too.
1 parent ceb31cc commit 944fc85

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,10 +3040,11 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
30403040
// Because the API deals out an index into a list of children we
30413041
// can't mix&match between the two typesystems if there is such a
30423042
// divergence. We'll need to replace all calls at once.
3043-
if (get_ast_num_children() <
3044-
runtime->GetNumChildren({weak_from_this(), type}, exe_scope)
3045-
.getValueOr(0))
3046-
return impl();
3043+
if (ModuleList::GetGlobalModuleListProperties().GetSwiftValidateTypeSystem())
3044+
if (get_ast_num_children() <
3045+
runtime->GetNumChildren({weak_from_this(), type}, exe_scope)
3046+
.getValueOr(0))
3047+
return impl();
30473048
if (ShouldSkipValidation(type))
30483049
return impl();
30493050
std::string ast_child_name;
@@ -3112,6 +3113,9 @@ size_t TypeSystemSwiftTypeRef::GetIndexOfChildMemberWithName(
31123113
#ifndef NDEBUG
31133114
// This block is a custom VALIDATE_AND_RETURN implementation to support
31143115
// checking the return value, plus the by-ref `child_indexes`.
3116+
if (!ModuleList::GetGlobalModuleListProperties()
3117+
.GetSwiftValidateTypeSystem())
3118+
return index_size;
31153119
if (!GetSwiftASTContext())
31163120
return index_size;
31173121
auto swift_scratch_ctx_lock = SwiftScratchContextLock(exe_ctx);
@@ -3531,6 +3535,9 @@ CompilerType TypeSystemSwiftTypeRef::CreateTupleType(
35313535
#ifndef NDEBUG
35323536
{
35333537
auto result = impl();
3538+
if (!ModuleList::GetGlobalModuleListProperties()
3539+
.GetSwiftValidateTypeSystem())
3540+
return result;
35343541
if (!GetSwiftASTContext())
35353542
return result;
35363543
std::vector<TupleElement> ast_elements;

0 commit comments

Comments
 (0)