void DeclContext::makeDeclVisibleInContext(NamedDecl *D) { DeclContext *PrimaryDC = this->getPrimaryContext(); DeclContext *DeclDC = D->getDeclContext()->getPrimaryContext(); // If the decl is being added outside of its semantic decl context, we // need to ensure that we eagerly build the lookup information for it. PrimaryDC->makeDeclVisibleInContextWithFlags(D, false, PrimaryDC == DeclDC); }
void DeclContext::makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal, bool Recoverable) { // FIXME: This feels like a hack. Should DeclarationName support // template-ids, or is there a better way to keep specializations // from being visible? if (isa<ClassTemplateSpecializationDecl>(D) || D->isTemplateParameter()) return; if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) if (FD->isFunctionTemplateSpecialization()) return; DeclContext *PrimaryContext = getPrimaryContext(); if (PrimaryContext != this) { PrimaryContext->makeDeclVisibleInContextWithFlags(D, Internal, Recoverable); return; } // If we already have a lookup data structure, perform the insertion // into it. If we haven't deserialized externally stored decls, deserialize // them so we can add the decl. Otherwise, be lazy and don't build that // structure until someone asks for it. if (LookupPtr || !Recoverable || hasExternalVisibleStorage()) makeDeclVisibleInContextImpl(D, Internal); // If we are a transparent context or inline namespace, insert into our // parent context, too. This operation is recursive. if (isTransparentContext() || isInlineNamespace()) getParent()->makeDeclVisibleInContextWithFlags(D, Internal, Recoverable); Decl *DCAsDecl = cast<Decl>(this); // Notify that a decl was made visible unless it's a Tag being defined. if (!(isa<TagDecl>(DCAsDecl) && cast<TagDecl>(DCAsDecl)->isBeingDefined())) if (ASTMutationListener *L = DCAsDecl->getASTMutationListener()) L->AddedVisibleDecl(this, D); }