@@ -235,6 +235,35 @@ class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener {
235
235
clang::ASTContext *m_src_ctx;
236
236
ClangASTImporter &importer;
237
237
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
+
238
267
public:
239
268
// / Constructs a CompleteTagDeclsScope.
240
269
// / \param importer The ClangASTImporter that we should observe.
@@ -257,30 +286,7 @@ class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener {
257
286
NamedDecl *decl = m_decls_to_complete.pop_back_val ();
258
287
m_decls_already_completed.insert (decl);
259
288
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);
284
290
285
291
to_context_md->removeOrigin (decl);
286
292
}
@@ -1370,6 +1376,18 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
1370
1376
from, m_source_ctx, &to->getASTContext ());
1371
1377
}
1372
1378
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
+
1373
1391
if (auto *to_tag_decl = dyn_cast<TagDecl>(to)) {
1374
1392
to_tag_decl->setHasExternalLexicalStorage ();
1375
1393
to_tag_decl->getPrimaryContext ()->setMustBuildLookupTable ();
@@ -1384,11 +1402,6 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
1384
1402
(to_tag_decl->isCompleteDefinition () ? " complete" : " incomplete" ));
1385
1403
}
1386
1404
1387
- if (auto *to_namespace_decl = dyn_cast<NamespaceDecl>(to)) {
1388
- m_main.BuildNamespaceMap (to_namespace_decl);
1389
- to_namespace_decl->setHasExternalVisibleStorage ();
1390
- }
1391
-
1392
1405
if (auto *to_container_decl = dyn_cast<ObjCContainerDecl>(to)) {
1393
1406
to_container_decl->setHasExternalLexicalStorage ();
1394
1407
to_container_decl->setHasExternalVisibleStorage ();
0 commit comments