From a08bf30c7660a31e551226f3f5fb6d3d5f7eb009 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 11 Sep 2025 14:37:13 -0700 Subject: [PATCH 1/2] [LLDB] Improve wording of error message (NFC) --- lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp index 134e348619bb9..96e3bfbab92f2 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp @@ -3921,12 +3921,15 @@ SwiftASTContext::GetModuleImportProgressRAII(std::string category) { category); } +static const char *g_invalid_context = + "could not initialize Swift compiler, run swift-healthcheck for more info"; + llvm::Expected SwiftASTContext::GetModule(const SourceModule &module, bool *cached) { if (cached) *cached = false; - VALID_OR_RETURN(llvm::createStringError("invalid context")); + VALID_OR_RETURN(llvm::createStringError(g_invalid_context)); std::string module_name = llvm::join(module.path, "."); LOG_PRINTF(GetLog(LLDBLog::Types), "(\"%s\")", module_name.c_str()); @@ -6584,7 +6587,7 @@ bool SwiftASTContext::IsFixedSize(CompilerType compiler_type) { llvm::Expected SwiftASTContext::GetBitSize(opaque_compiler_type_t type, ExecutionContextScope *exe_scope) { - VALID_OR_RETURN_CHECK_TYPE(type, llvm::createStringError("invalid context")); + VALID_OR_RETURN_CHECK_TYPE(type, llvm::createStringError(g_invalid_context)); // If the type has type parameters, bind them first. swift::CanType swift_can_type(GetCanonicalSwiftType(type)); @@ -6831,7 +6834,7 @@ llvm::Expected SwiftASTContext::GetNumChildren(opaque_compiler_type_t type, bool omit_empty_base_classes, const ExecutionContext *exe_ctx) { - VALID_OR_RETURN_CHECK_TYPE(type, llvm::createStringError("invalid type")); + VALID_OR_RETURN_CHECK_TYPE(type, llvm::createStringError(g_invalid_context)); swift::CanType swift_can_type(GetCanonicalSwiftType(type)); From ac7bcb55711f539cfcc0013ba5e6d302775903e2 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 12 Sep 2025 09:39:49 -0700 Subject: [PATCH 2/2] Update lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp Co-authored-by: Jonas Devlieghere --- lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp index 96e3bfbab92f2..0f3bd95b6b157 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp @@ -3921,7 +3921,7 @@ SwiftASTContext::GetModuleImportProgressRAII(std::string category) { category); } -static const char *g_invalid_context = +static constexpr llvm::StringLiteral g_invalid_context = "could not initialize Swift compiler, run swift-healthcheck for more info"; llvm::Expected