On Wed, Jun 6, 2018 at 11:24 PM Richard Trieu via cfe-commits <cfe-commits@lists.llvm.org> wrote: > > Author: rtrieu > Date: Wed Jun 6 20:20:30 2018 > New Revision: 334160 > > URL: http://llvm.org/viewvc/llvm-project?rev=334160&view=rev > Log: > 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. > > Added: > cfe/trunk/test/Modules/local-visibility.cpp > Modified: > cfe/trunk/lib/Sema/SemaLookup.cpp > > Modified: cfe/trunk/lib/Sema/SemaLookup.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=334160&r1=334159&r2=334160&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/SemaLookup.cpp (original) > +++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Jun 6 20:20:30 2018 > @@ -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(Se > 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(Se > } > } > > - return false; > + // Only return false if there is at least one redecl that is not filtered > out. > + if (HasFilteredRedecls) > + return false; > + > + return true;
How about: return !HasFilteredRedecls; instead? > } > > bool Sema::hasVisibleExplicitSpecialization( > @@ -1497,8 +1505,6 @@ bool Sema::hasVisibleMemberSpecializatio > // class definition? > return D->getLexicalDeclContext()->isFileContext(); > }); > - > - return false; > } > > /// Determine whether a declaration is visible to name lookup. > > Added: cfe/trunk/test/Modules/local-visibility.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/local-visibility.cpp?rev=334160&view=auto > ============================================================================== > --- cfe/trunk/test/Modules/local-visibility.cpp (added) > +++ cfe/trunk/test/Modules/local-visibility.cpp Wed Jun 6 20:20:30 2018 > @@ -0,0 +1,15 @@ > +// RUN: %clang_cc1 -fsyntax-only -fmodules %s -verify > +// RUN: %clang_cc1 -fsyntax-only %s -verify > + > +// expected-no-diagnostics > +template <typename Var> > +struct S { > + template <unsigned N> > + struct Inner { }; > + > + template <> > + struct Inner<0> { }; > +}; > + > +S<int>::Inner<1> I1; > +S<int>::Inner<0> I0; > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits