This patch is a part of D101950 which makes LLDB use redeclarations in its internal clang ASTs.
This patch does the following:
- Add an API that allows redeclaring a declaration inside a TypeSystemClang.
- Make the TypeSystemClang APIs work with redeclarations. Mainly making sure we look at redeclarations of DeclContext (see the added calls to getPrimaryContext which for example finds the definition of a class. See also the test for nested types)
- Removes code that assumes a 1-1 mapping between Type and Decl (which is no longer true for redeclarations). The biggest offender here are the APIs for creating classes/templates/etc. as they return all CompilerType (which doesn't identify a unique Decl, but only a redeclaration chain).
- Removed code that tries to eagerly create types for declarations. Types should be created via GetTypeForDecl so that existing types from forward declarations are reused. Otherwise we end up with
The patch also makes that we store the TemplateParameterInfos for template specializations
in the TypeSystemClang. The only reason for this is that Clang is using a different data
structure for storing this info internally so we can't just reuse the information from the
forward declaration when creating the redeclaration (see CreateRedeclaration). This
can be removed once we updated the DWARF parser and the TypeSystemClang APIs
to accept the information as we can find it in the Clang AST.
This shouldn't affect LLDB's functionality on its own as the DWARF parser currently doesn't
create redeclarations. That's why all the tests are unit tests.
The added logic for looking for the right redeclaration should work as before in ASTs that only
have single-decl redeclaration chains (which is what we currently do).