Skip to content

Commit 9c33060

Browse files
Merge pull request #7889 from adrian-prantl/119385604
Add missing nullptr check
2 parents dbd8f38 + 812872f commit 9c33060

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
@@ -417,9 +417,10 @@ SwiftLanguageRuntimeImpl::emplaceClangTypeInfo(
417417
return &*it_b.first->second;
418418
}
419419

420-
llvm::Optional<uint64_t> SwiftLanguageRuntimeImpl::GetMemberVariableOffsetRemoteMirrors(
421-
CompilerType instance_type, ValueObject *instance, llvm::StringRef member_name,
422-
Status *error) {
420+
llvm::Optional<uint64_t>
421+
SwiftLanguageRuntimeImpl::GetMemberVariableOffsetRemoteMirrors(
422+
CompilerType instance_type, ValueObject *instance,
423+
llvm::StringRef member_name, Status *error) {
423424
LLDB_LOGF(GetLog(LLDBLog::Types), "using remote mirrors");
424425
auto ts =
425426
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
@@ -84,14 +84,14 @@ SwiftLanguageRuntimeImpl::GetMemberVariableOffsetRemoteAST(
8484
llvm::StringRef member_name) {
8585
auto scratch_ctx =
8686
instance_type.GetTypeSystem().dyn_cast_or_null<SwiftASTContext>();
87-
if (scratch_ctx == nullptr || scratch_ctx->HasFatalErrors())
87+
if (!scratch_ctx || scratch_ctx->HasFatalErrors())
8888
return {};
8989

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

9797
// Perform the cache lookup.
@@ -143,6 +143,9 @@ SwiftLanguageRuntimeImpl::GetMemberVariableOffsetRemoteAST(
143143
}
144144
}
145145

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

0 commit comments

Comments
 (0)