[cfe-dev] DeclContext::addHiddenDecl vs NamedDecl::isHidden

Richard Smith richard at metafoo.co.uk
Mon Oct 14 15:57:39 PDT 2013


On Thu, Oct 10, 2013 at 8:03 AM, Vassil Vassilev <
vasil.georgiev.vasilev at cern.ch> wrote:

> Hi,
>   Is there any particular reason DeclContext::addHiddenDecl to not call
> NamedDecl::setHidden() on the added declaration?
>

Yes. addHiddenDecl doesn't make a declaration hidden, it adds it without
making it visible. This can be part of the process of making a declaration
visible... or not. It doesn't make any sense for this to mark the
declaration as hidden. (Also, declarations marked as hidden are still in
the name lookup structures, so these mean different things.)


>   It feels like an inconsistency to me, because one can add a 'hidden'
> NamedDecl and later on to call removeDecl. In that case the DeclContext
> would assert because the name wasn't found in the lookup table. Is there
> something I missed?


removeDecl is only used in very restricted circumstances, so this isn't a
problem in practice. Nor does it check whether the declaration is marked as
'hidden' -- that doesn't affect whether the name appears in the lookup
table anyway, so wouldn't be a sensible check.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131014/85f509ec/attachment.html>


More information about the cfe-dev mailing list