[cfe-dev] UsingDirectiveDecl inconsistently (not) added to their DeclContext.

Enea Zaffanella zaffanella at cs.unipr.it
Tue Sep 4 09:54:07 PDT 2012


Ping^2.

On 08/21/2012 12:16 PM, Enea Zaffanella wrote:
> Ping.
>
> On 08/06/2012 04:30 PM, Enea Zaffanella wrote:
>> We are observing an inconsistency (affecting our AST visitors) in the
>> addition of UsingDirectiveDecl to their DeclContext.
>>
>> When parsing a using directive, it gets added to its DeclContext only if
>> it is NOT a function/method:
>>
>> ===================== SemaDeclCXX.cpp
>> void Sema::PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir) {
>>      // If the scope has an associated entity and the using directive is at
>>      // namespace or translation unit scope, add the UsingDirectiveDecl into
>>      // its lookup structure so qualified name lookup can find it.
>>      DeclContext *Ctx = static_cast<DeclContext*>(S->getEntity());
>>      if (Ctx && !Ctx->isFunctionOrMethod())
>>        Ctx->addDecl(UDir);
>> =====================
>>
>>
>> However, when such a using declaration is subject to template
>> instantiations, it is unconditionally added to its DeclContext, no
>> matter if it is a function/method or not:
>>
>> ===================== SemaTemplateInstantiateDecl.cpp
>> Decl
>> *TemplateDeclInstantiator::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
>>      // Using directives are never dependent (and never contain any types or
>>      // expressions), so they require no explicit instantiation work.
>>
>>      UsingDirectiveDecl *Inst
>>        = UsingDirectiveDecl::Create(SemaRef.Context, Owner, D->getLocation(),
>>                                     D->getNamespaceKeyLocation(),
>>                                     D->getQualifierLoc(),
>>                                     D->getIdentLocation(),
>>                                     D->getNominatedNamespace(),
>>                                     D->getCommonAncestor());
>>      Owner->addDecl(Inst);
>> =====================
>>
>> Therefore, when visiting the instantiated DeclContext we will see more
>> declarations than when visiting its instantiation pattern.
>> We would like to remove this inconsistency, but it is unclear to us
>> which is the right fix to apply: should we always add the using
>> declaration to its DeclContext or should we repeat the check for
>> function/method when instantiating?
>>
>> Enea.
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list