From e2ff0f69041b346b716f722b600364befd24697c Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Tue, 4 Mar 2014 18:11:50 +0000 Subject: [PATCH] When deciding whether or not to resolve two 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index e4a06ee7f8..cb5939cd3d 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -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) { -- 2.40.0