This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Make SBType::IsTypeComplete more consistent by forcing the loading of definitions
ClosedPublic

Authored by teemperor on Oct 27 2021, 5:54 AM.

Details

Summary

Currently calling SBType::IsTypeComplete returns true for record types
if and only if the underlying record in our internal Clang AST has a definition.

The function however doesn't actually force the loading of any external
definition from debug info, so it currently can return false even if the
type is actually defined in a program's debug info but LLDB hasn't lazily
created the definition yet.

This patch changes the behaviour to always load the definition first
so that IsTypeComplete now consistently returns true if there is a
definition in the module/target.

The motivation for this patch is twofold:

  • The API is now arguably more useful for the user which don't know or

care about the internal lazy loading mechanism of LLDB.

  • With D101950 there is no longer a good way to ask a Decl for a definition

without automatically pulling in a definition from the ExternalASTSource. The
current behaviour doesn't seem useful enough to justify the necessary workarounds
to preserve it for a time after D101950.

Note that there was a test that used this API to test lazy loading of debug info
but that has been replaced with TestLazyLoading by now (which just dumps the
internal Clang AST state instead).

Diff Detail

Event Timeline

teemperor created this revision.Oct 27 2021, 5:54 AM
teemperor requested review of this revision.Oct 27 2021, 5:54 AM
teemperor edited the summary of this revision. (Show Details)Oct 27 2021, 5:56 AM
aprantl accepted this revision.Oct 29 2021, 11:24 AM
aprantl added inline comments.
lldb/bindings/interface/SBType.i
841

Thanks for adding this!

This revision is now accepted and ready to land.Oct 29 2021, 11:24 AM
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp