How to get mangled function names from type information with LLVM?

Hello guys, I need to get mangled names based on the provided type information for functions. I got recommended LLVM to try to do this.
So I have all the type information: namespace, class name, function name, calling convention, return type, argument types and names. I need to get an MSVC-mangled name.

Could I do this with LLVM without compiling a whole executable with debugging symbols?

There’s this: MicrosoftCXXNameMangler class inside /llvm/llvm-project/blob/main/clang/lib/AST/MicrosoftMangle.cpp file.

But I don’t quite understand which objects to instantiate other than the MicrosoftCXXNameMangler, and also how to properly instantiate them and then use.

So let’s say I have the type information:

Function:
Class Namespace: None
Calling convention: __stdcall
Function Name: Add
Class Name: MyClass1
Return type: int
Arguments: int Integer1, int Integer2

That would type information for this code:

class MyClass1 {
public:
  int Add(int Integer1, int Integer2) { return Integer1 + Integer2 };
};

Am I looking in the right place in that MicrosoftMangle.cpp? I looked through the code, and I think I need to instantiate MicrosoftCXXNameMangler object and then call mangleFunctionType and provide it with FunctionType object.

Then to create the FunctionType object, I call FunctionType::get method and I have to provide return type and arguments, which are Type objects, and if it’s a function with variable arguments.

The problem I with the Type class is that all of its’ constructors are private. The comment says that lldb_private::SymbolFileCommon can create types as it is declared as a friend class. The SymbolFileCommon has MakeType function that has this signature:

  lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name,
                        std::optional<uint64_t> byte_size,
                        SymbolContextScope *context,
                        lldb::user_id_t encoding_uid,
                        Type::EncodingDataType encoding_uid_type,
                        const Declaration &decl,
                        const CompilerType &compiler_qual_type,
                        Type::ResolveState compiler_type_resolve_state,
                        uint32_t opaque_payload = 0)

This is where I don’t understand how to create the types for the return and argument types for the function. So name is for the type’s name. byte_size is for the size of the type, fine. But I don’t understand all the other arguments for it: SymbolContextScope *context, lldb::user_id_t encoding_uid, Type::EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_qual_type, Type::ResolveState compiler_type_resolve_state, uint32_t opaque_payload = 0.

Can someone confirm that I’m digging in the right direction and that it’s a valid way to do what I want to do? Are there any examples in the code base of creating the types for function return and arguments in particular? And the FunctionType itself?

How hard is it going to be to manually use these classes and instantiate all these objects and get mangled names without compiling and starting the whole clang?