diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-08-31 00:36:30 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-08-31 00:36:30 +0000 |
commit | 7a126a474fdde06382b315b4e3d8ef0a21d4dc31 (patch) | |
tree | 70e2f4e6b75e1e1141822888cd4d2b3ff01633a8 /lib/AST | |
parent | 51a8a378012b5d6a1306fdd75bd135fea3e23b7b (diff) |
Rename DeclContext::getLookupContext to getRedeclContext and change its semantics slightly. No functionality change in the absence of inline namespaces. Also, change a few places where inline namespaces actually make a difference to be prepared for them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112563 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/Decl.cpp | 6 | ||||
-rw-r--r-- | lib/AST/DeclBase.cpp | 30 |
2 files changed, 27 insertions, 9 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index bef6194e26..9d9f27e1a0 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -104,7 +104,7 @@ getLinkageForTemplateArgumentList(const TemplateArgumentList &TArgs) { } static Linkage getLinkageForNamespaceScopeDecl(const NamedDecl *D) { - assert(D->getDeclContext()->getLookupContext()->isFileContext() && + assert(D->getDeclContext()->getRedeclContext()->isFileContext() && "Not a name having namespace scope"); ASTContext &Context = D->getASTContext(); @@ -345,7 +345,7 @@ Linkage NamedDecl::getLinkage() const { } // Handle linkage for namespace-scope names. - if (getDeclContext()->getLookupContext()->isFileContext()) + if (getDeclContext()->getRedeclContext()->isFileContext()) if (Linkage L = getLinkageForNamespaceScopeDecl(this)) return L; @@ -969,7 +969,7 @@ void FunctionDecl::setBody(Stmt *B) { bool FunctionDecl::isMain() const { ASTContext &Context = getASTContext(); return !Context.getLangOptions().Freestanding && - getDeclContext()->getLookupContext()->isTranslationUnit() && + getDeclContext()->getRedeclContext()->isTranslationUnit() && getIdentifier() && getIdentifier()->isStr("main"); } diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 9463b6cc73..0316124fbe 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -471,8 +471,8 @@ DeclContext::~DeclContext() { } DeclContext *DeclContext::getLookupParent() { // FIXME: Find a better way to identify friends if (isa<FunctionDecl>(this)) - if (getParent()->getLookupContext()->isFileContext() && - getLexicalParent()->getLookupContext()->isRecord()) + if (getParent()->getRedeclContext()->isFileContext() && + getLexicalParent()->getRedeclContext()->isRecord()) return getLexicalParent(); return getParent(); @@ -515,7 +515,7 @@ bool DeclContext::isTransparentContext() const { return false; } -bool DeclContext::Encloses(DeclContext *DC) { +bool DeclContext::Encloses(const DeclContext *DC) const { if (getPrimaryContext() != this) return getPrimaryContext()->Encloses(DC); @@ -847,10 +847,10 @@ DeclContext::lookup(DeclarationName Name) const { return const_cast<DeclContext*>(this)->lookup(Name); } -DeclContext *DeclContext::getLookupContext() { +DeclContext *DeclContext::getRedeclContext() { DeclContext *Ctx = this; - // Skip through transparent contexts. - while (Ctx->isTransparentContext()) + // Skip through transparent contexts, except inline namespaces. + while (Ctx->isTransparentContext() && !Ctx->isNamespace()) Ctx = Ctx->getParent(); return Ctx; } @@ -863,6 +863,24 @@ DeclContext *DeclContext::getEnclosingNamespaceContext() { return Ctx->getPrimaryContext(); } +bool DeclContext::InEnclosingNamespaceSetOf(const DeclContext *O) const { + // For non-file contexts, this is equivalent to Equals. + if (!isFileContext()) + return O->Equals(this); + + do { + if (O->Equals(this)) + return true; + + const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(O); + if (!NS || !NS->isInline()) + break; + O = NS->getParent(); + } while (O); + + return false; +} + void DeclContext::makeDeclVisibleInContext(NamedDecl *D, bool Recoverable) { // FIXME: This feels like a hack. Should DeclarationName support // template-ids, or is there a better way to keep specializations |