diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-11 01:49:57 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-11 01:49:57 +0000 |
commit | fa2608147089e29e2c2e41dd33784a3dedbd5265 (patch) | |
tree | 3be4839aaa7a9e53a7e40e619462a22bbea3f814 /lib/Sema/SemaLookup.cpp | |
parent | 8da894badfcde801cf20a6495cebe7400fc19f04 (diff) |
[modules] Fix visibility checking for using declarations via ADL.
We want to check whether the using (shadow) declaration itself is visible, not
whether its target is visible.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315408 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 8cb4fd63eb..8f3e93845b 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -3349,16 +3349,24 @@ void Sema::ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, continue; } - if (isa<UsingShadowDecl>(D)) - D = cast<UsingShadowDecl>(D)->getTargetDecl(); + auto *Underlying = D; + if (auto *USD = dyn_cast<UsingShadowDecl>(D)) + Underlying = USD->getTargetDecl(); - if (!isa<FunctionDecl>(D) && !isa<FunctionTemplateDecl>(D)) + if (!isa<FunctionDecl>(Underlying) && + !isa<FunctionTemplateDecl>(Underlying)) continue; - if (!isVisible(D) && !(D = findAcceptableDecl(*this, D))) - continue; + if (!isVisible(D)) { + D = findAcceptableDecl(*this, D); + if (!D) + continue; + if (auto *USD = dyn_cast<UsingShadowDecl>(D)) + Underlying = USD->getTargetDecl(); + } - Result.insert(D); + // FIXME: Preserve D as the FoundDecl. + Result.insert(Underlying); } } } |