Skip to content

Revert " Reland "[lldb][RPC] Upstream lldb-rpc-gen tool" (#146969)" Attempt 2" #150354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

vvereschaka
Copy link
Contributor

Reverts #148996

Many failed LLDB builders:

  • cross-project-tests-sie-ubuntu
  • cross-project-tests-sie-ubuntu-dwarf5
  • lldb-x86_64-debian
  • lldb-aarch64-ubuntu
  • lldb-arm-ubuntu

@llvmbot
Copy link
Member

llvmbot commented Jul 24, 2025

@llvm/pr-subscribers-lldb

Author: Vladimir Vereschaka (vvereschaka)

Changes

Reverts llvm/llvm-project#148996

Many failed LLDB builders:

  • cross-project-tests-sie-ubuntu
  • cross-project-tests-sie-ubuntu-dwarf5
  • lldb-x86_64-debian
  • lldb-aarch64-ubuntu
  • lldb-arm-ubuntu

Patch is 43.13 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/150354.diff

19 Files Affected:

  • (modified) lldb/cmake/modules/LLDBConfig.cmake (-19)
  • (modified) lldb/test/CMakeLists.txt (+1-6)
  • (removed) lldb/test/Shell/RPC/Generator/Inputs/SBDummy.h ()
  • (removed) lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test (-9)
  • (removed) lldb/test/Shell/RPC/Generator/lit.local.cfg (-3)
  • (modified) lldb/test/Shell/helper/toolchain.py (-10)
  • (modified) lldb/test/Shell/lit.site.cfg.py.in (-1)
  • (modified) lldb/tools/CMakeLists.txt (-6)
  • (removed) lldb/tools/lldb-rpc-gen/CMakeLists.txt (-23)
  • (removed) lldb/tools/lldb-rpc-gen/RPCCommon.cpp (-508)
  • (removed) lldb/tools/lldb-rpc-gen/RPCCommon.h (-108)
  • (removed) lldb/tools/lldb-rpc/CMakeLists.txt (-22)
  • (removed) lldb/tools/lldb-rpc/LLDBRPCGeneration.cmake (-80)
  • (removed) lldb/tools/lldb-rpc/LLDBRPCHeaders.cmake (-101)
  • (renamed) lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp (+14-22)
  • (renamed) lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.cpp ()
  • (renamed) lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.h ()
  • (renamed) lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerSourceEmitter.cpp ()
  • (renamed) lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerSourceEmitter.h ()
diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index 1bc494a48cb03..8c30b6e09d2c7 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -323,23 +323,4 @@ else()
     set(LLDB_CAN_USE_DEBUGSERVER OFF)
 endif()
 
-# In a cross-compile build, we need to skip building the generated
-# lldb-rpc sources in the first phase of host build so that they can
-# get built using the just-built Clang toolchain in the second phase.
-if (NOT DEFINED LLDB_CAN_USE_LLDB_RPC_SERVER)
-  if ((CMAKE_CROSSCOMPILING OR LLVM_HOST_TRIPLE MATCHES "${LLVM_DEFAULT_TARGET_TRIPLE}") AND
-      CMAKE_SYSTEM_NAME MATCHES "AIX|Android|Darwin|FreeBSD|Linux|NetBSD|OpenBSD|Windows")
-    set(LLDB_CAN_USE_LLDB_RPC_SERVER ON)
-  else()
-    set(LLDB_CAN_USE_LLDB_RPC_SERVER OFF)
-  endif()
-endif()
-
-if (CMAKE_CROSSCOMPILING)
-  set(LLDB_BUILD_LLDBRPC OFF CACHE BOOL "")
-  get_host_tool_path(lldb-rpc-gen LLDB_RPC_GEN_EXE lldb_rpc_gen_exe lldb_rpc_gen_target)
-else()
-  set(LLDB_BUILD_LLDBRPC ON CACHE BOOL "")
-endif()
-
 include(LLDBGenerateConfig)
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index b786edc46cd2f..6449ac5a9247f 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -132,10 +132,6 @@ if(TARGET lldb-framework)
   add_lldb_test_dependency(lldb-framework)
 endif()
 
