[cfe-dev] DeclContext::addHiddenDecl vs NamedDecl::isHidden
Vassil Vassilev
vasil.georgiev.vasilev at cern.ch
Wed Oct 16 00:28:11 PDT 2013
On 10/15/2013 12:57 AM, Richard Smith wrote:
> On Thu, Oct 10, 2013 at 8:03 AM, Vassil Vassilev
> <vasil.georgiev.vasilev at cern.ch
> <mailto: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?
>
Thanks for the clarification.
>
> 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.
In our context we use removeDecl a lot. For example, we need to
'rollback' for example the last 'n' decls. Thus for us the consistency
of that interface is very important.
Independent on that that part of removeDecl is not very clear to me,
(DeclBase.cpp)01091 StoredDeclsMap *Map =
getPrimaryContext()->LookupPtr.getPointer();
(DeclBase.cpp)01092 if (!Map) return;
how that is supposed to work with out-of-line definitions, where the
primary context of the lexical context != primary context of the
'semantic'/'lookup' context. Eg:
class MyClass {
void f();
}
MyClass::f() {} // we want to remove that out-of-line definition.
Shouldn't like 01091 be smth like: StoredDeclsMap *Map =
D->getDeclContext()->getPrimaryContext()->LookupPtr.getPointer();
Many thanks,
Vassil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131016/3f8dc577/attachment.html>
More information about the cfe-dev
mailing list