@@ -824,23 +824,17 @@ bool ClangASTImporter::CompleteTagDecl(clang::TagDecl *decl) {
824
824
if (!decl_origin.Valid ())
825
825
return false ;
826
826
827
- ImporterDelegateSP delegate_sp (
828
- GetDelegate (&decl->getASTContext (), decl_origin.ctx ));
829
-
830
- ASTImporterDelegate::CxxModuleScope std_scope (*delegate_sp,
831
- &decl->getASTContext ());
832
-
833
- if (!TypeSystemClang::UseRedeclCompletion ()) {
834
- if (!TypeSystemClang::GetCompleteDecl (decl_origin.ctx , decl_origin.decl ))
835
- return false ;
836
-
837
- if (delegate_sp)
838
- delegate_sp->ImportDefinitionTo (decl, decl_origin.decl );
839
- } else {
827
+ if (TypeSystemClang::UseRedeclCompletion ()) {
840
828
auto *origin_def = llvm::cast<TagDecl>(decl_origin.decl )->getDefinition ();
841
829
if (!origin_def)
842
830
return false ;
843
831
832
+ ImporterDelegateSP delegate_sp (
833
+ GetDelegate (&decl->getASTContext (), decl_origin.ctx ));
834
+
835
+ ASTImporterDelegate::CxxModuleScope std_scope (*delegate_sp,
836
+ &decl->getASTContext ());
837
+
844
838
// This is expected to pull in a definition for result_decl (if in redecl
845
839
// completion mode)
846
840
llvm::Expected<Decl *> result = delegate_sp->Import (origin_def);
@@ -859,6 +853,18 @@ bool ClangASTImporter::CompleteTagDecl(clang::TagDecl *decl) {
859
853
if (!decl->isThisDeclarationADefinition () && result_decl != decl)
860
854
if (result_decl->getPreviousDecl () == nullptr )
861
855
result_decl->setPreviousDecl (decl);
856
+ } else {
857
+ if (!TypeSystemClang::GetCompleteDecl (decl_origin.ctx , decl_origin.decl ))
858
+ return false ;
859
+
860
+ ImporterDelegateSP delegate_sp (
861
+ GetDelegate (&decl->getASTContext (), decl_origin.ctx ));
862
+
863
+ ASTImporterDelegate::CxxModuleScope std_scope (*delegate_sp,
864
+ &decl->getASTContext ());
865
+
866
+ if (delegate_sp)
867
+ delegate_sp->ImportDefinitionTo (decl, decl_origin.decl );
862
868
}
863
869
864
870
return true ;
@@ -880,27 +886,15 @@ bool ClangASTImporter::CompleteObjCInterfaceDecl(
880
886
if (!decl_origin.Valid ())
881
887
return false ;
882
888
883
- ImporterDelegateSP delegate_sp (
884
- GetDelegate (&interface_decl->getASTContext (), decl_origin.ctx ));
885
-
886
- if (!TypeSystemClang::UseRedeclCompletion ()) {
887
- if (!TypeSystemClang::GetCompleteDecl (decl_origin.ctx , decl_origin.decl ))
888
- return false ;
889
-
890
- if (delegate_sp)
891
- delegate_sp->ImportDefinitionTo (interface_decl, decl_origin.decl );
892
-
893
- if (ObjCInterfaceDecl *super_class = interface_decl->getSuperClass ())
894
- RequireCompleteType (clang::QualType (super_class->getTypeForDecl (), 0 ));
895
- } else {
889
+ if (TypeSystemClang::UseRedeclCompletion ()) {
896
890
ObjCInterfaceDecl *origin_decl =
897
891
llvm::cast<ObjCInterfaceDecl>(decl_origin.decl );
898
892
899
893
origin_decl = origin_decl->getDefinition ();
900
894
if (!origin_decl)
901
895
return false ;
902
896
903
- auto delegate_sp (
897
+ ImporterDelegateSP delegate_sp (
904
898
GetDelegate (&interface_decl->getASTContext (), decl_origin.ctx ));
905
899
906
900
llvm::Expected<Decl *> result = delegate_sp->Import (origin_decl);
@@ -915,6 +909,18 @@ bool ClangASTImporter::CompleteObjCInterfaceDecl(
915
909
return false ;
916
910
}
917
911
912
+ if (!TypeSystemClang::GetCompleteDecl (decl_origin.ctx , decl_origin.decl ))
913
+ return false ;
914
+
915
+ ImporterDelegateSP delegate_sp (
916
+ GetDelegate (&interface_decl->getASTContext (), decl_origin.ctx ));
917
+
918
+ if (delegate_sp)
919
+ delegate_sp->ImportDefinitionTo (interface_decl, decl_origin.decl );
920
+
921
+ if (ObjCInterfaceDecl *super_class = interface_decl->getSuperClass ())
922
+ RequireCompleteType (clang::QualType (super_class->getTypeForDecl (), 0 ));
923
+
918
924
return true ;
919
925
}
920
926
@@ -1204,15 +1210,14 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
1204
1210
DeclContext::lookup_result lr = dc->lookup (*dn_or_err);
1205
1211
for (clang::Decl *candidate : lr) {
1206
1212
if (candidate->getKind () == From->getKind ()) {
1207
- RegisterImportedDecl (From, candidate);
1208
-
1209
- // If we're dealing with redecl chains. We want to find the definition,
1213
+ // If we're dealing with redecl chains, we want to find the definition,
1210
1214
// so skip if the decl is actually just a forwad decl.
1211
1215
if (TypeSystemClang::UseRedeclCompletion ())
1212
1216
if (auto *tag_decl = llvm::dyn_cast<TagDecl>(candidate);
1213
1217
!tag_decl || !tag_decl->getDefinition ())
1214
1218
continue ;
1215
1219
1220
+ RegisterImportedDecl (From, candidate);
1216
1221
m_decls_to_ignore.insert (candidate);
1217
1222
return candidate;
1218
1223
}
0 commit comments