@@ -230,6 +230,35 @@ class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener {
230
230
clang::ASTContext *m_src_ctx;
231
231
ClangASTImporter &importer;
232
232
233
+ void CompleteDecl (
234
+ Decl *decl,
235
+ lldb_private::ClangASTImporter::ASTContextMetadata const &to_context_md) {
236
+ // The decl that should be completed has to be imported into the target
237
+ // context from some other context.
238
+ assert (to_context_md.hasOrigin (decl));
239
+ // We should only complete decls coming from the source context.
240
+ assert (to_context_md.getOrigin (decl).ctx == m_src_ctx);
241
+
242
+ Decl *original_decl = to_context_md.getOrigin (decl).decl ;
243
+
244
+ // Complete the decl now.
245
+ TypeSystemClang::GetCompleteDecl (m_src_ctx, original_decl);
246
+ if (auto *tag_decl = dyn_cast<TagDecl>(decl)) {
247
+ if (auto *original_tag_decl = dyn_cast<TagDecl>(original_decl)) {
248
+ if (original_tag_decl->isCompleteDefinition ()) {
249
+ m_delegate->ImportDefinitionTo (tag_decl, original_tag_decl);
250
+ tag_decl->setCompleteDefinition (true );
251
+ }
252
+ }
253
+
254
+ tag_decl->setHasExternalLexicalStorage (false );
255
+ tag_decl->setHasExternalVisibleStorage (false );
256
+ } else if (auto *container_decl = dyn_cast<ObjCContainerDecl>(decl)) {
257
+ container_decl->setHasExternalLexicalStorage (false );
258
+ container_decl->setHasExternalVisibleStorage (false );
259
+ }
260
+ }
261
+
233
262
public:
234
263
// / Constructs a CompleteTagDeclsScope.
235
264
// / \param importer The ClangASTImporter that we should observe.
@@ -252,30 +281,7 @@ class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener {
252
281
NamedDecl *decl = m_decls_to_complete.pop_back_val ();
253
282
m_decls_already_completed.insert (decl);
254
283
255
- // The decl that should be completed has to be imported into the target
256
- // context from some other context.
257
- assert (to_context_md->hasOrigin (decl));
258
- // We should only complete decls coming from the source context.
259
- assert (to_context_md->getOrigin (decl).ctx == m_src_ctx);
260
-
261
- Decl *original_decl = to_context_md->getOrigin (decl).decl ;
262
-
263
- // Complete the decl now.
264
- TypeSystemClang::GetCompleteDecl (m_src_ctx, original_decl);
265
- if (auto *tag_decl = dyn_cast<TagDecl>(decl)) {
266
- if (auto *original_tag_decl = dyn_cast<TagDecl>(original_decl)) {
267
- if (original_tag_decl->isCompleteDefinition ()) {
268
- m_delegate->ImportDefinitionTo (tag_decl, original_tag_decl);
269
- tag_decl->setCompleteDefinition (true );
270
- }
271
- }
272
-
273
- tag_decl->setHasExternalLexicalStorage (false );
274
- tag_decl->setHasExternalVisibleStorage (false );
275
- } else if (auto *container_decl = dyn_cast<ObjCContainerDecl>(decl)) {
276
- container_decl->setHasExternalLexicalStorage (false );
277
- container_decl->setHasExternalVisibleStorage (false );
278
- }
284
+ CompleteDecl (decl, *to_context_md);
279
285
280
286
to_context_md->removeOrigin (decl);
281
287
}
0 commit comments