diff options
author | Gabor Marton <martongabesz@gmail.com> | 2018-12-17 12:42:12 +0000 |
---|---|---|
committer | Gabor Marton <martongabesz@gmail.com> | 2018-12-17 12:42:12 +0000 |
commit | 7df342a4d1a6400646d7403104f840c218b0661d (patch) | |
tree | 63f41e4161256fd8108ec54d7fb5254dfa8c4631 /clang/lib/AST/DeclBase.cpp | |
parent | e913b956aa90a2ab7b9723b804617548827c11d7 (diff) | |
download | bcm5719-llvm-7df342a4d1a6400646d7403104f840c218b0661d.tar.gz bcm5719-llvm-7df342a4d1a6400646d7403104f840c218b0661d.zip |
[ASTImporter] Fix redecl chain of classes and class templates
Summary:
The crux of the issue that is being fixed is that lookup could not find
previous decls of a friend class. The solution involves making the
friend declarations visible in their decl context (i.e. adding them to
the lookup table).
Also, we simplify `VisitRecordDecl` greatly.
This fix involves two other repairs (without these the unittests fail):
(1) We could not handle the addition of injected class types properly
when a redecl chain was involved, now this is fixed.
(2) DeclContext::removeDecl failed if the lookup table in Vector form
did not contain the to be removed element. This caused troubles in
ASTImporter::ImportDeclContext. This is also fixed.
Reviewers: a_sidorin, balazske, a.sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits
Differential Revision: https://reviews.llvm.org/D53655
llvm-svn: 349349
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 95babf79179..66dfa53314e 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1463,7 +1463,9 @@ void DeclContext::removeDecl(Decl *D) { if (Map) { StoredDeclsMap::iterator Pos = Map->find(ND->getDeclName()); assert(Pos != Map->end() && "no lookup entry for decl"); - if (Pos->second.getAsVector() || Pos->second.getAsDecl() == ND) + // Remove the decl only if it is contained. + StoredDeclsList::DeclsTy *Vec = Pos->second.getAsVector(); + if ((Vec && is_contained(*Vec, ND)) || Pos->second.getAsDecl() == ND) Pos->second.remove(ND); } } while (DC->isTransparentContext() && (DC = DC->getParent())); |