diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/DeclBase.cpp | 23 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 10 |
2 files changed, 20 insertions, 13 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index ca88377034..0b958fe82b 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -478,6 +478,11 @@ DeclContext *DeclContext::getLookupParent() { return getParent(); } +bool DeclContext::isInlineNamespace() const { + return isNamespace() && + cast<NamespaceDecl>(this)->isInline(); +} + bool DeclContext::isDependentContext() const { if (isFileContext()) return false; @@ -509,8 +514,6 @@ bool DeclContext::isTransparentContext() const { return true; else if (DeclKind >= Decl::firstRecord && DeclKind <= Decl::lastRecord) return cast<RecordDecl>(this)->isAnonymousStructOrUnion(); - else if (DeclKind == Decl::Namespace) - return cast<NamespaceDecl>(this)->isInline(); return false; } @@ -799,10 +802,10 @@ void DeclContext::buildLookup(DeclContext *DCtx) { I != IEnd; ++I) makeDeclVisibleInContextImpl(I->getInterface()); - // If this declaration is itself a transparent declaration context, - // add its members (recursively). + // If this declaration is itself a transparent declaration context or + // inline namespace, add its members (recursively). if (DeclContext *InnerCtx = dyn_cast<DeclContext>(*D)) - if (InnerCtx->isTransparentContext()) + if (InnerCtx->isTransparentContext() || InnerCtx->isInlineNamespace()) buildLookup(InnerCtx->getPrimaryContext()); } } @@ -849,8 +852,8 @@ DeclContext::lookup(DeclarationName Name) const { DeclContext *DeclContext::getRedeclContext() { DeclContext *Ctx = this; - // Skip through transparent contexts, except inline namespaces. - while (Ctx->isTransparentContext() && !Ctx->isNamespace()) + // Skip through transparent contexts. + while (Ctx->isTransparentContext()) Ctx = Ctx->getParent(); return Ctx; } @@ -904,9 +907,9 @@ void DeclContext::makeDeclVisibleInContext(NamedDecl *D, bool Recoverable) { if (LookupPtr || !Recoverable || hasExternalVisibleStorage()) makeDeclVisibleInContextImpl(D); - // If we are a transparent context, insert into our parent context, - // too. This operation is recursive. - if (isTransparentContext()) + // If we are a transparent context or inline namespace, insert into our + // parent context, too. This operation is recursive. + if (isTransparentContext() || isInlineNamespace()) getParent()->makeDeclVisibleInContext(D, Recoverable); } diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index bb267e3733..1e047106cd 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -1619,7 +1619,11 @@ static void CollectEnclosingNamespace(Sema::AssociatedNamespaceSet &Namespaces, // We don't use DeclContext::getEnclosingNamespaceContext() as this may // be a locally scoped record. - while (Ctx->isRecord() || Ctx->isTransparentContext()) + // We skip out of inline namespaces. The innermost non-inline namespace + // contains all names of all its nested inline namespaces anyway, so we can + // replace the entire inline namespace tree with its root. + while (Ctx->isRecord() || Ctx->isTransparentContext() || + Ctx->isInlineNamespace()) Ctx = Ctx->getParent(); if (Ctx->isFileContext()) @@ -2423,9 +2427,9 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, Visited.add(ND); } - // Visit transparent contexts inside this context. + // Visit transparent contexts and inline namespaces inside this context. if (DeclContext *InnerCtx = dyn_cast<DeclContext>(*D)) { - if (InnerCtx->isTransparentContext()) + if (InnerCtx->isTransparentContext() || InnerCtx->isInlineNamespace()) LookupVisibleDecls(InnerCtx, Result, QualifiedNameLookup, InBaseClass, Consumer, Visited); } |