[Lldb-commits] [lldb] [lldb] Bring more diagnostics in compliance with our coding standards (PR #190410)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 3 14:25:12 PDT 2026


https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/190410

The LLVM Coding Standards [1] specify that:

> [T]o match error message styles commonly produced by other tools,
> start the first sentence with a lowercase letter, and finish the last
> sentence without a period, if it would end in one otherwise.

Historically, that hasn't been something we've enforced in LLDB, but in the past year or so I've started to pay more attention to this in code reviews. This PR brings more error messages in compliance, further increasing consistency.

I also adopted `createStringErrorV` where it improved the code as a drive-by for lines I was already touching.

[1] https://llvm.org/docs/CodingStandards.html#error-and-warning-messages

Assisted-by: Claude Code

>From 8d7941dd8163c82cff304fd1794f1879f62fc774 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Fri, 3 Apr 2026 13:20:36 -0700
Subject: [PATCH] [lldb] Bring more diagnostics in compliance with our coding
 standards

The LLVM Coding Standards [1] specify that:

> [T]o match error message styles commonly produced by other tools,
> start the first sentence with a lowercase letter, and finish the last
> sentence without a period, if it would end in one otherwise.

Historically, that hasn't been something we've enforced in LLDB, but in
the past year or so I've started to pay more attention to this in code
reviews. This PR brings more error messages in compliance, further
increasing consistency.

I also adopted `createStringErrorV` where it improved the code as a
drive-by for lines I was already touching.

[1] https://llvm.org/docs/CodingStandards.html#error-and-warning-messages

Assisted-by: Claude Code
---
 lldb/source/DataFormatters/TypeSynthetic.cpp  |  9 ++--
 lldb/source/Expression/Expression.cpp         |  2 +-
 lldb/source/Expression/IRExecutionUnit.cpp    |  2 +-
 lldb/source/Host/common/Socket.cpp            |  4 +-
 lldb/source/Host/common/TCPSocket.cpp         |  2 +-
 lldb/source/Host/macosx/objcxx/Host.mm        |  2 +-
 lldb/source/Host/posix/DomainSocket.cpp       |  2 +-
 lldb/source/Host/posix/PipePosix.cpp          |  2 +-
 lldb/source/Interpreter/Options.cpp           |  4 +-
 .../Language/CPlusPlus/BlockPointer.cpp       |  6 ++-
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 52 +++++++++----------
 .../Plugins/Language/CPlusPlus/Coroutines.cpp |  6 ++-
 .../CPlusPlus/GenericInitializerList.cpp      | 10 ++--
 .../Language/CPlusPlus/GenericList.cpp        |  4 +-
 .../Language/CPlusPlus/GenericOptional.cpp    |  6 ++-
 .../Plugins/Language/CPlusPlus/LibCxx.cpp     | 10 ++--
 .../Language/CPlusPlus/LibCxxAtomic.cpp       |  5 +-
 .../Plugins/Language/CPlusPlus/LibCxxMap.cpp  |  8 +--
 .../Language/CPlusPlus/LibCxxProxyArray.cpp   | 10 ++--
 .../Language/CPlusPlus/LibCxxQueue.cpp        |  5 +-
 .../Language/CPlusPlus/LibCxxSliceArray.cpp   | 10 ++--
 .../Plugins/Language/CPlusPlus/LibCxxSpan.cpp |  9 ++--
 .../Language/CPlusPlus/LibCxxUnorderedMap.cpp |  7 +--
 .../Language/CPlusPlus/LibCxxValarray.cpp     | 10 ++--
 .../Language/CPlusPlus/LibCxxVector.cpp       | 22 ++++----
 .../Plugins/Language/CPlusPlus/LibStdcpp.cpp  | 14 ++---
 .../CPlusPlus/LibStdcppUniquePointer.cpp      |  6 ++-
 .../Language/CPlusPlus/MsvcStlAtomic.cpp      |  6 ++-
 .../Language/CPlusPlus/MsvcStlDeque.cpp       | 12 +++--
 .../CPlusPlus/MsvcStlSmartPointer.cpp         | 10 ++--
 .../Language/CPlusPlus/MsvcStlSpan.cpp        | 10 ++--
 .../Language/CPlusPlus/MsvcStlTree.cpp        |  4 +-
 .../Language/CPlusPlus/MsvcStlUnordered.cpp   |  4 +-
 .../Language/CPlusPlus/MsvcStlVector.cpp      | 22 ++++----
 lldb/source/Plugins/Language/ObjC/Cocoa.cpp   |  5 +-
 .../Plugins/Language/ObjC/NSDictionary.cpp    |  6 ++-
 lldb/source/Plugins/Language/ObjC/NSError.cpp |  6 ++-
 .../Plugins/Language/ObjC/NSException.cpp     |  6 ++-
 .../Platform/MacOSX/PlatformDarwin.cpp        |  4 +-
 .../Plugins/Process/AIX/NativeProcessAIX.cpp  |  2 +-
 .../Process/FreeBSD/NativeProcessFreeBSD.cpp  |  6 +--
 .../Process/Linux/NativeProcessLinux.cpp      |  4 +-
 .../Process/NetBSD/NativeProcessNetBSD.cpp    |  6 +--
 .../Process/Windows/Common/ProcessWindows.cpp |  4 +-
 .../Process/elf-core/ProcessElfCore.cpp       |  2 +-
 .../GDBRemoteCommunicationServerLLGS.cpp      |  8 +--
 .../Interfaces/ScriptedPythonInterface.h      |  4 +-
 .../Python/ScriptInterpreterPython.cpp        | 13 +++--
 .../NativePDB/SymbolFileNativePDB.cpp         |  4 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp      |  4 +-
 lldb/source/Symbol/CompilerType.cpp           |  7 +--
 lldb/source/Symbol/SymbolContext.cpp          |  2 +-
 lldb/source/Target/Process.cpp                |  2 +-
 lldb/source/Target/Target.cpp                 |  4 +-
 lldb/source/Target/Thread.cpp                 |  2 +-
 lldb/source/ValueObject/ValueObject.cpp       |  2 +-
 .../ValueObject/ValueObjectRegister.cpp       |  4 +-
 .../ValueObject/ValueObjectSynthetic.cpp      | 13 ++---
 .../DWARF/x86/class-type-nullptr-deref.s      |  2 +-
 .../DWARF/x86/debug-types-signature-loop.s    | 10 ++--
 lldb/test/Shell/Target/target-label.test      |  2 +-
 lldb/unittests/Expression/ExpressionTest.cpp  | 14 ++---
 62 files changed, 249 insertions(+), 196 deletions(-)

diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp b/lldb/source/DataFormatters/TypeSynthetic.cpp
index e25296e91fa25..53fe150954c7d 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -21,6 +21,7 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/StreamString.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorExtras.h"
 #include <cstdint>
 
 using namespace lldb;
@@ -70,8 +71,8 @@ TypeFilterImpl::FrontEnd::GetIndexOfChildWithName(ConstString name) {
       }
     }
   }
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 std::string TypeFilterImpl::GetDescription() {
@@ -225,8 +226,8 @@ bool ScriptedSyntheticChildren::FrontEnd::MightHaveChildren() {
 llvm::Expected<size_t>
 ScriptedSyntheticChildren::FrontEnd::GetIndexOfChildWithName(ConstString name) {
   if (!m_wrapper_sp || m_interpreter == nullptr)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   return m_interpreter->GetIndexOfChildWithName(m_wrapper_sp,
                                                 name.GetCString());
 }
diff --git a/lldb/source/Expression/Expression.cpp b/lldb/source/Expression/Expression.cpp
index cca645e5f264f..f31aba945d150 100644
--- a/lldb/source/Expression/Expression.cpp
+++ b/lldb/source/Expression/Expression.cpp
@@ -39,7 +39,7 @@ lldb_private::FunctionCallLabel::fromString(llvm::StringRef label) {
   label.split(components, ":", /*MaxSplit=*/4);
 
   if (components.size() != 5)
-    return llvm::createStringError("malformed function call label.");
+    return llvm::createStringError("malformed function call label");
 
   if (components[0] != FunctionCallLabelPrefix)
     return llvm::createStringErrorV(
diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp
index 60b9de0d21b2e..06f4d7b9fb5dd 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -729,7 +729,7 @@ ResolveFunctionCallLabel(FunctionCallLabel &label,
   symbol_was_missing_weak = false;
 
   if (!sc.target_sp)
-    return llvm::createStringError("target not available.");
+    return llvm::createStringError("target not available");
 
   auto module_sp = sc.target_sp->GetImages().FindModule(label.module_id);
   if (!module_sp)
diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp
index 48191b4d1ca81..041dfbda0c21d 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -181,7 +181,7 @@ llvm::Error Socket::Initialize() {
   if (err == 0) {
     if (wsaData.wVersion < wVersion) {
       WSACleanup();
-      return llvm::createStringError("WSASock version is not expected.");
+      return llvm::createStringError("WSASock version is not expected");
     }
   } else {
     return llvm::errorCodeToError(llvm::mapWindowsError(::WSAGetLastError()));
@@ -247,7 +247,7 @@ Socket::CreatePair(std::optional<SocketProtocol> protocol) {
     return DomainSocket::CreatePair();
 #endif
   default:
-    return llvm::createStringError("Unsupported protocol");
+    return llvm::createStringError("unsupported protocol");
   }
 }
 
diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp
index c144f3c501d7f..18a2d66e30bf4 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -267,7 +267,7 @@ llvm::Expected<std::vector<MainLoopBase::ReadHandleUP>>
 TCPSocket::Accept(MainLoopBase &loop,
                   std::function<void(std::unique_ptr<Socket> socket)> sock_cb) {
   if (m_listen_sockets.size() == 0)
-    return llvm::createStringError("No open listening sockets!");
+    return llvm::createStringError("no open listening sockets!");
 
   std::vector<MainLoopBase::ReadHandleUP> handles;
   for (auto socket : m_listen_sockets) {
diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm
index 1aa6b5376b6b1..2b18c0d50e80b 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -458,7 +458,7 @@ repeat with the_window in (get windows)\n\
       std::error_code(ENOTSUP, std::system_category()));
 #else  // !TARGET_OS_OSX
   if (url.empty())
-    return llvm::createStringError("Cannot open empty URL.");
+    return llvm::createStringError("cannot open empty URL");
 
   LLDB_LOG(GetLog(LLDBLog::Host), "Opening URL: {0}", url);
 
diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp
index 6a730324a1ea3..c0f6ffe626e9e 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -227,7 +227,7 @@ DomainSocket::FromBoundNativeSocket(NativeSocket sockfd, bool should_close) {
   if (getsockname(sockfd, (struct sockaddr *)&addr, &addr_len) == -1)
     return llvm::createStringError("not a socket or error occurred");
   if (addr.sun_family != AF_UNIX)
-    return llvm::createStringError("Bad socket type");
+    return llvm::createStringError("bad socket type");
 #ifdef __linux__
   if (addr_len > offsetof(struct sockaddr_un, sun_path) &&
       addr.sun_path[0] == '\0')
diff --git a/lldb/source/Host/posix/PipePosix.cpp b/lldb/source/Host/posix/PipePosix.cpp
index 68b02a9aa465b..93410119d2941 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -164,7 +164,7 @@ llvm::Error PipePosix::OpenAsWriter(llvm::StringRef name,
                                     const Timeout<std::micro> &timeout) {
   std::lock_guard<std::mutex> guard(m_write_mutex);
   if (CanReadUnlocked() || CanWriteUnlocked())
-    return llvm::createStringError("Pipe is already opened");
+    return llvm::createStringError("pipe is already opened");
 
   int flags = O_WRONLY | O_NONBLOCK | O_CLOEXEC;
 
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index 283c9cc0105a1..89e204de6aead 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -934,7 +934,7 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
   Option *long_options = GetLongOptions();
 
   if (long_options == nullptr) {
-    return llvm::createStringError("Invalid long options");
+    return llvm::createStringError("invalid long options");
   }
 
   std::string short_options = BuildShortOptions(long_options);
@@ -959,7 +959,7 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
       break;
 
     if (val == '?') {
-      return llvm::createStringError("Unknown or ambiguous option");
+      return llvm::createStringError("unknown or ambiguous option");
     }
 
     if (val == 0)
diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 9ab1bf03250b1..cc1cd351f6b45 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -11,6 +11,8 @@
 #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
 #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Symbol/TypeSystem.h"
@@ -146,8 +148,8 @@ class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
 
   llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
     if (!m_block_struct_type.IsValid())
-      return llvm::createStringError("Type has no child named '%s'",
-                                     name.AsCString());
+      return llvm::createStringErrorV("type has no child named '{0}'",
+                                      name.GetStringRef());
 
     const bool omit_empty_base_classes = false;
     return m_block_struct_type.GetIndexOfChildWithName(name.AsCString(),
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 7a0f556b3aed4..b7da0f592f596 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -18,6 +18,7 @@
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Demangle/ItaniumDemangle.h"
+#include "llvm/Support/ErrorExtras.h"
 
 #include "lldb/Core/DemangledNameInfo.h"
 #include "lldb/Core/Mangled.h"
@@ -260,24 +261,24 @@ static llvm::Expected<std::pair<llvm::StringRef, DemangledNameInfo>>
 GetAndValidateInfo(const SymbolContext &sc) {
   Mangled mangled = sc.GetPossiblyInlinedFunctionName();
   if (!mangled)
-    return llvm::createStringError("Function does not have a mangled name.");
+    return llvm::createStringError("function does not have a mangled name");
 
   auto demangled_name = mangled.GetDemangledName().GetStringRef();
   if (demangled_name.empty())
-    return llvm::createStringError(
-        "Function '%s' does not have a demangled name.",
-        mangled.GetMangledName().AsCString(""));
+    return llvm::createStringErrorV(
+        "function '{0}' does not have a demangled name",
+        mangled.GetMangledName().GetStringRef());
 
   const std::optional<DemangledNameInfo> &info = mangled.GetDemangledInfo();
   if (!info)
-    return llvm::createStringError(
-        "Function '%s' does not have demangled info.", demangled_name.data());
+    return llvm::createStringErrorV(
+        "function '{0}' does not have demangled info", demangled_name);
 
   // Function without a basename is nonsense.
   if (!info->hasBasename())
-    return llvm::createStringError(
-        "DemangledInfo for '%s does not have basename range.",
-        demangled_name.data());
+    return llvm::createStringErrorV(
+        "demangled info for '{0}' does not have a basename range",
+        demangled_name);
 
   return std::make_pair(demangled_name, *info);
 }
@@ -304,8 +305,8 @@ llvm::Expected<llvm::StringRef>
 CPlusPlusLanguage::GetDemangledTemplateArguments(
     llvm::StringRef demangled, const DemangledNameInfo &info) {
   if (!info.hasTemplateArguments())
-    return llvm::createStringError(
-        "Template arguments range for '%s' is invalid.", demangled.data());
+    return llvm::createStringErrorV(
+        "template arguments range for '{0}' is invalid", demangled);
 
   return demangled.slice(info.TemplateArgumentsRange.first,
                          info.TemplateArgumentsRange.second);
@@ -326,8 +327,8 @@ llvm::Expected<llvm::StringRef>
 CPlusPlusLanguage::GetDemangledReturnTypeLHS(llvm::StringRef demangled,
                                              const DemangledNameInfo &info) {
   if (info.ScopeRange.first >= demangled.size())
-    return llvm::createStringError(
-        "Scope range for '%s' LHS return type is invalid.", demangled.data());
+    return llvm::createStringErrorV(
+        "scope range for '{0}' LHS return type is invalid", demangled);
 
   return demangled.substr(0, info.ScopeRange.first);
 }
@@ -347,8 +348,8 @@ llvm::Expected<llvm::StringRef>
 CPlusPlusLanguage::GetDemangledFunctionQualifiers(
     llvm::StringRef demangled, const DemangledNameInfo &info) {
   if (!info.hasQualifiers())
-    return llvm::createStringError("Qualifiers range for '%s' is invalid.",
-                                   demangled.data());
+    return llvm::createStringErrorV("qualifiers range for '{0}' is invalid",
+                                    demangled);
 
   return demangled.slice(info.QualifiersRange.first,
                          info.QualifiersRange.second);
@@ -370,9 +371,8 @@ llvm::Expected<llvm::StringRef>
 CPlusPlusLanguage::GetDemangledReturnTypeRHS(llvm::StringRef demangled,
                                              const DemangledNameInfo &info) {
   if (info.QualifiersRange.first < info.ArgumentsRange.second)
-    return llvm::createStringError(
-        "Qualifiers range for '%s' RHS return type  is invalid.",
-        demangled.data());
+    return llvm::createStringErrorV(
+        "qualifiers range for '{0}' RHS return type is invalid", demangled);
 
   return demangled.slice(info.ArgumentsRange.second,
                          info.QualifiersRange.first);
@@ -393,8 +393,8 @@ llvm::Expected<llvm::StringRef>
 CPlusPlusLanguage::GetDemangledScope(llvm::StringRef demangled,
                                      const DemangledNameInfo &info) {
   if (!info.hasScope())
-    return llvm::createStringError("Scope range for '%s' is invalid.",
-                                   demangled.data());
+    return llvm::createStringErrorV("scope range for '{0}' is invalid",
+                                    demangled);
 
   return demangled.slice(info.ScopeRange.first, info.ScopeRange.second);
 }
@@ -414,8 +414,8 @@ llvm::Expected<llvm::StringRef>
 CPlusPlusLanguage::GetDemangledFunctionSuffix(llvm::StringRef demangled,
                                               const DemangledNameInfo &info) {
   if (!info.hasSuffix())
-    return llvm::createStringError("Suffix range for '%s' is invalid.",
-                                   demangled.data());
+    return llvm::createStringErrorV("suffix range for '{0}' is invalid",
+                                    demangled);
 
   return demangled.slice(info.SuffixRange.first, info.SuffixRange.second);
 }
@@ -435,8 +435,8 @@ llvm::Expected<llvm::StringRef>
 CPlusPlusLanguage::GetDemangledFunctionArguments(
     llvm::StringRef demangled, const DemangledNameInfo &info) {
   if (!info.hasArguments())
-    return llvm::createStringError(
-        "Function arguments range for '%s' is invalid.", demangled.data());
+    return llvm::createStringErrorV(
+        "function arguments range for '{0}' is invalid", demangled);
 
   return demangled.slice(info.ArgumentsRange.first, info.ArgumentsRange.second);
 }
@@ -2488,8 +2488,8 @@ class ManglingSubstitutor
 
   llvm::Expected<ConstString> substituteImpl(llvm::StringRef Mangled) {
     if (this->parse() == nullptr)
-      return llvm::createStringError(
-          llvm::formatv("Failed to substitute mangling in '{0}'", Mangled));
+      return llvm::createStringErrorV("failed to substitute mangling in '{0}'",
+                                      Mangled);
 
     if (!Substituted)
       return ConstString();
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index e8c2db1886333..6726c8d43ede4 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -9,6 +9,8 @@
 #include "Coroutines.h"
 
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/VariableList.h"
 
@@ -201,8 +203,8 @@ StdlibCoroutineHandleSyntheticFrontEnd::GetIndexOfChildWithName(
       return idx;
   }
 
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericInitializerList.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericInitializerList.cpp
index 7f012b7fc8aa6..33d0bf91058d7 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/GenericInitializerList.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/GenericInitializerList.cpp
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/ValueObject/ValueObject.h"
@@ -114,13 +116,13 @@ class GenericInitializerListSyntheticFrontEnd
 
   llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
     if (!m_start) {
-      return llvm::createStringError("Type has no child named '%s'",
-                                     name.AsCString());
+      return llvm::createStringErrorV("type has no child named '{0}'",
+                                      name.GetStringRef());
     }
     auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
     if (!optional_idx) {
-      return llvm::createStringError("Type has no child named '%s'",
-                                     name.AsCString());
+      return llvm::createStringErrorV("type has no child named '{0}'",
+                                      name.GetStringRef());
     }
     return *optional_idx;
   }
diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp
index 841d3b2220df7..e5ef393c09753 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp
@@ -553,11 +553,11 @@ llvm::Expected<uint32_t> MsvcStlListFrontEnd::CalculateNumChildren() {
   auto size_sp =
       m_backend.GetChildAtNamePath({"_Mypair", "_Myval2", "_Mysize"});
   if (!size_sp)
-    return llvm::createStringError("Failed to resolve size.");
+    return llvm::createStringError("failed to resolve size");
 
   m_count = size_sp->GetValueAsUnsigned(UINT32_MAX);
   if (m_count == UINT32_MAX)
-    return llvm::createStringError("Failed to read size value.");
+    return llvm::createStringError("failed to read size value");
 
   return m_count;
 }
diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
index e4c261a5411f7..e6ac1ac772d21 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
@@ -11,6 +11,8 @@
 #include "LibStdcpp.h"
 #include "MsvcStl.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Target/Target.h"
 
@@ -41,8 +43,8 @@ class GenericOptionalFrontend : public SyntheticChildrenFrontEnd {
   llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
     if (name == "$$dereference$$")
       return 0;
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
 
   llvm::Expected<uint32_t> CalculateNumChildren() override {
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 57717fac1d00f..82997f69669bc 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -8,6 +8,8 @@
 
 #include "LibCxx.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
@@ -416,8 +418,8 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
   if (name == "object" || name == "$$dereference$$")
     return 1;
 
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
@@ -519,8 +521,8 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
     return 1;
   if (name == "obj" || name == "object" || name == "$$dereference$$")
     return 2;
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 /// The field layout in a libc++ string (cap, side, data or data, size, cap).
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
index e20dd31ef70ad..e93694927eb78 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
@@ -8,6 +8,7 @@
 
 #include "LibCxxAtomic.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
+#include "llvm/Support/ErrorExtras.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -135,8 +136,8 @@ lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
     GetIndexOfChildWithName(ConstString name) {
   if (name == "Value")
     return 0;
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index c40223f5845a5..9153be411da12 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -9,6 +9,8 @@
 #include "LibCxx.h"
 
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/DataBufferHeap.h"
@@ -275,7 +277,7 @@ llvm::Expected<uint32_t> lldb_private::formatters::
   auto [size_sp, is_compressed_pair] =
       GetValueOrOldCompressedPair(*m_tree, "__size_", "__pair3_");
   if (!size_sp)
-    return llvm::createStringError("Unexpected std::map layout");
+    return llvm::createStringError("unexpected std::map layout");
 
   if (is_compressed_pair)
     return CalculateNumChildrenForOldCompressedPairLayout(*size_sp);
@@ -482,8 +484,8 @@ llvm::Expected<size_t>
 lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
     GetIndexOfChildWithName(ConstString name) {
   if (!m_pair_sp)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
 
   return m_pair_sp->GetIndexOfChildWithName(name);
 }
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxProxyArray.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxProxyArray.cpp
index a3d34c6e76d1e..8f0bd85130694 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxProxyArray.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxProxyArray.cpp
@@ -8,6 +8,8 @@
 
 #include "LibCxx.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/ValueObject/ValueObject.h"
 #include <optional>
@@ -177,12 +179,12 @@ llvm::Expected<size_t>
 lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd::
     GetIndexOfChildWithName(ConstString name) {
   if (!m_base)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
   if (!optional_idx) {
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
   return *optional_idx;
 }
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
index 9d55feedd400f..5fc040bb11f89 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
@@ -8,6 +8,7 @@
 
 #include "LibCxx.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
+#include "llvm/Support/ErrorExtras.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -23,8 +24,8 @@ class QueueFrontEnd : public SyntheticChildrenFrontEnd {
   llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
     if (m_container_sp)
       return m_container_sp->GetIndexOfChildWithName(name);
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
 
   lldb::ChildCacheState Update() override;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp
index 3bdb099d21012..ab3a02146100e 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp
@@ -8,6 +8,8 @@
 
 #include "LibCxx.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/ValueObject/ValueObject.h"
 #include <optional>
@@ -148,12 +150,12 @@ llvm::Expected<size_t>
 lldb_private::formatters::LibcxxStdSliceArraySyntheticFrontEnd::
     GetIndexOfChildWithName(ConstString name) {
   if (!m_start)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
   if (!optional_idx) {
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
   return *optional_idx;
 }
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp
index 496bbd07304d6..e0557ea00afbf 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp
@@ -12,6 +12,7 @@
 #include "lldb/Utility/ConstString.h"
 #include "lldb/ValueObject/ValueObject.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/Support/ErrorExtras.h"
 #include <optional>
 
 using namespace lldb;
@@ -131,12 +132,12 @@ lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::Update() {
 llvm::Expected<size_t> lldb_private::formatters::
     LibcxxStdSpanSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
   if (!m_start)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
   if (!optional_idx) {
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
   return *optional_idx;
 }
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 34eed108d8501..735f3f76742b5 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -20,6 +20,7 @@
 #include "lldb/ValueObject/ValueObjectConstResult.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorExtras.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -222,7 +223,7 @@ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
     return size_sp->GetValueAsUnsigned(0);
 
   if (!is_compressed_pair)
-    return llvm::createStringError("Unsupported std::unordered_map layout.");
+    return llvm::createStringError("unsupported std::unordered_map layout");
 
   ValueObjectSP num_elements_sp = GetFirstValueOfLibCXXCompressedPair(*size_sp);
 
@@ -392,8 +393,8 @@ lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::
     return 0;
   if (name == "second")
     return 1;
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp
index 3a8bf3a45ce54..9ab383144561b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp
@@ -8,6 +8,8 @@
 
 #include "LibCxx.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/ValueObject/ValueObject.h"
 #include <optional>
@@ -127,12 +129,12 @@ llvm::Expected<size_t>
 lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd::
     GetIndexOfChildWithName(ConstString name) {
   if (!m_start || !m_finish)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
   if (!optional_idx) {
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
   return *optional_idx;
 }
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
index ce2b24fd438d6..701d48ba8b822 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
@@ -8,6 +8,8 @@
 
 #include "LibCxx.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/ValueObject/ValueObject.h"
@@ -166,12 +168,12 @@ llvm::Expected<size_t>
 lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
     GetIndexOfChildWithName(ConstString name) {
   if (!m_start || !m_finish)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
   if (!optional_idx) {
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
   return *optional_idx;
 }
@@ -269,17 +271,17 @@ llvm::Expected<size_t>
 lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
     GetIndexOfChildWithName(ConstString name) {
   if (!m_count || !m_base_data_address)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   auto optional_idx = ExtractIndexFromString(name.AsCString());
   if (!optional_idx) {
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
   uint32_t idx = *optional_idx;
   if (idx >= CalculateNumChildrenIgnoringErrors())
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   return idx;
 }
 
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
index c06f50c1ca65d..4b4081ab98913 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -12,6 +12,8 @@
 #include "Plugins/Language/CPlusPlus/CxxStringTypes.h"
 #include "Plugins/Language/CPlusPlus/Generic.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/StringPrinter.h"
 #include "lldb/DataFormatters/VectorIterator.h"
@@ -156,8 +158,8 @@ LibstdcppMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName(
     return 0;
   if (name == "second")
     return 1;
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 SyntheticChildrenFrontEnd *
@@ -233,8 +235,8 @@ llvm::Expected<size_t>
 VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
   if (name == "item")
     return 0;
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 bool lldb_private::formatters::LibStdcppStringSummaryProvider(
@@ -393,8 +395,8 @@ LibStdcppSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
   if (name == "object" || name == "$$dereference$$")
     return 1;
 
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
index 36401a0480c02..cd95a753c2a7f 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -8,6 +8,8 @@
 
 #include "LibStdcpp.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/TypeSynthetic.h"
 #include "lldb/Utility/ConstString.h"
@@ -145,8 +147,8 @@ LibStdcppUniquePtrSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
     return 1;
   if (name == "obj" || name == "object" || name == "$$dereference$$")
     return 2;
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 bool LibStdcppUniquePtrSyntheticFrontEnd::GetSummary(
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp
index 7973e4f01bf3e..6b6556e7b3e06 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp
@@ -8,6 +8,8 @@
 
 #include "MsvcStl.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/TypeSynthetic.h"
 
 using namespace lldb;
@@ -85,8 +87,8 @@ llvm::Expected<size_t> lldb_private::formatters::
     MsvcStlAtomicSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
   if (name == "Value")
     return 0;
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 lldb_private::SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlDeque.cpp b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlDeque.cpp
index de103e9e4a460..c45870603e59a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlDeque.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlDeque.cpp
@@ -8,6 +8,8 @@
 
 #include "MsvcStl.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/TypeSynthetic.h"
 
@@ -55,7 +57,7 @@ lldb_private::formatters::MsvcStlDequeSyntheticFrontEnd::
 llvm::Expected<uint32_t> lldb_private::formatters::
     MsvcStlDequeSyntheticFrontEnd::CalculateNumChildren() {
   if (!m_map)
-    return llvm::createStringError("Failed to read size");
+    return llvm::createStringError("failed to read size");
   return m_size;
 }
 
@@ -158,13 +160,13 @@ lldb_private::formatters::MsvcStlDequeSyntheticFrontEnd::Update() {
 llvm::Expected<size_t> lldb_private::formatters::MsvcStlDequeSyntheticFrontEnd::
     GetIndexOfChildWithName(ConstString name) {
   if (!m_map)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   if (auto optional_idx = ExtractIndexFromString(name.GetCString()))
     return *optional_idx;
 
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 bool lldb_private::formatters::IsMsvcStlDeque(ValueObject &valobj) {
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlSmartPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlSmartPointer.cpp
index d72300171400a..b183b08c9f3a3 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlSmartPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlSmartPointer.cpp
@@ -9,6 +9,8 @@
 #include "Generic.h"
 #include "MsvcStl.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/TypeSynthetic.h"
 
@@ -169,8 +171,8 @@ lldb_private::formatters::MsvcStlSmartPointerSyntheticFrontEnd::
   if (name == "object" || name == "$$dereference$$")
     return 1;
 
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 lldb_private::formatters::MsvcStlSmartPointerSyntheticFrontEnd::
@@ -270,8 +272,8 @@ lldb_private::formatters::MsvcStlUniquePtrSyntheticFrontEnd::
     return 1;
   if (name == "obj" || name == "object" || name == "$$dereference$$")
     return 2;
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 lldb_private::SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlSpan.cpp b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlSpan.cpp
index 6d99aeb42a407..8c85ea010effc 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlSpan.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlSpan.cpp
@@ -8,6 +8,8 @@
 
 #include "MsvcStl.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/ValueObject/ValueObject.h"
@@ -107,13 +109,13 @@ llvm::Expected<size_t>
 lldb_private::formatters::MsvcStlSpanSyntheticFrontEnd::GetIndexOfChildWithName(
     ConstString name) {
   if (!m_start)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
 
   auto optional_idx = formatters::ExtractIndexFromString(name.GetCString());
   if (!optional_idx)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   return *optional_idx;
 }
 
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlTree.cpp b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlTree.cpp
index 3cd88eebc56b1..728a5e31204bc 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlTree.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlTree.cpp
@@ -227,7 +227,7 @@ class MsvcStlTreeIterSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
 
   llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
     if (!m_inner_sp)
-      return llvm::createStringError("There are no children.");
+      return llvm::createStringError("there are no children");
     return m_inner_sp->GetIndexOfChildWithName(name);
   }
 
@@ -260,7 +260,7 @@ lldb_private::formatters::MsvcStlTreeSyntheticFrontEnd::CalculateNumChildren() {
     return m_count;
   }
 
-  return llvm::createStringError("Failed to read size.");
+  return llvm::createStringError("failed to read size");
 }
 
 ValueObjectSP
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlUnordered.cpp b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlUnordered.cpp
index 9540bff97d260..00909d27fb607 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlUnordered.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlUnordered.cpp
@@ -22,7 +22,7 @@ class UnorderedFrontEnd : public SyntheticChildrenFrontEnd {
 
   llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
     if (!m_list_sp)
-      return llvm::createStringError("Missing _List");
+      return llvm::createStringError("missing _List");
     return m_list_sp->GetIndexOfChildWithName(name);
   }
 
@@ -30,7 +30,7 @@ class UnorderedFrontEnd : public SyntheticChildrenFrontEnd {
 
   llvm::Expected<uint32_t> CalculateNumChildren() override {
     if (!m_list_sp)
-      return llvm::createStringError("Missing _List");
+      return llvm::createStringError("missing _List");
     return m_list_sp->GetNumChildren();
   }
 
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlVector.cpp
index 99e73ca46fa20..9e620b08a7896 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlVector.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlVector.cpp
@@ -8,6 +8,8 @@
 
 #include "MsvcStl.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/TypeSynthetic.h"
 
@@ -138,12 +140,12 @@ lldb_private::formatters::MsvcStlVectorSyntheticFrontEnd::Update() {
 llvm::Expected<size_t> lldb_private::formatters::
     MsvcStlVectorSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
   if (!m_start || !m_finish)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   auto optional_idx = ExtractIndexFromString(name.GetCString());
   if (!optional_idx) {
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
   return *optional_idx;
 }
@@ -267,17 +269,17 @@ llvm::Expected<size_t>
 lldb_private::formatters::MsvcStlVectorBoolSyntheticFrontEnd::
     GetIndexOfChildWithName(ConstString name) {
   if (!m_count || !m_base_data_address)
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   auto optional_idx = ExtractIndexFromString(name.AsCString());
   if (!optional_idx) {
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
   uint32_t idx = *optional_idx;
   if (idx >= CalculateNumChildrenIgnoringErrors())
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   return idx;
 }
 
diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 72e4d0fe2aa21..d0e1b3992a472 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -30,6 +30,7 @@
 
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/bit.h"
+#include "llvm/Support/ErrorExtras.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -1050,8 +1051,8 @@ class ObjCClassSyntheticChildrenFrontEnd : public SyntheticChildrenFrontEnd {
   bool MightHaveChildren() override { return false; }
 
   llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
 };
 
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index 2d72e913192ab..7ac8a0158c191 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -16,6 +16,8 @@
 #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Target/StackFrame.h"
@@ -929,8 +931,8 @@ llvm::Expected<size_t> lldb_private::formatters::
   static const ConstString g_zero("[0]");
   if (name == g_zero)
     return 0;
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 llvm::Expected<uint32_t> lldb_private::formatters::
diff --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp
index 0152c3125f1e1..af2ea3e70bf8e 100644
--- a/lldb/source/Plugins/Language/ObjC/NSError.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSError.cpp
@@ -11,6 +11,8 @@
 #include "Cocoa.h"
 
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/DataBufferHeap.h"
@@ -169,8 +171,8 @@ class NSErrorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
     static ConstString g_userInfo("_userInfo");
     if (name == g_userInfo)
       return 0;
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
 
 private:
diff --git a/lldb/source/Plugins/Language/ObjC/NSException.cpp b/lldb/source/Plugins/Language/ObjC/NSException.cpp
index e27c7e0e97bef..9c66ee0658fdd 100644
--- a/lldb/source/Plugins/Language/ObjC/NSException.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSException.cpp
@@ -10,6 +10,8 @@
 
 #include "Cocoa.h"
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/DataBufferHeap.h"
@@ -162,8 +164,8 @@ class NSExceptionSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
     if (name == g_reason) return 1;
     if (name == g_userInfo) return 2;
     if (name == g_reserved) return 3;
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   }
 
 private:
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 21be75c5a25da..cc1e00562e4a0 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1107,11 +1107,11 @@ ResolveSDKPathFromDebugInfo(lldb_private::Target *target) {
 
   ModuleSP exe_module_sp = target->GetExecutableModule();
   if (!exe_module_sp)
-    return llvm::createStringError("Failed to get module from target");
+    return llvm::createStringError("failed to get module from target");
 
   SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
   if (!sym_file)
-    return llvm::createStringError("Failed to get symbol file from executable");
+    return llvm::createStringError("failed to get symbol file from executable");
 
   if (sym_file->GetNumCompileUnits() == 0)
     return llvm::createStringError(
diff --git a/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
index 67db9eb4e4d2b..66eeb213436a2 100644
--- a/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
+++ b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
@@ -80,7 +80,7 @@ NativeProcessAIX::Manager::Launch(ProcessLaunchInfo &launch_info,
   if (!WIFSTOPPED(wstatus)) {
     LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
              WaitStatus::Decode(wstatus));
-    return llvm::createStringError("Could not sync with inferior process");
+    return llvm::createStringError("could not sync with inferior process");
   }
   LLDB_LOG(log, "inferior started, now in stopped state");
 
diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
index ab8f8a426d9f9..af4d0d7505f6f 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
@@ -92,13 +92,13 @@ NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo &launch_info,
   if (!WIFSTOPPED(wstatus)) {
     LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
              WaitStatus::Decode(wstatus));
-    return llvm::createStringError("Could not sync with inferior process");
+    return llvm::createStringError("could not sync with inferior process");
   }
   LLDB_LOG(log, "inferior started, now in stopped state");
 
   ProcessInstanceInfo Info;
   if (!Host::GetProcessInfo(pid, Info)) {
-    return llvm::createStringError("Cannot get process architecture");
+    return llvm::createStringError("cannot get process architecture");
   }
 
   // Set the architecture to the exe architecture.
@@ -129,7 +129,7 @@ NativeProcessFreeBSD::Manager::Attach(
   // Retrieve the architecture for the running process.
   ProcessInstanceInfo Info;
   if (!Host::GetProcessInfo(pid, Info)) {
-    return llvm::createStringError("Cannot get process architecture");
+    return llvm::createStringError("cannot get process architecture");
   }
 
   std::unique_ptr<NativeProcessFreeBSD> process_up(new NativeProcessFreeBSD(
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index a40a66e838a89..5527734ad39be 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -287,7 +287,7 @@ NativeProcessLinux::Manager::Launch(ProcessLaunchInfo &launch_info,
   if (!WIFSTOPPED(wstatus)) {
     LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
              WaitStatus::Decode(wstatus));
-    return llvm::createStringError("Could not sync with inferior process");
+    return llvm::createStringError("could not sync with inferior process");
   }
   LLDB_LOG(log, "inferior started, now in stopped state");
 
@@ -504,7 +504,7 @@ llvm::Expected<std::vector<::pid_t>> NativeProcessLinux::Attach(::pid_t pid) {
 
   size_t tid_count = tids_to_attach.size();
   if (tid_count == 0)
-    return llvm::createStringError("No such process");
+    return llvm::createStringError("no such process");
 
   std::vector<::pid_t> tids;
   tids.reserve(tid_count);
diff --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
index e4de3fab3a0fa..661589f6ea3fd 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -78,13 +78,13 @@ NativeProcessNetBSD::Manager::Launch(ProcessLaunchInfo &launch_info,
   if (!WIFSTOPPED(wstatus)) {
     LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
              WaitStatus::Decode(wstatus));
-    return llvm::createStringError("Could not sync with inferior process");
+    return llvm::createStringError("could not sync with inferior process");
   }
   LLDB_LOG(log, "inferior started, now in stopped state");
 
   ProcessInstanceInfo Info;
   if (!Host::GetProcessInfo(pid, Info)) {
-    return llvm::createStringError("Cannot get process architecture");
+    return llvm::createStringError("cannot get process architecture");
   }
 
   // Set the architecture to the exe architecture.
@@ -115,7 +115,7 @@ NativeProcessNetBSD::Manager::Attach(
   // Retrieve the architecture for the running process.
   ProcessInstanceInfo Info;
   if (!Host::GetProcessInfo(pid, Info)) {
-    return llvm::createStringError("Cannot get process architecture");
+    return llvm::createStringError("cannot get process architecture");
   }
 
   std::unique_ptr<NativeProcessNetBSD> process_up(new NativeProcessNetBSD(
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 730b944c1ddcb..c0c8be8bd62b8 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -1010,7 +1010,7 @@ class IOHandlerProcessSTDIOWindows : public IOHandler {
       INPUT_RECORD inputRecord;
       DWORD numRead = 0;
       if (!PeekConsoleInput(hStdin, &inputRecord, 1, &numRead))
-        return llvm::createStringError("Failed to peek standard input.");
+        return llvm::createStringError("failed to peek standard input");
 
       if (numRead == 0)
         return false;
@@ -1021,7 +1021,7 @@ class IOHandlerProcessSTDIOWindows : public IOHandler {
         return true;
 
       if (!ReadConsoleInput(hStdin, &inputRecord, 1, &numRead))
-        return llvm::createStringError("Failed to read standard input.");
+        return llvm::createStringError("failed to read standard input");
     }
   }
 
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index cf9e253af7f25..70069f96d5701 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -645,7 +645,7 @@ ProcessElfCore::parseSegment(const DataExtractor &segment) {
   while (offset < segment.GetByteSize()) {
     ELFNote note = ELFNote();
     if (!note.Parse(segment, &offset))
-      return llvm::createStringError("Unable to parse note segment");
+      return llvm::createStringError("unable to parse note segment");
 
     size_t note_start = offset;
     size_t note_size = llvm::alignTo(note.n_descsz, 4);
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 48f6648292c2c..10509a63e47c3 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -2442,7 +2442,7 @@ GDBRemoteCommunicationServerLLGS::Handle_H(StringExtractorGDBRemote &packet) {
   auto pid_tid = packet.GetPidTid(default_process ? default_process->GetID()
                                                   : LLDB_INVALID_PROCESS_ID);
   if (!pid_tid)
-    return SendErrorResponse(llvm::createStringError("Malformed thread-id"));
+    return SendErrorResponse(llvm::createStringError("malformed thread-id"));
 
   lldb::pid_t pid = pid_tid->first;
   lldb::tid_t tid = pid_tid->second;
@@ -2451,7 +2451,7 @@ GDBRemoteCommunicationServerLLGS::Handle_H(StringExtractorGDBRemote &packet) {
     return SendUnimplementedResponse("Selecting all processes not supported");
   if (pid == LLDB_INVALID_PROCESS_ID)
     return SendErrorResponse(
-        llvm::createStringError("No current process and no PID provided"));
+        llvm::createStringError("no current process and no PID provided"));
 
   // Check the process ID and find respective process instance.
   auto new_process_it = m_debugged_processes.find(pid);
@@ -4121,7 +4121,7 @@ GDBRemoteCommunicationServerLLGS::Handle_T(StringExtractorGDBRemote &packet) {
   auto pid_tid = packet.GetPidTid(m_current_process ? m_current_process->GetID()
                                                     : LLDB_INVALID_PROCESS_ID);
   if (!pid_tid)
-    return SendErrorResponse(llvm::createStringError("Malformed thread-id"));
+    return SendErrorResponse(llvm::createStringError("malformed thread-id"));
 
   lldb::pid_t pid = pid_tid->first;
   lldb::tid_t tid = pid_tid->second;
@@ -4130,7 +4130,7 @@ GDBRemoteCommunicationServerLLGS::Handle_T(StringExtractorGDBRemote &packet) {
   // explicit about the error.
   if (pid == LLDB_INVALID_PROCESS_ID)
     return SendErrorResponse(
-        llvm::createStringError("No current process and no PID provided"));
+        llvm::createStringError("no current process and no PID provided"));
 
   // Check the process ID and find respective process instance.
   auto new_process_it = m_debugged_processes.find(pid);
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 10c176a25cbd9..37597d059ca90 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -462,7 +462,7 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
 
     // Call the static method.
     llvm::Expected<PythonObject> expected_return_object =
-        llvm::createStringError("Not initialized.");
+        llvm::createStringError("not initialized");
     std::apply(
         [&method, &expected_return_object](auto &&...args) {
           llvm::consumeError(expected_return_object.takeError());
@@ -525,7 +525,7 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
     auto transformed_args = TransformArgs(original_args);
 
     llvm::Expected<PythonObject> expected_return_object =
-        llvm::createStringError("Not initialized.");
+        llvm::createStringError("not initialized");
     std::apply(
         [&implementor, &method_name, &expected_return_object](auto &&...args) {
           llvm::consumeError(expected_return_object.takeError());
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index e021e5dab8867..f962fb884d146 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -43,6 +43,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorExtras.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FormatAdapters.h"
 
@@ -1957,14 +1958,17 @@ lldb::ValueObjectSP ScriptInterpreterPythonImpl::GetChildAtIndex(
 llvm::Expected<uint32_t> ScriptInterpreterPythonImpl::GetIndexOfChildWithName(
     const StructuredData::ObjectSP &implementor_sp, const char *child_name) {
   if (!implementor_sp)
-    return llvm::createStringError("Type has no child named '%s'", child_name);
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    child_name);
 
   StructuredData::Generic *generic = implementor_sp->GetAsGeneric();
   if (!generic)
-    return llvm::createStringError("Type has no child named '%s'", child_name);
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    child_name);
   auto *implementor = static_cast<PyObject *>(generic->GetValue());
   if (!implementor)
-    return llvm::createStringError("Type has no child named '%s'", child_name);
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    child_name);
 
   uint32_t ret_val = UINT32_MAX;
 
@@ -1976,7 +1980,8 @@ llvm::Expected<uint32_t> ScriptInterpreterPythonImpl::GetIndexOfChildWithName(
   }
 
   if (ret_val == UINT32_MAX)
-    return llvm::createStringError("Type has no child named '%s'", child_name);
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    child_name);
   return ret_val;
 }
 
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 3518a919c67da..176f1f992c02d 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -3109,13 +3109,13 @@ SymbolFileNativePDB::ResolveUdtDeclaration(PdbTypeSymId type_id) {
 
   auto it = m_udt_declarations.find(type_id.index);
   if (it == m_udt_declarations.end())
-    return llvm::createStringError("No UDT declaration found");
+    return llvm::createStringError("no UDT declaration found");
 
   llvm::StringRef file_name;
   if (it->second.IsIpiIndex) {
     CVType cvt = m_index->ipi().getType(it->second.FileNameIndex);
     if (cvt.kind() != LF_STRING_ID)
-      return llvm::createStringError("File name was not a LF_STRING_ID");
+      return llvm::createStringError("file name was not a LF_STRING_ID");
 
     StringIdRecord sid;
     if (auto err = TypeDeserializer::deserializeAs(cvt, sid))
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 67be014feee4b..fba6aec296324 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -13,6 +13,7 @@
 #include "clang/Frontend/ASTConsumers.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorExtras.h"
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/FormatVariadic.h"
 
@@ -7020,8 +7021,7 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
       break;
     }
   }
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.str().c_str());
+  return llvm::createStringErrorV("type has no child named '{0}'", name);
 }
 
 CompilerType
diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index 091a1e753b255..1c16212d6ddd6 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Support/ErrorExtras.h"
+
 #include "lldb/Symbol/CompilerType.h"
 
 #include "lldb/Core/Debugger.h"
@@ -769,7 +771,7 @@ CompilerType::GetBitSize(ExecutionContextScope *exe_scope) const {
   if (IsValid())
     if (auto type_system_sp = GetTypeSystem())
       return type_system_sp->GetBitSize(m_type, exe_scope);
-  return llvm::createStringError("Invalid type: Cannot determine size");
+  return llvm::createStringError("invalid type: cannot determine size");
 }
 
 llvm::Expected<uint64_t>
@@ -1036,8 +1038,7 @@ CompilerType::GetIndexOfChildWithName(llvm::StringRef name,
       return type_system_sp->GetIndexOfChildWithName(m_type, name,
                                                      omit_empty_base_classes);
   }
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.str().c_str());
+  return llvm::createStringErrorV("type has no child named '{0}'", name);
 }
 
 // Dumping types
diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp
index 7b015bd23b711..fab07112d5400 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -685,7 +685,7 @@ llvm::Error
 SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line,
                                                 AddressRange &range) {
   if (!line_entry.IsValid()) {
-    return llvm::createStringError("Symbol context has no line table.");
+    return llvm::createStringError("symbol context has no line table");
   }
 
   range = line_entry.range;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 34d8b91a42833..c1ad42cf8d21f 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2598,7 +2598,7 @@ Process::ReadModuleFromMemory(const FileSpec &file_spec,
             file_spec.GetPath().c_str());
   ModuleSP module_sp = std::make_shared<Module>(file_spec, ArchSpec());
   if (!module_sp)
-    return llvm::createStringError("Failed to allocate Module");
+    return llvm::createStringError("failed to allocate module");
 
   Status error;
   std::unique_ptr<Progress> progress_up;
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 0168c7d686e37..d802e7b1bf40e 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2601,7 +2601,7 @@ llvm::Expected<lldb::TypeSystemSP>
 Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
                                         bool create_on_demand) {
   if (!m_valid)
-    return llvm::createStringError("Invalid Target");
+    return llvm::createStringError("invalid target");
 
   if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all
                                              // assembly code
@@ -2805,7 +2805,7 @@ void Target::SetDefaultArchitecture(const ArchSpec &arch) {
 llvm::Error Target::SetLabel(llvm::StringRef label) {
   size_t n = LLDB_INVALID_INDEX32;
   if (llvm::to_integer(label, n))
-    return llvm::createStringError("Cannot use integer as target label.");
+    return llvm::createStringError("cannot use integer as target label");
   TargetList &targets = GetDebugger().GetTargetList();
   for (size_t i = 0; i < targets.GetNumTargets(); i++) {
     TargetSP target_sp = targets.GetTargetAtIndex(i);
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index c8e50db2316ad..890c4edbdc809 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -1624,7 +1624,7 @@ llvm::Error Thread::LoadScriptedFrameProvider(
     auto [last_desc, last_id] = m_provider_chain_ids.back();
     auto it = m_frame_providers.find(last_id);
     if (it == m_frame_providers.end())
-      return llvm::createStringError("Previous frame provider not found");
+      return llvm::createStringError("previous frame provider not found");
     SyntheticFrameProviderSP last_provider = it->second;
     StackFrameListSP last_provider_frames = last_provider->GetInputFrames();
     input_frames = std::make_shared<SyntheticStackFrameList>(
diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp
index edad5aa4d490d..5e2a2a0e05af1 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -3044,7 +3044,7 @@ llvm::Expected<lldb::ValueObjectSP> ValueObject::CastDerivedToBaseType(
         "Underlying start & target types should be different");
 
   if (base_type_indices.empty())
-    return llvm::createStringError("Children sequence must be non-empty");
+    return llvm::createStringError("children sequence must be non-empty");
 
   // Both the starting & target types are valid for the cast, and the list of
   // base class indices is non-empty, so we can proceed with the cast.
diff --git a/lldb/source/ValueObject/ValueObjectRegister.cpp b/lldb/source/ValueObject/ValueObjectRegister.cpp
index 97aeaa8bebe63..0d6e54b39ac1d 100644
--- a/lldb/source/ValueObject/ValueObjectRegister.cpp
+++ b/lldb/source/ValueObject/ValueObjectRegister.cpp
@@ -25,6 +25,7 @@
 #include "lldb/Utility/Stream.h"
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ErrorExtras.h"
 
 #include <cassert>
 #include <memory>
@@ -146,8 +147,7 @@ ValueObjectRegisterSet::GetIndexOfChildWithName(llvm::StringRef name) {
     if (reg_info != nullptr)
       return reg_info->kinds[eRegisterKindLLDB];
   }
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.str().c_str());
+  return llvm::createStringErrorV("type has no child named '{0}'", name);
 }
 
 #pragma mark -
diff --git a/lldb/source/ValueObject/ValueObjectSynthetic.cpp b/lldb/source/ValueObject/ValueObjectSynthetic.cpp
index b0e67df5541e9..f03d25f67470f 100644
--- a/lldb/source/ValueObject/ValueObjectSynthetic.cpp
+++ b/lldb/source/ValueObject/ValueObjectSynthetic.cpp
@@ -20,6 +20,7 @@
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorExtras.h"
 #include <optional>
 
 namespace lldb_private {
@@ -364,20 +365,20 @@ ValueObjectSynthetic::GetIndexOfChildWithName(llvm::StringRef name_ref) {
       uint32_t max = index + 1;
       auto num_children = GetNumChildrenIgnoringErrors(max);
       if (index >= num_children)
-        return llvm::createStringError("Subscript index out of range: %zu",
-                                       index);
+        return llvm::createStringErrorV("subscript index out of range: {0}",
+                                        index);
     }
     std::lock_guard<std::mutex> guard(m_child_mutex);
     m_name_toindex[name.GetCString()] = index;
     return index;
   } else if (!found_index && m_synth_filter_up == nullptr) {
-    return llvm::createStringError("Type has no child named '%s'",
-                                   name.AsCString());
+    return llvm::createStringErrorV("type has no child named '{0}'",
+                                    name.GetStringRef());
   } else if (found_index)
     return *found_index;
 
-  return llvm::createStringError("Type has no child named '%s'",
-                                 name.AsCString());
+  return llvm::createStringErrorV("type has no child named '{0}'",
+                                  name.GetStringRef());
 }
 
 bool ValueObjectSynthetic::IsInScope() { return m_parent->IsInScope(); }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/class-type-nullptr-deref.s b/lldb/test/Shell/SymbolFile/DWARF/x86/class-type-nullptr-deref.s
index b47eba78e77cf..d21e469dd1484 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/class-type-nullptr-deref.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/class-type-nullptr-deref.s
@@ -4,7 +4,7 @@
 # RUN: llvm-mc --triple x86_64-pc-linux %s --filetype=obj -o %t
 # RUN: %lldb %t -o "target variable x" -o exit 2>&1 | FileCheck %s
 
-# CHECK: Invalid type: Cannot determine size
+# CHECK: invalid type: cannot determine size
 
 # This tests a fix for a crash. If things are working we don't get a segfault.
 
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-signature-loop.s b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-signature-loop.s
index 73b85fc9fa44e..3a327faed2a3c 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-signature-loop.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-signature-loop.s
@@ -4,7 +4,7 @@
 # RUN: ld.lld %t.o -o %t
 # RUN: %lldb %t -o "target variable e" -b | FileCheck %s
 
-# CHECK: error: Invalid type: Cannot determine size
+# CHECK: error: invalid type: cannot determine size
 
         .type   e, at object               # @e
         .section        .rodata,"a", at progbits
@@ -19,15 +19,15 @@ e:
 .Linfo_string0:
         .asciz  "Hand-written DWARF"
 .Linfo_string1:
-        .asciz  "a.cpp"            
+        .asciz  "a.cpp"
 .Linfo_string3:
-        .asciz  "e"           
+        .asciz  "e"
 .Linfo_string4:
         .asciz  "unsigned int"
 .Linfo_string5:
-        .asciz  "e1"          
+        .asciz  "e1"
 .Linfo_string6:
-        .asciz  "E"           
+        .asciz  "E"
 
         .section        .debug_abbrev,"", at progbits
         .byte   1                       # Abbreviation Code
diff --git a/lldb/test/Shell/Target/target-label.test b/lldb/test/Shell/Target/target-label.test
index 7f4f31e09fa16..cb022f2361d76 100644
--- a/lldb/test/Shell/Target/target-label.test
+++ b/lldb/test/Shell/Target/target-label.test
@@ -19,7 +19,7 @@ target create -l "cat" /bin/cat
 # CHECK: Cannot use label 'cat' since it's set in target #1.
 
 target create -l 42 /bin/cat
-# CHECK: error: Cannot use integer as target label.
+# CHECK: error: cannot use integer as target label
 
 target select 0
 # CHECK: * target #0: [[LS_PATH]]
diff --git a/lldb/unittests/Expression/ExpressionTest.cpp b/lldb/unittests/Expression/ExpressionTest.cpp
index 4b391340dc9f6..c7d4f466e92ee 100644
--- a/lldb/unittests/Expression/ExpressionTest.cpp
+++ b/lldb/unittests/Expression/ExpressionTest.cpp
@@ -36,13 +36,13 @@ static LabelTestCase g_label_test_cases[] = {
      {},
      {"expected function call label prefix '$__lldb_func' but found "
       "'$__lldb_funcc' instead."}},
-    {"", {}, {"malformed function call label."}},
-    {"foo", {}, {"malformed function call label."}},
-    {"$__lldb_func", {}, {"malformed function call label."}},
-    {"$__lldb_func:", {}, {"malformed function call label."}},
-    {"$__lldb_func:blah", {}, {"malformed function call label."}},
-    {"$__lldb_func:blah:0x0", {}, {"malformed function call label."}},
-    {"$__lldb_func:111:0x0:0x0", {}, {"malformed function call label."}},
+    {"", {}, {"malformed function call label"}},
+    {"foo", {}, {"malformed function call label"}},
+    {"$__lldb_func", {}, {"malformed function call label"}},
+    {"$__lldb_func:", {}, {"malformed function call label"}},
+    {"$__lldb_func:blah", {}, {"malformed function call label"}},
+    {"$__lldb_func:blah:0x0", {}, {"malformed function call label"}},
+    {"$__lldb_func:111:0x0:0x0", {}, {"malformed function call label"}},
     {"$__lldb_func:111:abc:0x0:_Z3foov",
      {},
      {"failed to parse module ID from 'abc'."}},



More information about the lldb-commits mailing list