From b1b040a803fd00a280d4a02f7151388be846701a 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) (cherry picked from commit a08bf30c7660a31e551226f3f5fb6d3d5f7eb009) --- 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 77df788c82498..4248e8113d290 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp @@ -3973,12 +3973,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()); @@ -6639,7 +6642,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)); @@ -6886,7 +6889,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 a259c615a7e436db8653e7bb2bed5c1aaae2844b 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 (cherry picked from commit ac7bcb55711f539cfcc0013ba5e6d302775903e2) --- 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 4248e8113d290..da05c0af92285 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp @@ -3973,7 +3973,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