Right now when using the ASTImporter to bring struct declarations from a C++ AST to a C AST, the
resulting imported Decl will just be a CXXRecordDecl even though in a C AST we only have RecordDecls.
When the 'to' AST already has a RecordDecl with the same name we currently also fail to merge the
CXXRecordDecl from the 'from' AST into it and instead just create a duplicated CXXRecordDecl.
Our use case for this is actually for Swift where the ASTImporter is used in a lot of rather adventurous
way to move things around clang::ASTContext instances. In LLDB we are (at the moment) always in
an AST that supports C++ so this won't have any effect on LLDB itself.
This patch introduces basic conversion functionality that converts a CXXRecordDecl that is just expressing
a valid C struct into a RecordDecl. If the target AST already has a equivalent RecordDecl this will now
also merge the 'from' record into that one.
There are a bunch of things that this patch doesn't try to fix:
- Unsupported C++ nodes such as user-defined constructors are still imported when explicitly requested by the user.
- C to C++ conversion for structs (i.e., adding the missing pieces to a RecordDecl and turn it into a CXXRecordDecl).
I'll try to address those in follow up patches. I also have some plans to at least implement the error handling for
importing from Objective-C to non-Objective-C contexts. The same goes for importing nodes that are exclusive
to one C/C++ standard to an AST with (usually earlier) standard where the node can't exist.
clang-format: please reformat the code