diff options
author | Balazs Keri <1.int32@gmail.com> | 2019-08-12 10:07:38 +0000 |
---|---|---|
committer | Balazs Keri <1.int32@gmail.com> | 2019-08-12 10:07:38 +0000 |
commit | 2e16060a8bbbd82f4637ddb5e58533a614ef529e (patch) | |
tree | ddc21079b8cf92dec43415dd982988223b0adb24 /clang/lib | |
parent | 3cafdfddcbcd077325622dd0869b409f4664769e (diff) | |
download | bcm5719-llvm-2e16060a8bbbd82f4637ddb5e58533a614ef529e.tar.gz bcm5719-llvm-2e16060a8bbbd82f4637ddb5e58533a614ef529e.zip |
[ASTImporter] Fix for import of friend class template with definition.
Summary:
If there is a friend class template "prototype" (forward declaration)
and later a definition for it in the existing code, this existing
definition may be not found by ASTImporter because it is not linked
to the prototype (under the friend AST node). The problem is fixed by
looping over all found matching decls instead of break after the first
found one.
Reviewers: martong, a.sidorin, shafik, a_sidorin
Reviewed By: a_sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65269
llvm-svn: 368551
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 69a9f9ddb6f..e999e89edad 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -5082,11 +5082,13 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) { if (IsStructuralMatch(D, FoundTemplate)) { ClassTemplateDecl *TemplateWithDef = getTemplateDefinition(FoundTemplate); - if (D->isThisDeclarationADefinition() && TemplateWithDef) { + if (D->isThisDeclarationADefinition() && TemplateWithDef) return Importer.MapImported(D, TemplateWithDef); - } - FoundByLookup = FoundTemplate; - break; + if (!FoundByLookup) + FoundByLookup = FoundTemplate; + // Search in all matches because there may be multiple decl chains, + // see ASTTests test ImportExistingFriendClassTemplateDef. + continue; } } |