diff options
author | Richard Trieu <rtrieu@google.com> | 2018-06-07 03:20:30 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2018-06-07 03:20:30 +0000 |
commit | 8153628f6a42a148d2b75189e2e286d1652422a2 (patch) | |
tree | ae1fa0c6c12bbe2b7d663eda855aa0383da032f4 /clang/lib/Sema/SemaLookup.cpp | |
parent | b92c77d176c8d641b9919763f34835ddaaa1b056 (diff) | |
download | bcm5719-llvm-8153628f6a42a148d2b75189e2e286d1652422a2.tar.gz bcm5719-llvm-8153628f6a42a148d2b75189e2e286d1652422a2.zip |
Change return value of trivial visibility check.
Previous, if no Decl's were checked, visibility was set to false. Switch it
so that in cases of no Decl's, return true. These are the Decl's after being
filtered. Also remove an unreachable return statement since it is directly
after another return statement.
llvm-svn: 334160
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index d2d4171c937..984247bacc6 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1452,6 +1452,8 @@ template<typename Filter> static bool hasVisibleDeclarationImpl(Sema &S, const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules, Filter F) { + bool HasFilteredRedecls = false; + for (auto *Redecl : D->redecls()) { auto *R = cast<NamedDecl>(Redecl); if (!F(R)) @@ -1460,6 +1462,8 @@ static bool hasVisibleDeclarationImpl(Sema &S, const NamedDecl *D, if (S.isVisible(R)) return true; + HasFilteredRedecls = true; + if (Modules) { Modules->push_back(R->getOwningModule()); const auto &Merged = S.Context.getModulesWithMergedDefinition(R); @@ -1467,7 +1471,11 @@ static bool hasVisibleDeclarationImpl(Sema &S, const NamedDecl *D, } } - return false; + // Only return false if there is at least one redecl that is not filtered out. + if (HasFilteredRedecls) + return false; + + return true; } bool Sema::hasVisibleExplicitSpecialization( @@ -1497,8 +1505,6 @@ bool Sema::hasVisibleMemberSpecialization( // class definition? return D->getLexicalDeclContext()->isFileContext(); }); - - return false; } /// Determine whether a declaration is visible to name lookup. |