This is an archive of the discontinued LLVM Phabricator instance.

Complete complete types early when importing types from Clang module DWARF.
ClosedPublic

Authored by aprantl on Nov 18 2019, 5:35 PM.

Details

Summary

This affects -gmodules only.

Under normal operation pcm_type is a shallow forward declaration
that gets completed later. This is necessary to support cyclic
data structures. If, however, pcm_type is already complete (for
example, because it was loaded for a different target before),
the definition needs to be imported right away, too.
Type::ResolveClangType() effectively ignores the ResolveState
inside type_sp and only looks at IsDefined(), so it never calls
ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(),
which does extra work for Objective-C classes. This would result
in only the forward declaration to be visible.

An alternative implementation would be to sink this into Type::ResolveClangType ( https://github.com/llvm/llvm-project/blob/88235812a71d99c082e7aa2ef9356d43d1f83a80/lldb/source/Symbol/Type.cpp#L589) though it isn't clear to me how to best do this from a layering perspective.

rdar://problem/52134074

Diff Detail

Event Timeline

aprantl created this revision.Nov 18 2019, 5:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2019, 5:35 PM
vsk added a subscriber: vsk.Nov 21 2019, 10:32 AM
vsk added inline comments.
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
236

AIUI, when RequireCompleteType returns false, type completion has failed and a diagnostic is emitted. When that happens, should ParseTypeFromClangModule still proceed to create the type?

aprantl marked an inline comment as done.Nov 21 2019, 10:54 AM
aprantl added inline comments.
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
236

I believe yes, because even the forward declaration alone will be of (limited) usefulness to represent pointer types.

aprantl marked an inline comment as done.Nov 21 2019, 10:55 AM
aprantl added inline comments.
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
236

That said, pcm_type.IsDefined() already tells us that the type has been completed successfully once, so this would be a hard situation to get into.

JDevlieghere accepted this revision.Nov 22 2019, 9:32 AM
JDevlieghere added a subscriber: JDevlieghere.

LGTM

This revision is now accepted and ready to land.Nov 22 2019, 9:32 AM
This revision was automatically updated to reflect the committed changes.