With the activated C++ module prototype LLDB currently runs into the issue that certain expressions
return declarations that are requiring a lot of importing and merging work from ClangASTImporter/ASTImporter.
For example unordered_map_var.size() has a return type of std::unordered_map<Key, Val>::size_type which
would require importing std::unordered_map<Key, Val> and all the declarations that it references.
Importing all these AST nodes is causing frequent crashes in LLDB when we end up failing to import/merge
some of the declarations or the generated AST isn't fully correct. So far we worked around this in the tests by
casting all expressions to some underlying type, but until we fix all the underlying we probably have to do
this automatically for the user to make this less frustrating to use (and the tests less tedious to write).
This patch automatically desugars the return types of expressions step-by-step until we reach a type that
no longer requires us to import any template. The current criteria is that we keep desugaring until we reach
a typedef'd type where the typedef is no longer inside a C++ module template/class. This means that things
like container.size() now return size_t instead of the std::container<T>::size_t types we get so far.
Also the patch removes all the now obsolete casts from the tests which are now done automatically.
The real solution to the problem is obviously to actually fix all the underlying bugs that cause us to assert/crash
when we import those declarations. This will be done on the side and this function is will whitelist more and
more declarations over time while I try to get the different STL declarations working (see for example D85141)
Maybe for (;!decl_context->isTranslationUnit()); decl_context = decl_context->getParent()) {