diff options
author | Brad King <brad.king@kitware.com> | 2015-05-15 19:51:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-05-15 19:51:25 (GMT) |
commit | d741c9e4e56ff43dc35603327f1a8d30c8bb167c (patch) | |
tree | 6b9cc06532204d3ff7c8b5fa751cbef4e976ec83 /src | |
parent | 5587062f5f894d7b2d7a61679a495535db0a8924 (diff) | |
download | CastXML-d741c9e4e56ff43dc35603327f1a8d30c8bb167c.zip CastXML-d741c9e4e56ff43dc35603327f1a8d30c8bb167c.tar.gz CastXML-d741c9e4e56ff43dc35603327f1a8d30c8bb167c.tar.bz2 |
Output: Place inline namespace members in containing namespace
An inline namespace affects the linkage of its members but for APIs
the members are effectively in the containing namespace. Generate
output as if they were really in the containing namespace and do
not generate a Namespace element for an inline namespace.
If --castxml-start names an inline namespace simply ignore it to avoid
dumping a Namespace element for it. One can argue this is valid since
the inline namespace should not normally be named in API usage.
Set our printing policy to avoid showing the inline namespace component
automatically. Note that expressions in the source code that hard-code
the inline namespace name will still be preserved and show the inline
namespace when printed (e.g. Variable init="" attribute expressions).
Suggested-by: Michka Popoff <michkapopoff@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/Output.cxx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Output.cxx b/src/Output.cxx index d505b54..202ce63 100644 --- a/src/Output.cxx +++ b/src/Output.cxx @@ -493,6 +493,7 @@ public: RequireComplete(true), MangleContext(ctx.createMangleContext()), PrintingPolicy(ctx.getPrintingPolicy()) { + this->PrintingPolicy.SuppressUnwrittenScope = true; } /** Visit declarations in the given translation unit. @@ -792,6 +793,14 @@ void ASTVisitor::AddDeclContextMembers(clang::DeclContext const* dc, static_cast<clang::LinkageSpecDecl const*>(d), emitted); continue; } break; + case clang::Decl::Namespace: { + clang::NamespaceDecl const* nd = + static_cast<clang::NamespaceDecl const*>(d); + if (nd->isInline()) { + this->AddDeclContextMembers(nd, emitted); + continue; + } + } break; case clang::Decl::Using: { continue; } break; @@ -821,6 +830,11 @@ void ASTVisitor::AddStartDecl(clang::Decl const* d) this->AddFunctionTemplateDecl( static_cast<clang::FunctionTemplateDecl const*>(d)); break; + case clang::Decl::Namespace: { + if (!static_cast<clang::NamespaceDecl const*>(d)->isInline()) { + this->AddDeclDumpNode(d, true); + } + } break; case clang::Decl::Using: { clang::UsingDecl const* ud = static_cast<clang::UsingDecl const*>(d); for(clang::UsingDecl::shadow_iterator i = ud->shadow_begin(), @@ -961,6 +975,10 @@ void ASTVisitor::OutputCvQualifiedType(DumpNode const* dn) //---------------------------------------------------------------------------- ASTVisitor::DumpId ASTVisitor::GetContextIdRef(clang::DeclContext const* dc) { + while (dc->isInlineNamespace()) { + dc = dc->getParent(); + } + if(clang::Decl const* d = clang::dyn_cast<clang::Decl>(dc)) { return this->AddDeclDumpNode(d, false); } else { |