]> granicus.if.org Git - clang/commitdiff
When deciding whether or not to resolve two
authorSean Callanan <scallanan@apple.com>
Tue, 4 Mar 2014 18:11:50 +0000 (18:11 +0000)
committerSean Callanan <scallanan@apple.com>
Tue, 4 Mar 2014 18:11:50 +0000 (18:11 +0000)
anonymous structs to the same Decl in the
ASTImporter, ensure that both are filled in
from their external sources (if present).
Otherwise two different structs may be
identified erroneously.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202869 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTImporter.cpp

index e4a06ee7f8e18a349ddf648ce528a9283160b189..cb5939cd3d4fec3dea30082032590c706a471943 100644 (file)
@@ -2538,6 +2538,21 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) {
         } else if (!D->isCompleteDefinition()) {
           // We have a forward declaration of this type, so adopt that forward
           // declaration rather than building a new one.
+            
+          // If one or both can be completed from external storage then try one
+          // last time to complete and compare them before doing this.
+            
+          if (FoundRecord->hasExternalLexicalStorage() &&
+              !FoundRecord->isCompleteDefinition())
+            FoundRecord->getASTContext().getExternalSource()->CompleteType(FoundRecord);
+          if (D->hasExternalLexicalStorage())
+            D->getASTContext().getExternalSource()->CompleteType(D);
+            
+          if (FoundRecord->isCompleteDefinition() &&
+              D->isCompleteDefinition() &&
+              !IsStructuralMatch(D, FoundRecord))
+            continue;
+              
           AdoptDecl = FoundRecord;
           continue;
         } else if (!SearchName) {