This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by teemperor on Jan 10 2020, 7:14 AM.

Details

Summary

This is a port of D67803 of 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).

Diff Detail

Event Timeline

teemperor created this revision.Jan 10 2020, 7:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 10 2020, 7:14 AM

FWIW, this isn't really a finished patch yet as I actually wanted to write several unit tests for this, but as it fixes the gmodules failures on master I thought I might as well put it up now.

shafik accepted this revision.Jan 10 2020, 9:56 AM

LGTM

This revision is now accepted and ready to land.Jan 10 2020, 9:56 AM
This revision was automatically updated to reflect the committed changes.