Skip to content

Commit e8e5be8

Browse files
Merge pull request #7902 from adrian-prantl/119385604-5.10
Add missing nullptr check
2 parents 2d55bb6 + 7323cab commit e8e5be8

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,10 @@ SwiftLanguageRuntimeImpl::emplaceClangTypeInfo(
428428
return &*it_b.first->second;
429429
}
430430

431-
llvm::Optional<uint64_t> SwiftLanguageRuntimeImpl::GetMemberVariableOffsetRemoteMirrors(
432-
CompilerType instance_type, ValueObject *instance, llvm::StringRef member_name,
433-
Status *error) {
431+
llvm::Optional<uint64_t>
432+
SwiftLanguageRuntimeImpl::GetMemberVariableOffsetRemoteMirrors(
433+
CompilerType instance_type, ValueObject *instance,
434+
llvm::StringRef member_name, Status *error) {
434435
LLDB_LOGF(GetLog(LLDBLog::Types), "using remote mirrors");
435436
auto ts =
436437
instance_type.GetTypeSystem().dyn_cast_or_null<TypeSystemSwiftTypeRef>();

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ SwiftLanguageRuntimeImpl::GetMemberVariableOffsetRemoteAST(
8383
llvm::StringRef member_name) {
8484
auto scratch_ctx =
8585
instance_type.GetTypeSystem().dyn_cast_or_null<SwiftASTContext>();
86-
if (scratch_ctx == nullptr || scratch_ctx->HasFatalErrors())
86+
if (!scratch_ctx || scratch_ctx->HasFatalErrors())
8787
return {};
8888

8989
auto *remote_ast = &GetRemoteASTContext(*scratch_ctx);
9090
// Check whether we've already cached this offset.
9191
swift::TypeBase *swift_type =
9292
GetCanonicalSwiftType(instance_type).getPointer();
93-
if (swift_type == nullptr)
93+
if (!swift_type)
9494
return {};
9595

9696
// Perform the cache lookup.
@@ -142,6 +142,9 @@ SwiftLanguageRuntimeImpl::GetMemberVariableOffsetRemoteAST(
142142
}
143143
}
144144

145+
if (!swift_type)
146+
return {};
147+
145148
// Try to determine whether it is safe to use RemoteAST. RemoteAST
146149
// is faster than RemoteMirrors, but can't do dynamic types (checked
147150
// inside RemoteAST) or incomplete types (checked here).

0 commit comments

Comments
 (0)