-if (LLDB_CAN_USE_LLDB_RPC_SERVER)
-  add_lldb_test_dependency(lldb-rpc-generate-sources)
-endif()
-
 # Add dependencies that are not exported targets when building standalone.
 if(NOT LLDB_BUILT_STANDALONE)
   add_lldb_test_dependency(
@@ -253,8 +249,7 @@ llvm_canonicalize_cmake_booleans(
   LLDB_TEST_SHELL_DISABLE_REMOTE
   LLDB_TOOL_LLDB_SERVER_BUILD
   LLDB_USE_SYSTEM_DEBUGSERVER
-  LLDB_IS_64_BITS
-  LLDB_BUILD_LLDBRPC)
+  LLDB_IS_64_BITS)
 
 # Configure the individual test suites.
 add_subdirectory(API)
diff --git a/lldb/test/Shell/RPC/Generator/Inputs/SBDummy.h b/lldb/test/Shell/RPC/Generator/Inputs/SBDummy.h
deleted file mode 100644
index e69de29bb2d1d..0000000000000
diff --git a/lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test b/lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test
deleted file mode 100644
index 15fcf8fb39c7d..0000000000000
--- a/lldb/test/Shell/RPC/Generator/Tests/CheckRPCGenToolByproducts.test
+++ /dev/null
@@ -1,9 +0,0 @@
-RUN: %lldb-rpc-gen --output-dir=%t %S/../Inputs/SBDummy.h
-
-RUN: ls %t | FileCheck %s
-
-# We're just making sure that the tool emits the class names,
-# methods and skipped methods file in the output directory.
-CHECK: SBAPI.def
-CHECK: SBClasses.def
-CHECK: SkippedMethods.txt
diff --git a/lldb/test/Shell/RPC/Generator/lit.local.cfg b/lldb/test/Shell/RPC/Generator/lit.local.cfg
deleted file mode 100644
index db9494781c00c..0000000000000
--- a/lldb/test/Shell/RPC/Generator/lit.local.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-# All tests for the tool need lldb-rpc-gen to be built.
-if not config.lldb_has_lldbrpc:
-   config.unsupported = True
diff --git a/lldb/test/Shell/helper/toolchain.py b/lldb/test/Shell/helper/toolchain.py
index 728f6347242f1..42968128f2702 100644
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -156,16 +156,6 @@ def use_lldb_substitutions(config):
             extra_args=["platform"],
             unresolved="ignore",
         ),
