aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-08-31 20:53:31 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-08-31 20:53:31 +0000
commit410c4f2eb5e6a8c2318cacb9a6751f1b4fcff166 (patch)
tree533dee111e3bb10c9bc1158afb3be5392a54be76 /lib/AST/DeclBase.cpp
parent0b36e614aa19df72885d5e0de996f7fbb9874ec3 (diff)
Make inline namespace not be transparent after all. The concept simply doesn't fit. Instead, special-case the few places where transparent contexts have the desired behavior for inline namespaces. Fixes a redeclaration issue in inline namespaces.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112637 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r--lib/AST/DeclBase.cpp23
1 files changed, 13 insertions, 10 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);
}