diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-30 22:38:20 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-30 22:38:20 +0000 |
commit | 8e62a65f20ac33af4e9608cd9ff2343c4380cc46 (patch) | |
tree | 72e89e78a4e2370160c1425acc6b8190df99797a /lib/Sema/SemaLookup.cpp | |
parent | 56a61ff5cc594f52cc895851f8a12873f165e051 (diff) |
[modules] Retain multiple using-directives in the same scope even if they name the same namespace.
They might have different visibility, and thus discarding all but one of them
can result in rejecting valid code. Also fix name lookup to cope with multiple
using-directives being found that denote the same namespace, where some are not
visible -- don't cache an "already visited" state for a using-directive that we
didn't visit because it was hidden.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316965 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 73aceaaf94..d3f91a4e27 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -155,7 +155,7 @@ namespace { while (true) { for (auto UD : DC->using_directives()) { DeclContext *NS = UD->getNominatedNamespace(); - if (visited.insert(NS).second && SemaRef.isVisible(UD)) { + if (SemaRef.isVisible(UD) && visited.insert(NS).second) { addUsingDirective(UD, EffectiveDC); queue.push_back(NS); } @@ -1883,7 +1883,7 @@ static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R, // with its using-children. for (auto *I : StartDC->using_directives()) { NamespaceDecl *ND = I->getNominatedNamespace()->getOriginalNamespace(); - if (Visited.insert(ND).second && S.isVisible(I)) + if (S.isVisible(I) && Visited.insert(ND).second) Queue.push_back(ND); } @@ -1931,7 +1931,7 @@ static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R, for (auto I : ND->using_directives()) { NamespaceDecl *Nom = I->getNominatedNamespace(); - if (Visited.insert(Nom).second && S.isVisible(I)) + if (S.isVisible(I) && Visited.insert(Nom).second) Queue.push_back(Nom); } } |