-        ToolSubst(
-            "%lldb-rpc-gen",
-            command=FindTool("lldb-rpc-gen"),
-            # We need the LLDB build directory root to pass into the tool, not the test build root.
-            extra_args=[
-                "-p " + config.lldb_build_directory + "/..",
-                '--extra-arg="-resource-dir=' + config.clang_resource_dir + '"',
-            ],
-            unresolved="ignore",
-        ),
         "lldb-test",
         "lldb-dap",
         ToolSubst(
diff --git a/lldb/test/Shell/lit.site.cfg.py.in b/lldb/test/Shell/lit.site.cfg.py.in
index beaa41e6fd379..5be5359217769 100644
--- a/lldb/test/Shell/lit.site.cfg.py.in
+++ b/lldb/test/Shell/lit.site.cfg.py.in
@@ -33,7 +33,6 @@ config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
 config.have_lldb_server = @LLDB_TOOL_LLDB_SERVER_BUILD@
 config.lldb_system_debugserver = @LLDB_USE_SYSTEM_DEBUGSERVER@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.lldb_has_lldbrpc = @LLDB_BUILD_LLDBRPC@
 # The shell tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-shell")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-shell")
diff --git a/lldb/tools/CMakeLists.txt b/lldb/tools/CMakeLists.txt
index e2f039527ad75..6804dc234555b 100644
--- a/lldb/tools/CMakeLists.txt
+++ b/lldb/tools/CMakeLists.txt
@@ -10,12 +10,6 @@ add_subdirectory(lldb-fuzzer EXCLUDE_FROM_ALL)
 
 add_lldb_tool_subdirectory(lldb-instr)
 add_lldb_tool_subdirectory(lldb-dap)
-if (LLDB_BUILD_LLDBRPC)
-  add_lldb_tool_subdirectory(lldb-rpc-gen)
-endif()
-if (LLDB_CAN_USE_LLDB_RPC_SERVER)
-  add_subdirectory(lldb-rpc)
-endif()
 
 if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
   add_lldb_tool_subdirectory(darwin-debug)
diff --git a/lldb/tools/lldb-rpc-gen/CMakeLists.txt b/lldb/tools/lldb-rpc-gen/CMakeLists.txt
deleted file mode 100644
index 65b76431d1bea..0000000000000
--- a/lldb/tools/lldb-rpc-gen/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-add_lldb_tool(lldb-rpc-gen
-    RPCCommon.cpp
-    server/RPCServerHeaderEmitter.cpp
-    server/RPCServerSourceEmitter.cpp
-    lldb-rpc-gen.cpp
-
-    CLANG_LIBS
-      clangAST
-      clangBasic
-      clangCodeGen
-      clangFrontend
-      clangLex
-      clangRewrite
-      clangSerialization
-      clangTooling
-
-    LINK_COMPONENTS
-      Support
-  )
-
-if (NOT DEFINED LLDB_RPC_GEN_EXE)
-  set(LLDB_RPC_GEN_EXE $<TARGET_FILE:lldb-rpc-gen> CACHE STRING "Executable that generates lldb-rpc-server")
-endif()
diff --git a/lldb/tools/lldb-rpc-gen/RPCCommon.cpp b/lldb/tools/lldb-rpc-gen/RPCCommon.cpp
deleted file mode 100644
index 34791fa8ef231..0000000000000
--- a/lldb/tools/lldb-rpc-gen/RPCCommon.cpp
+++ /dev/null
@@ -1,508 +0,0 @@
-//===-- RPCCommon.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 "RPCCommon.h"
-
-#include "clang/AST/AST.h"
-#include "clang/AST/Attr.h"
-#include "clang/AST/DeclBase.h"
-#include "clang/AST/Mangle.h"
-#include "clang/Lex/Lexer.h"
-
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/raw_ostream.h"
-
-#include <cstring>
-
-using namespace clang;
-
-// We intentionally do not generate some classes because they are currently
-// inconvenient, they aren't really used by most consumers, or we're not sure
-// why they exist.
-static constexpr llvm::StringRef DisallowedClasses[] = {
-    "SBCommunication", // This class is pretty much unused by consumers, so we
-                       // skip it.
-    "SBInputReader",   // This class is pretty much unused by consumers, so we
-                       // skip it.
-    "SBCommandPluginInterface", // This class uses virtual functions, and the SB
-                                // API should not have those, so we skip this
-                                // class.
-    "SBCommand", // There's nothing too difficult about this one, but many of
-                 // its methods take a SBCommandPluginInterface pointer so
-                 // there's no reason to support this.
-};
-
-// NOTE: In lldb-rpc-gen, we use mangled names when we need to work with
-// functions. We do this because we support many functions that have overloads,
-// and mangled names have no ambiguity which makes it easier to keep track of.
-// This is also possible since the LLDB SB API is stable.
-
-// We intentionally avoid generating certain methods either because they are
-// difficult to support correctly or they aren't really used much from C++.
-// NOTE: These methods are marked as deprecated using LLDB_DEPRECATED.
-// Normally this macro defines to the deprecated annotation, but this
-// functionality is removed in SBDefines.h when generating SWIG bindings which
-// we use for testing. Because of this, there is no annotation for the tool to
-// pick up on so this list will be used while we have this restriction in
-// SBDefines.h.
-static constexpr llvm::StringRef DisallowedMethods[] = {
-    // The threading functionality in SBHostOS is deprecated and thus we do not
-    // generate them. It would be ideal to add the annotations to the methods
-    // and then support not generating deprecated methods. However, without
-    // annotations the generator generates most things correctly. This one is
-    // problematic because it returns a pointer to an "opaque" structure
-    // (thread_t) that is not `void *`, so special casing it is more effort than
-    // it's worth.
-    "_ZN4lldb8SBHostOS10ThreadJoinEP17_opaque_pthread_tPPvPNS_7SBErrorE",
-    "_ZN4lldb8SBHostOS12ThreadCancelEP17_opaque_pthread_tPNS_7SBErrorE",
-    "_ZN4lldb8SBHostOS12ThreadCreateEPKcPFPvS3_ES3_PNS_7SBErrorE",
-    "_ZN4lldb8SBHostOS12ThreadDetachEP17_opaque_pthread_tPNS_7SBErrorE",
-    "_ZN4lldb8SBHostOS13ThreadCreatedEPKc",
-};
-
-static constexpr llvm::StringRef ClassesWithoutDefaultCtor[] = {
-    "SBHostOS",
-    "SBReproducer",
-};
-
-static constexpr llvm::StringRef ClassesWithoutCopyOperations[] = {
-    "SBHostOS",
-    "SBReproducer",
-    "SBStream",
-    "SBProgress",
-};
-
-static constexpr llvm::StringRef MethodsWithPointerPlusLen[] = {
-    "_ZN4lldb6SBData11ReadRawDataERNS_7SBErrorEyPvm",
-    "_ZN4lldb6SBData7SetDataERNS_7SBErrorEPKvmNS_9ByteOrderEh",
-    "_ZN4lldb6SBData20SetDataWithOwnershipERNS_7SBErrorEPKvmNS_9ByteOrderEh",
-    "_ZN4lldb6SBData25CreateDataFromUInt64ArrayENS_9ByteOrderEjPym",
-    "_ZN4lldb6SBData25CreateDataFromUInt32ArrayENS_9ByteOrderEjPjm",
-    "_ZN4lldb6SBData25CreateDataFromSInt64ArrayENS_9ByteOrderEjPxm",
-    "_ZN4lldb6SBData25CreateDataFromSInt32ArrayENS_9ByteOrderEjPim",
-    "_ZN4lldb6SBData25CreateDataFromDoubleArrayENS_9ByteOrderEjPdm",
-    "_ZN4lldb6SBData22SetDataFromUInt64ArrayEPym",
-    "_ZN4lldb6SBData22SetDataFromUInt32ArrayEPjm",
-    "_ZN4lldb6SBData22SetDataFromSInt64ArrayEPxm",
-    "_ZN4lldb6SBData22SetDataFromSInt32ArrayEPim",
-    "_ZN4lldb6SBData22SetDataFromDoubleArrayEPdm",
-    "_ZN4lldb10SBDebugger22GetDefaultArchitectureEPcm",
-    "_ZN4lldb10SBDebugger13DispatchInputEPvPKvm",
-    "_ZN4lldb10SBDebugger13DispatchInputEPKvm",
-    "_ZN4lldb6SBFile4ReadEPhmPm",
-    "_ZN4lldb6SBFile5WriteEPKhmPm",
-    "_ZNK4lldb10SBFileSpec7GetPathEPcm",
-    "_ZN4lldb10SBFileSpec11ResolvePathEPKcPcm",
-    "_ZN4lldb8SBModule10GetVersionEPjj",
-    "_ZN4lldb12SBModuleSpec12SetUUIDBytesEPKhm",
-    "_ZNK4lldb9SBProcess9GetSTDOUTEPcm",
-    "_ZNK4lldb9SBProcess9GetSTDERREPcm",
-    "_ZNK4lldb9SBProcess19GetAsyncProfileDataEPcm",
-    "_ZN4lldb9SBProcess10ReadMemoryEyPvmRNS_7SBErrorE",
-    "_ZN4lldb9SBProcess11WriteMemoryEyPKvmRNS_7SBErrorE",
-    "_ZN4lldb9SBProcess21ReadCStringFromMemoryEyPvmRNS_7SBErrorE",
-    "_ZNK4lldb16SBStructuredData14GetStringValueEPcm",
-    "_ZN4lldb8SBTarget23BreakpointCreateByNamesEPPKcjjRKNS_"
-    "14SBFileSpecListES6_",
-    "_ZN4lldb8SBTarget10ReadMemoryENS_9SBAddressEPvmRNS_7SBErrorE",
-    "_ZN4lldb8SBTarget15GetInstructionsENS_9SBAddressEPKvm",
-    "_ZN4lldb8SBTarget25GetInstructionsWithFlavorENS_9SBAddressEPKcPKvm",
-    "_ZN4lldb8SBTarget15GetInstructionsEyPKvm",
-    "_ZN4lldb8SBTarget25GetInstructionsWithFlavorEyPKcPKvm",
-    "_ZN4lldb8SBThread18GetStopDescriptionEPcm",
-    // The below mangled names are used for dummy methods in shell tests
-    // that test the emitters' output. If you're adding any new mangled names
-    // from the actual SB API to this list please add them above.
-    "_ZN4lldb33SBRPC_"
-    "CHECKCONSTCHARPTRPTRWITHLEN27CheckConstCharPtrPtrWithLenEPPKcm",
-    "_ZN4lldb19SBRPC_CHECKARRAYPTR13CheckArrayPtrEPPKcm",
-    "_ZN4lldb18SBRPC_CHECKVOIDPTR12CheckVoidPtrEPvm",
-};
-
-// These classes inherit from rpc::ObjectRef directly (as opposed to
-// rpc::LocalObjectRef). Changing them from ObjectRef to LocalObjectRef is ABI
-// breaking, so we preserve that compatibility here.
-//
-// lldb-rpc-gen emits classes as LocalObjectRefs by default.
-//
-// FIXME: Does it matter which one it emits by default?
-static constexpr llvm::StringRef ClassesThatInheritFromObjectRef[] = {
-    "SBAddress",
-    "SBBreakpointName",
-    "SBCommandInterpreter",
-    "SBCommandReturnObject",
-    "SBError",
-    "SBExecutionContext",
-    "SBExpressionOptions",
-    "SBFileSpec",
-    "SBFileSpecList",
-    "SBFormat",
-    "SBFunction",
-    "SBHistoricalFrame",
-    "SBHistoricalLineEntry",
-    "SBHistoricalLineEntryList",
-    "SBLineEntry",
-    "SBStream",
-    "SBStringList",
-    "SBStructuredData",
-    "SBSymbolContext",
-    "SBSymbolContextList",
-    "SBTypeMember",
-    "SBTypeSummaryOptions",
-    "SBValueList",
-};
-
-QualType lldb_rpc_gen::GetUnderlyingType(QualType T) {
-  QualType UnderlyingType;
-  if (T->isPointerType())
-    UnderlyingType = T->getPointeeType();
-  else if (T->isReferenceType())
-    UnderlyingType = T.getNonReferenceType();
-  else
-    UnderlyingType = T;
-
-  return UnderlyingType;
-}
-
-QualType lldb_rpc_gen::GetUnqualifiedUnderlyingType(QualType T) {
-  return GetUnderlyingType(T).getUnqualifiedType();
-}
-
-std::string lldb_rpc_gen::GetMangledName(ASTContext &Context,
-                                         CXXMethodDecl *MDecl) {
-  std::string Mangled;
-  llvm::raw_string_ostream MangledStream(Mangled);
-
-  GlobalDecl GDecl;
-  if (const auto *CtorDecl = dyn_cast<CXXConstructorDecl>(MDecl))
-    GDecl = GlobalDecl(CtorDecl, Ctor_Complete);
-  else if (const auto *DtorDecl = dyn_cast<CXXDestructorDecl>(MDecl))
-    GDecl = GlobalDecl(DtorDecl, Dtor_Deleting);
-  else
-    GDecl = GlobalDecl(MDecl);
-
-  MangleContext *MC = Context.createMangleContext();
-  MC->mangleName(GDecl, MangledStream);
-  return Mangled;
-}
-
-static auto CheckTypeForLLDBPrivate = [](const Type *Ty) {};
-bool lldb_rpc_gen::TypeIsFromLLDBPrivate(QualType T) {
-  auto CheckTypeForLLDBPrivate = [](const Type *Ty) {
-    if (!Ty)
-      return false;
-    const auto *CXXRDecl = Ty->getAsCXXRecordDecl();
-    if (!CXXRDecl)
-      return false;
-    const auto *NSDecl =
-        llvm::dyn_cast<NamespaceDecl>(CXXRDecl->getDeclContext());
-    if (!NSDecl)
-      return false;
-    return NSDecl->getName() == "lldb_private";
-  };
-
-  // First, get the underlying type (remove qualifications and strip off any
-  // pointers/references). Then we'll need to desugar this type. This will
-  // remove things like typedefs, so instead of seeing "lldb::DebuggerSP" we'll
-  // actually see something like "std::shared_ptr<lldb_private::Debugger>".
-  QualType UnqualifiedUnderlyingType = GetUnqualifiedUnderlyingType(T);
-  const Type *DesugaredType =
-      UnqualifiedUnderlyingType->getUnqualifiedDesugaredType();
-  assert(DesugaredType && "DesugaredType from a valid Type is nullptr!");
-
-  // Check the type itself.
-  if (CheckTypeForLLDBPrivate(DesugaredType))
-    return true;
-
-  // If that didn't work, it's possible that the type has a template argument
-  // that is an lldb_private type.
-  if (const auto *TemplateSDecl =
-          llvm::dyn_cast_or_null<ClassTemplateSpecializationDecl>(
-              DesugaredType->getAsCXXRecordDecl())) {
-    for (const TemplateArgument &TA :
-         TemplateSDecl->getTemplateArgs().asArray()) {
-      if (TA.getKind() != TemplateArgument::Type)
-        continue;
-      if (CheckTypeForLLDBPrivate(TA.getAsType().getTypePtr()))
-        return true;
-    }
-  }
-  return false;
-}
-
-bool lldb_rpc_gen::TypeIsSBClass(QualType T) {
-  QualType UnqualifiedUnderlyingType = GetUnqualifiedUnderlyingType(T);
-  const auto *CXXRDecl = UnqualifiedUnderlyingType->getAsCXXRecordDecl();
-  if (!CXXRDecl)
-    return false; // SB Classes are always C++ classes
-
-  return CXXRDecl->getName().starts_with("SB");
-}
-
-bool lldb_rpc_gen::TypeIsConstCharPtr(QualType T) {
-  if (!T->isPointerType())
-    return false;
-
-  QualType UnderlyingType = T->getPointeeType();
-  if (!UnderlyingType.isConstQualified())
-    return false;
-
-  // NOTE: We should be able to do `UnderlyingType->isCharType` but that will
-  // return true for `const uint8_t *` since that is effectively an unsigned
-  // char pointer. We currently do not support pointers other than `const char
-  // *` and `const char **`.
-
-  // NOTE: Checking that the underlying type is a signed integer works on Darwin
-  // platforms, but Linux platforms expect that the underlying type is an
-  // unsigned integer.
-  return UnderlyingType->isSpecificBuiltinType(BuiltinType::Char_S) ||
-         UnderlyingType->isSpecificBuiltinType(BuiltinType::SChar) ||
-         UnderlyingType->isSpecificBuiltinType(BuiltinType::Char_U) ||
-         UnderlyingType->isSpecificBuiltinType(BuiltinType::UChar);
-}
-
-bool lldb_rpc_gen::TypeIsConstCharPtrPtr(QualType T) {
-  if (!T->isPointerType())
-    return false;
-
-  return TypeIsConstCharPtr(T->getPointeeType());
-}
-
-bool lldb_rpc_gen::TypeIsDisallowedClass(QualType T) {
-  QualType UUT = GetUnqualifiedUnderlyingType(T);
-  const auto *CXXRDecl = UUT->getAsCXXRecordDecl();
-  if (!CXXRDecl)
-    return false;
-
-  llvm::StringRef DeclName = CXXRDecl->getName();
-  for (const llvm::StringRef DisallowedClass : DisallowedClasses)
-    if (DeclName == DisallowedClass)
-      return true;
-  return false;
-}
-
-bool lldb_rpc_gen::TypeIsCallbackFunctionPointer(QualType T) {
-  return T->isFunctionPointerType();
-}
-
-bool lldb_rpc_gen::MethodIsDisallowed(ASTContext &Context,
-                                      CXXMethodDecl *MDecl) {
-  bool isDisallowed = false;
-  std::string MangledName = lldb_rpc_gen::GetMangledName(Context, MDecl);
-  if (llvm::is_contained(DisallowedMethods, MangledName))
-    isDisallowed = true;
-
-  if (MDecl->hasAttrs()) {
-    for (auto *attr : MDecl->getAttrs()) {
-      if (strcmp(attr->getAttrName()->getNameStart(), "deprecated") == 0)
-        isDisallowed = true;
-    }
-  }
-  return isDisallowed;
-}
-
-bool lldb_rpc_gen::HasCallbackParameter(CXXMethodDecl *MDecl) {
-  bool HasCallbackParameter = false;
-  bool HasBatonParameter = false;
-  auto End = MDecl->parameters().end();
-  for (auto Iter = MDecl->parameters().begin(); Iter != End; Iter++) {
-    if ((*Iter)->getType()->isFunctionPointerType())
-      HasCallbackParameter = true;
-    else if ((*Iter)->getType()->isVoidPointerType())
-      HasBatonParameter = true;
-  }
-
-  return HasCallbackParameter && HasBatonParameter;
-}
-
-// NOTE: There's possibly a more clever way to do this, but we're keeping
-// the string replacement way here. Here is why it is written this way:
-// By the time we have already created a `Method` object, we have extracted the
-// `QualifiedName` and the relevant QualTypes for parameters/return types, many
-// of which contains "lldb::" in them. To change it in a way that would be
-// friendly to liblldbrpc, we would need to have a way of replacing that
-// namespace at the time of creating a Method, and only for liblldbrpc methods.
-// IMO this would complicate Method more than what I'm doing here, and not
-// necessarily for any more benefit.
-// In clang-tools-extra, there is a ChangeNamespaces tool which tries to do
-// something similar to this. It also operates primarily on string replacement,
-// but uses more sophisticated clang tooling to do so.
-// For now, this will do what we need it to do.
-std::string
-lldb_rpc_gen::ReplaceLLDBNamespaceWithRPCNamespace(std::string Name) {
-  const char *lldb_namespace = "lldb::";
-  auto Pos = Name.find(lldb_namespace);
-  while (Pos != std::string::npos) {
-    constexpr size_t SizeOfLLDBNamespace = 6;
-    Name.replace(Pos, SizeOfLLDBNamespace, "lldb_rpc::");
-    Pos = Name.find(lldb_namespace);
-  }
-  return Name;
-}
-
-std::string lldb_rpc_gen::StripLLDBNamespace(std::string Name) {
-  const char *lldb_namespace = "lldb::";
-  auto Pos = Name.find(lldb_namespace...
[truncated]

@chelcassanova chelcassanova self-requested a review July 24, 2025 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants