[llvm-branch-commits] [lldb] release/22.x: [lldb][Target] Allow eLanguageTypeAssembly to use ScratchTypeSystemClang (#183771) (PR #184187)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Mar 2 09:47:30 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: None (llvmbot)

<details>
<summary>Changes</summary>

Backport 447eba88c8d7f219667c9914a0d91bf44c1d1512

Requested by: @<!-- -->Michael137

---
Full diff: https://github.com/llvm/llvm-project/pull/184187.diff


3 Files Affected:

- (modified) lldb/source/Target/Target.cpp (+2-1) 
- (modified) lldb/unittests/Target/CMakeLists.txt (+2) 
- (added) lldb/unittests/Target/ScratchTypeSystemTest.cpp (+59) 


``````````diff
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 1ff115e980cf9..bba630636e526 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2618,7 +2618,8 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
 
   if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all
                                              // assembly code
-      || language == eLanguageTypeUnknown) {
+      || language == eLanguageTypeAssembly ||
+      language == eLanguageTypeUnknown) {
     LanguageSet languages_for_expressions =
         Language::GetLanguagesSupportingTypeSystemsForExpressions();
 
diff --git a/lldb/unittests/Target/CMakeLists.txt b/lldb/unittests/Target/CMakeLists.txt
index 83eec3b1117bf..47df8c600ca19 100644
--- a/lldb/unittests/Target/CMakeLists.txt
+++ b/lldb/unittests/Target/CMakeLists.txt
@@ -11,12 +11,14 @@ add_lldb_unittest(TargetTests
   PathMappingListTest.cpp
   RegisterFlagsTest.cpp
   RemoteAwarePlatformTest.cpp
+  ScratchTypeSystemTest.cpp
   StackFrameRecognizerTest.cpp
   SummaryStatisticsTest.cpp
   FindFileTest.cpp
 
   LINK_COMPONENTS
       Support
+      TestingSupport
   LINK_LIBS
       lldbCore
       lldbHost
diff --git a/lldb/unittests/Target/ScratchTypeSystemTest.cpp b/lldb/unittests/Target/ScratchTypeSystemTest.cpp
new file mode 100644
index 0000000000000..b86cab80293a5
--- /dev/null
+++ b/lldb/unittests/Target/ScratchTypeSystemTest.cpp
@@ -0,0 +1,59 @@
+//===-- TestTypeSystem.cpp -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/TestUtilities.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/lldb-enumerations.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+class TestTypeSystemMap : public testing::Test {
+public:
+  SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems;
+
+protected:
+  void SetUp() override {
+    std::call_once(TestUtilities::g_debugger_initialize_flag,
+                   []() { Debugger::Initialize(nullptr); });
+  };
+
+  DebuggerSP m_debugger_sp;
+  PlatformSP m_platform_sp;
+};
+
+TEST_F(TestTypeSystemMap, GetScratchTypeSystemForLanguage) {
+  // Set up the debugger, make sure that was done properly.
+  TargetSP target_sp;
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
+
+  m_debugger_sp = Debugger::CreateInstance();
+
+  auto &target = m_debugger_sp->GetDummyTarget();
+  EXPECT_THAT_EXPECTED(
+      target.GetScratchTypeSystemForLanguage(lldb::eLanguageTypeMipsAssembler),
+      llvm::FailedWithMessage("No expression support for any languages"));
+  EXPECT_THAT_EXPECTED(
+      target.GetScratchTypeSystemForLanguage(lldb::eLanguageTypeAssembly),
+      llvm::FailedWithMessage("No expression support for any languages"));
+  EXPECT_THAT_EXPECTED(
+      target.GetScratchTypeSystemForLanguage(lldb::eLanguageTypeUnknown),
+      llvm::FailedWithMessage("No expression support for any languages"));
+  EXPECT_THAT_EXPECTED(
+      target.GetScratchTypeSystemForLanguage(lldb::eLanguageTypeModula2),
+      llvm::FailedWithMessage("TypeSystem for language modula2 doesn't exist"));
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/184187


More information about the llvm-branch-commits mailing list