[Lldb-commits] [PATCH] D72413: Add missing nullptr checks.

Adrian Prantl via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 8 16:42:22 PST 2020


aprantl added a comment.

> Do we currently have a way to end up in this state?

Not in llvm.org. This was prompted by a swift-lldb-crash where we can end up with no Swift context after a catastrophic error. I believe that in practice the clang runtimes are always available, but the API returns a nullable pointer so the call sites should take this into account:

  PersistentExpressionState *
  Target::GetPersistentExpressionStateForLanguage(lldb::LanguageType language) {
    auto type_system_or_err = GetScratchTypeSystemForLanguage(language, true);
  
    if (auto err = type_system_or_err.takeError()) {
      LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
                     std::move(err),
                     "Unable to get persistent expression state for language {}",
                     Language::GetNameForLanguageType(language));
      return nullptr;
    }
  
    return type_system_or_err->GetPersistentExpressionState();
  }


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72413/new/

https://reviews.llvm.org/D72413





More information about the lldb-commits mailing list