From c94711c7e355c8d4ddaa08154e3149718e546c6b 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. llvm-svn: 202869 --- clang/lib/AST/ASTImporter.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index e4a06ee7f8e1..cb5939cd3d4f 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/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) {