[lldb] Remove FieldDecl stealing hack by rerouting indirect imports to the…

Authored by teemperor on Jan 10 2020, 10:17 AM.

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.


[lldb] Remove FieldDecl stealing hack by rerouting indirect imports to the original AST

This is a port of D67803 that was about preventing indirect importing to our scratch context when evaluating expressions.

D67803 already has a pretty long explanation of how this works, but the idea is that instead
of importing declarations indirectly over the expression AST (i.e., Debug info AST -> Expression AST -> scratch AST)
we instead directly import the declaration from the debug info AST to the scratch AST.

The difference from D67803 is that here we have to do this in the ASTImporterDelegate (which is our ASTImporter
subclass we use in LLDB). It has the same information as the ExternalASTMerger in D67803 as it can access the
ClangASTImporter (which also keeps track of where Decls originally came from).

With this patch we can also delete the FieldDecl stealing hack in the ClangASTSource (this was only necessary as the
indirect imports caused the creation of duplicate Record declarations but we needed the fields in the Record decl
we originally found in the scratch ASTContext).

This also fixes the current gmodules failures where we fail to find std::vector fields after an indirect import
over the expression AST (where it seems even our FieldDecl stealing hack can't save us from).

Reviewers: shafik, aprantl

Reviewed By: shafik

Subscribers: JDevlieghere, lldb-commits, mib, labath, friss

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72507