@@ -235,6 +235,35 @@ class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener {
235235 clang::ASTContext *m_src_ctx;
236236 ClangASTImporter &importer;
237237
238+ void CompleteDecl (
239+ Decl *decl,
240+ lldb_private::ClangASTImporter::ASTContextMetadata const &to_context_md) {
241+ // The decl that should be completed has to be imported into the target
242+ // context from some other context.
243+ assert (to_context_md.hasOrigin (decl));
244+ // We should only complete decls coming from the source context.
245+ assert (to_context_md.getOrigin (decl).ctx == m_src_ctx);
246+
247+ Decl *original_decl = to_context_md.getOrigin (decl).decl ;
248+
249+ // Complete the decl now.
250+ TypeSystemClang::GetCompleteDecl (m_src_ctx, original_decl);
251+ if (auto *tag_decl = dyn_cast<TagDecl>(decl)) {
252+ if (auto *original_tag_decl = dyn_cast<TagDecl>(original_decl)) {
253+ if (original_tag_decl->isCompleteDefinition ()) {
254+ m_delegate->ImportDefinitionTo (tag_decl, original_tag_decl);
255+ tag_decl->setCompleteDefinition (true );
256+ }
257+ }
258+
259+ tag_decl->setHasExternalLexicalStorage (false );
260+ tag_decl->setHasExternalVisibleStorage (false );
261+ } else if (auto *container_decl = dyn_cast<ObjCContainerDecl>(decl)) {
262+ container_decl->setHasExternalLexicalStorage (false );
263+ container_decl->setHasExternalVisibleStorage (false );
264+ }
265+ }
266+
238267public:
239268 // / Constructs a CompleteTagDeclsScope.
240269 // / \param importer The ClangASTImporter that we should observe.
@@ -257,30 +286,7 @@ class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener {
257286 NamedDecl *decl = m_decls_to_complete.pop_back_val ();
258287 m_decls_already_completed.insert (decl);
259288
260- // The decl that should be completed has to be imported into the target
261- // context from some other context.
262- assert (to_context_md->hasOrigin (decl));
263- // We should only complete decls coming from the source context.
264- assert (to_context_md->getOrigin (decl).ctx == m_src_ctx);
265-
266- Decl *original_decl = to_context_md->getOrigin (decl).decl ;
267-
268- // Complete the decl now.
269- TypeSystemClang::GetCompleteDecl (m_src_ctx, original_decl);
270- if (auto *tag_decl = dyn_cast<TagDecl>(decl)) {
271- if (auto *original_tag_decl = dyn_cast<TagDecl>(original_decl)) {
272- if (original_tag_decl->isCompleteDefinition ()) {
273- m_delegate->ImportDefinitionTo (tag_decl, original_tag_decl);
274- tag_decl->setCompleteDefinition (true );
275- }
276- }
277-
278- tag_decl->setHasExternalLexicalStorage (false );
279- tag_decl->setHasExternalVisibleStorage (false );
280- } else if (auto *container_decl = dyn_cast<ObjCContainerDecl>(decl)) {
281- container_decl->setHasExternalLexicalStorage (false );
282- container_decl->setHasExternalVisibleStorage (false );
283- }
289+ CompleteDecl (decl, *to_context_md);
284290
285291 to_context_md->removeOrigin (decl);
286292 }
@@ -1370,6 +1376,18 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
13701376 from, m_source_ctx, &to->getASTContext ());
13711377 }
13721378
1379+ if (auto *to_namespace_decl = dyn_cast<NamespaceDecl>(to)) {
1380+ m_main.BuildNamespaceMap (to_namespace_decl);
1381+ to_namespace_decl->setHasExternalVisibleStorage ();
1382+ }
1383+
1384+ MarkDeclImported (from, to);
1385+ }
1386+
1387+ void ClangASTImporter::ASTImporterDelegate::MarkDeclImported (Decl *from,
1388+ Decl *to) {
1389+ Log *log = GetLog (LLDBLog::Expressions);
1390+
13731391 if (auto *to_tag_decl = dyn_cast<TagDecl>(to)) {
13741392 to_tag_decl->setHasExternalLexicalStorage ();
13751393 to_tag_decl->getPrimaryContext ()->setMustBuildLookupTable ();
@@ -1384,11 +1402,6 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
13841402 (to_tag_decl->isCompleteDefinition () ? " complete" : " incomplete" ));
13851403 }
13861404
1387- if (auto *to_namespace_decl = dyn_cast<NamespaceDecl>(to)) {
1388- m_main.BuildNamespaceMap (to_namespace_decl);
1389- to_namespace_decl->setHasExternalVisibleStorage ();
1390- }
1391-
13921405 if (auto *to_container_decl = dyn_cast<ObjCContainerDecl>(to)) {
13931406 to_container_decl->setHasExternalLexicalStorage ();
13941407 to_container_decl->setHasExternalVisibleStorage ();
0 commit comments