@@ -1031,7 +1031,8 @@ Expected<LambdaCapture> ASTNodeImporter::import(const LambdaCapture &From) {
1031
1031
1032
1032
template <typename T>
1033
1033
bool ASTNodeImporter::hasSameVisibilityContextAndLinkage (T *Found, T *From) {
1034
- if (Found->getLinkageInternal () != From->getLinkageInternal ())
1034
+ if (!Importer.hasLLDBRedeclCompletion () &&
1035
+ Found->getLinkageInternal () != From->getLinkageInternal ())
1035
1036
return false ;
1036
1037
1037
1038
if (From->hasExternalFormalLinkage ())
@@ -1482,7 +1483,9 @@ ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
1482
1483
}
1483
1484
1484
1485
ExpectedType ASTNodeImporter::VisitRecordType (const RecordType *T) {
1486
+ // getCanonicalDecl in order to not trigger redeclaration completion
1485
1487
Expected<RecordDecl *> ToDeclOrErr = import (T->getDecl ());
1488
+
1486
1489
if (!ToDeclOrErr)
1487
1490
return ToDeclOrErr.takeError ();
1488
1491
@@ -1771,8 +1774,9 @@ Error ASTNodeImporter::ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD) {
1771
1774
1772
1775
if (RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
1773
1776
if (RecordDecl *ToRecord = cast<RecordDecl>(ToD)) {
1774
- if (FromRecord->getDefinition () && FromRecord->isCompleteDefinition () &&
1775
- !ToRecord->getDefinition ()) {
1777
+ if (FromRecord->getDefinition () && !ToRecord->getDefinition () &&
1778
+ (Importer.hasLLDBRedeclCompletion () ||
1779
+ FromRecord->isCompleteDefinition ())) {
1776
1780
if (Error Err = ImportDefinition (FromRecord, ToRecord))
1777
1781
return Err;
1778
1782
}
@@ -1873,12 +1877,15 @@ ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
1873
1877
ImportedOrErr.takeError ());
1874
1878
continue ;
1875
1879
}
1876
- FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
1877
- Decl *ImportedDecl = *ImportedOrErr;
1878
- FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
1879
- if (FieldFrom && FieldTo) {
1880
- Error Err = ImportFieldDeclDefinition (FieldFrom, FieldTo);
1881
- HandleChildErrors.handleChildImportResult (ChildErrors, std::move (Err));
1880
+
1881
+ if (Importer.hasLLDBRedeclCompletion ()) {
1882
+ FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
1883
+ Decl *ImportedDecl = *ImportedOrErr;
1884
+ FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
1885
+ if (FieldFrom && FieldTo) {
1886
+ Error Err = ImportFieldDeclDefinition (FieldFrom, FieldTo);
1887
+ HandleChildErrors.handleChildImportResult (ChildErrors, std::move (Err));
1888
+ }
1882
1889
}
1883
1890
}
1884
1891
@@ -2039,7 +2046,11 @@ Error ASTNodeImporter::ImportDefinition(
2039
2046
To->completeDefinition ();
2040
2047
};
2041
2048
2042
- if (To->getDefinition () || To->isBeingDefined ()) {
2049
+ bool hasDef = (Importer.hasLLDBRedeclCompletion () &&
2050
+ To->isThisDeclarationADefinition ()) ||
2051
+ To->getDefinition ();
2052
+
2053
+ if (hasDef || To->isBeingDefined ()) {
2043
2054
if (Kind == IDK_Everything ||
2044
2055
// In case of lambdas, the class already has a definition ptr set, but
2045
2056
// the contained decls are not imported yet. Also, isBeingDefined was
@@ -2558,6 +2569,9 @@ ASTNodeImporter::VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias) {
2558
2569
!hasSameVisibilityContextAndLinkage (FoundR, FromR))
2559
2570
continue ;
2560
2571
}
2572
+
2573
+ if (Importer.hasLLDBRedeclCompletion () && Importer.isMinimalImport ())
2574
+ return Importer.MapImported (D, FoundTypedef);
2561
2575
// If the "From" context has a complete underlying type but we
2562
2576
// already have a complete underlying type then return with that.
2563
2577
if (!FromUT->isIncompleteType () && !FoundUT->isIncompleteType ())
@@ -2822,9 +2836,11 @@ ExpectedDecl ASTNodeImporter::VisitEnumDecl(EnumDecl *D) {
2822
2836
return POIOrErr.takeError ();
2823
2837
}
2824
2838
2839
+ auto Kind = Importer.hasLLDBRedeclCompletion () ? IDK_Everything : IDK_Default;
2840
+
2825
2841
// Import the definition
2826
2842
if (D->isCompleteDefinition ())
2827
- if (Error Err = ImportDefinition (D, D2))
2843
+ if (Error Err = ImportDefinition (D, D2, Kind ))
2828
2844
return std::move (Err);
2829
2845
2830
2846
return D2;
@@ -2902,7 +2918,8 @@ ExpectedDecl ASTNodeImporter::VisitRecordDecl(RecordDecl *D) {
2902
2918
2903
2919
if (IsStructuralMatch (D, FoundRecord)) {
2904
2920
RecordDecl *FoundDef = FoundRecord->getDefinition ();
2905
- if (D->isThisDeclarationADefinition () && FoundDef) {
2921
+ if (!Importer.hasLLDBRedeclCompletion () &&
2922
+ D->isThisDeclarationADefinition () && FoundDef) {
2906
2923
// FIXME: Structural equivalence check should check for same
2907
2924
// user-defined methods.
2908
2925
Importer.MapImported (D, FoundDef);
@@ -3078,8 +3095,9 @@ ExpectedDecl ASTNodeImporter::VisitRecordDecl(RecordDecl *D) {
3078
3095
if (D->isAnonymousStructOrUnion ())
3079
3096
D2->setAnonymousStructOrUnion (true );
3080
3097
3098
+ auto Kind = Importer.hasLLDBRedeclCompletion () ? IDK_Everything : IDK_Default;
3081
3099
if (D->isCompleteDefinition ())
3082
- if (Error Err = ImportDefinition (D, D2, IDK_Default ))
3100
+ if (Error Err = ImportDefinition (D, D2, Kind ))
3083
3101
return std::move (Err);
3084
3102
3085
3103
return D2;
@@ -5203,7 +5221,8 @@ Error ASTNodeImporter::ImportDefinition(
5203
5221
diag::note_odr_objc_missing_superclass);
5204
5222
}
5205
5223
5206
- if (shouldForceImportDeclContext (Kind))
5224
+ if (Importer.hasLLDBRedeclCompletion () ||
5225
+ shouldForceImportDeclContext (Kind))
5207
5226
if (Error Err = ImportDeclContext (From))
5208
5227
return Err;
5209
5228
return Error::success ();
@@ -6084,8 +6103,9 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl(
6084
6103
}
6085
6104
}
6086
6105
6106
+ auto Kind = Importer.hasLLDBRedeclCompletion () ? IDK_Everything : IDK_Default;
6087
6107
if (D->isCompleteDefinition ())
6088
- if (Error Err = ImportDefinition (D, D2))
6108
+ if (Error Err = ImportDefinition (D, D2, Kind ))
6089
6109
return std::move (Err);
6090
6110
6091
6111
return D2;
0 commit comments