[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 5 01:59:33 PDT 2025
================
@@ -0,0 +1,107 @@
+//===-- RPCCommon.h -------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_RPC_GEN_RPCCOMMON_H
+#define LLDB_RPC_GEN_RPCCOMMON_H
+
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include <string>
+
+using namespace clang;
+
+namespace lldb_rpc_gen {
+QualType GetUnderlyingType(QualType T);
+QualType GetUnqualifiedUnderlyingType(QualType T);
+std::string GetMangledName(ASTContext &Context, CXXMethodDecl *MDecl);
+
+bool TypeIsFromLLDBPrivate(QualType T);
+bool TypeIsSBClass(QualType T);
+bool TypeIsConstCharPtr(QualType T);
+bool TypeIsConstCharPtrPtr(QualType T);
+bool TypeIsDisallowedClass(QualType T);
+bool TypeIsCallbackFunctionPointer(QualType T);
+
+bool MethodIsDisallowed(ASTContext &Context, CXXMethodDecl *MDecl);
+bool HasCallbackParameter(CXXMethodDecl *MDecl);
+
+std::string ReplaceLLDBNamespaceWithRPCNamespace(std::string Name);
+std::string StripLLDBNamespace(std::string Name);
+bool SBClassRequiresDefaultCtor(const std::string &ClassName);
+bool SBClassRequiresCopyCtorAssign(const std::string &ClassName);
+bool SBClassInheritsFromObjectRef(const std::string &ClassName);
+std::string GetSBClassNameFromType(QualType T);
+struct Param {
+ std::string Name;
+ QualType Type;
+ std::string DefaultValueText;
+ bool IsFollowedByLen;
+};
+
+enum GenerationKind : bool { eServer, eLibrary };
+
+struct Method {
+ enum Type { eOther, eConstructor, eDestructor };
+
+ Method(CXXMethodDecl *MDecl, const PrintingPolicy &Policy,
+ ASTContext &Context);
+
+ // Adding a '<' allows us to use Methods in ordered containers.
+ bool operator<(const lldb_rpc_gen::Method &rhs) const;
+ const PrintingPolicy &Policy;
+ const ASTContext &Context;
+ std::string QualifiedName;
+ std::string BaseName;
+ std::string MangledName;
+ QualType ReturnType;
+ QualType ThisType;
+ std::vector<Param> Params;
+ bool IsConst = false;
+ bool IsInstance = false;
+ bool IsCtor = false;
+ bool IsCopyCtor = false;
+ bool IsCopyAssign = false;
+ bool IsMoveCtor = false;
+ bool IsMoveAssign = false;
+ bool IsDtor = false;
+ bool IsConversionMethod = false;
+ bool IsExplicitCtorOrConversionMethod = false;
+ bool ContainsFunctionPointerParameter = false;
+
+ std::string CreateParamListAsString(GenerationKind Generation,
+ bool IncludeDefaultValue = false) const;
+
+ bool RequiresConnectionParameter() const;
+};
+
+std::string
+GetDefaultArgumentsForConstructor(std::string ClassName,
+ const lldb_rpc_gen::Method &method);
+
+class FileEmitter {
+protected:
+ FileEmitter(std::unique_ptr<llvm::ToolOutputFile> &&OutputFile)
----------------
DavidSpickett wrote:
Understood
https://github.com/llvm/llvm-project/pull/138031
More information about the lldb-commits
mailing list