r253012 - [modules] When a declaration has non-trivial visibility, check whether it's

Sean Silva via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 16 19:00:12 PST 2015


On Sat, Nov 14, 2015 at 2:30 PM, Richard Smith <richard at metafoo.co.uk>
wrote:

> On Nov 13, 2015 7:23 PM, "Sean Silva" <chisophugis at gmail.com> wrote:
> >
> >
> >
> > On Thu, Nov 12, 2015 at 9:14 PM, Richard Smith via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
> >>
> >> Author: rsmith
> >> Date: Thu Nov 12 23:14:45 2015
> >> New Revision: 253012
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=253012&view=rev
> >> Log:
> >> [modules] When a declaration has non-trivial visibility, check whether
> it's
> >
> >
> > What is "non-trivial visibility"? Is this "visibility" something that
> exists in the present C++ language? (e.g. `using namespace std` etc.) or is
> this a different notion?
>
> This is the modules notion of visibility (whether the declaration has been
> imported or not). Here, non-trivial visibility means "not known to be
> unconditionally visible", and corresponds to the Hidden flag on the Decl
> being true.
>

I just looked at the comment on the `Hidden` flag and it doesn't seem to
mention anything about being "trivial" or "non-trivial". Why say
"declaration has non-trivial visibility" instead of just "declaration is
hidden"? Do they mean different things?

-- Sean Silva


> > -- Sean Silva
> >
> >>
> >> actually hidden before we check its linkage. This avoids computing the
> linkage
> >> "too early" for an anonymous struct with a typedef name for linkage.
> >>
> >> Modified:
> >>     cfe/trunk/include/clang/Sema/Lookup.h
> >>     cfe/trunk/test/Modules/submodule-visibility.cpp
> >>
> >> Modified: cfe/trunk/include/clang/Sema/Lookup.h
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=253012&r1=253011&r2=253012&view=diff
> >>
> ==============================================================================
> >> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
> >> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Nov 12 23:14:45 2015
> >> @@ -303,8 +303,7 @@ public:
> >>      if (!D->isInIdentifierNamespace(IDNS))
> >>        return nullptr;
> >>
> >> -    if (!D->isHidden() || isHiddenDeclarationVisible(D) ||
> >> -        isVisibleSlow(getSema(), D))
> >> +    if (isVisible(getSema(), D) || isHiddenDeclarationVisible(D))
> >>        return D;
> >>
> >>      return getAcceptableDeclSlow(D);
> >>
> >> Modified: cfe/trunk/test/Modules/submodule-visibility.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/submodule-visibility.cpp?rev=253012&r1=253011&r2=253012&view=diff
> >>
> ==============================================================================
> >> --- cfe/trunk/test/Modules/submodule-visibility.cpp (original)
> >> +++ cfe/trunk/test/Modules/submodule-visibility.cpp Thu Nov 12 23:14:45
> 2015
> >> @@ -28,3 +28,10 @@ int k = n + m; // OK, a and b are visibl
> >>  #ifndef B
> >>  #error B is not defined
> >>  #endif
> >> +
> >> +// Ensure we don't compute the linkage of this struct before we find
> it has a
> >> +// typedef name for linkage purposes.
> >> +typedef struct {
> >> +  int p;
> >> +  void (*f)(int p);
> >> +} name_for_linkage;
> >>
> >>
> >> _______________________________________________
> >> cfe-commits mailing list
> >> cfe-commits at lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151116/8ce3d597/attachment.html>


More information about the cfe-commits mailing list