summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-04-11 18:02:10 (GMT)
committerBrad King <brad.king@kitware.com>2014-04-11 18:04:48 (GMT)
commitb82cb69be094485eea6e091c30d8de60443ba64b (patch)
treeb6651d80780684375158f2ab31caed8f25ea38c5 /src
parentc785d1821c39fb02fb394d65af4d6065a594391b (diff)
downloadCastXML-b82cb69be094485eea6e091c30d8de60443ba64b.zip
CastXML-b82cb69be094485eea6e091c30d8de60443ba64b.tar.gz
CastXML-b82cb69be094485eea6e091c30d8de60443ba64b.tar.bz2
Output: Refactor declaration context traversal
Factor new method AddDeclContextMembers out of PrintMembersAttribute. It will need to become recursive to support LinkageSpecDecl members.
Diffstat (limited to 'src')
-rw-r--r--src/Output.cxx116
1 files changed, 64 insertions, 52 deletions
diff --git a/src/Output.cxx b/src/Output.cxx
index 574de3d..30bdeb5 100644
--- a/src/Output.cxx
+++ b/src/Output.cxx
@@ -174,6 +174,10 @@ class ASTVisitor: public ASTVisitorBase
void AddFunctionTemplateDecl(clang::FunctionTemplateDecl const* d,
std::set<unsigned int>* emitted = 0);
+ /** Add declaration context members for output. */
+ void AddDeclContextMembers(clang::DeclContext const* dc,
+ std::set<unsigned int>& emitted);
+
/** Add a starting declaration for output. */
void AddStartDecl(clang::Decl const* d);
@@ -580,6 +584,65 @@ void ASTVisitor::AddFunctionTemplateDecl(clang::FunctionTemplateDecl const* d,
}
//----------------------------------------------------------------------------
+void ASTVisitor::AddDeclContextMembers(clang::DeclContext const* dc,
+ std::set<unsigned int>& emitted)
+{
+ for(clang::DeclContext::decl_iterator i = dc->decls_begin(),
+ e = dc->decls_end(); i != e; ++i) {
+ clang::Decl const* d = *i;
+
+ // Skip declarations that are not really members of this context.
+ if(d->getDeclContext() != dc) {
+ continue;
+ }
+
+ // Ignore certain members.
+ switch (d->getKind()) {
+ case clang::Decl::CXXRecord: {
+ if(static_cast<clang::CXXRecordDecl const*>(d)->isInjectedClassName()) {
+ continue;
+ }
+ } break;
+ case clang::Decl::AccessSpec: {
+ continue;
+ } break;
+ case clang::Decl::ClassTemplate: {
+ this->AddClassTemplateDecl(
+ static_cast<clang::ClassTemplateDecl const*>(d), &emitted);
+ continue;
+ } break;
+ case clang::Decl::ClassTemplatePartialSpecialization: {
+ continue;
+ } break;
+ case clang::Decl::Empty: {
+ continue;
+ } break;
+ case clang::Decl::Friend: {
+ continue;
+ } break;
+ case clang::Decl::FunctionTemplate: {
+ this->AddFunctionTemplateDecl(
+ static_cast<clang::FunctionTemplateDecl const*>(d), &emitted);
+ continue;
+ } break;
+ case clang::Decl::Using: {
+ continue;
+ } break;
+ case clang::Decl::UsingDirective: {
+ continue;
+ } break;
+ default:
+ break;
+ }
+
+ // Queue this decl and print its id.
+ if(unsigned int id = this->AddDumpNode(d, true)) {
+ emitted.insert(id);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
void ASTVisitor::AddStartDecl(clang::Decl const* d)
{
switch (d->getKind()) {
@@ -877,59 +940,8 @@ void ASTVisitor::PrintContextAttribute(clang::Decl const* d)
void ASTVisitor::PrintMembersAttribute(clang::DeclContext const* dc)
{
std::set<unsigned int> emitted;
- for(clang::DeclContext::decl_iterator i = dc->decls_begin(),
- e = dc->decls_end(); i != e; ++i) {
- clang::Decl const* d = *i;
-
- // Skip declarations that are not really members of this context.
- if(d->getDeclContext() != dc) {
- continue;
- }
- // Ignore certain members.
- switch (d->getKind()) {
- case clang::Decl::CXXRecord: {
- if(static_cast<clang::CXXRecordDecl const*>(d)->isInjectedClassName()) {
- continue;
- }
- } break;
- case clang::Decl::AccessSpec: {
- continue;
- } break;
- case clang::Decl::ClassTemplate: {
- this->AddClassTemplateDecl(
- static_cast<clang::ClassTemplateDecl const*>(d), &emitted);
- continue;
- } break;
- case clang::Decl::ClassTemplatePartialSpecialization: {
- continue;
- } break;
- case clang::Decl::Empty: {
- continue;
- } break;
- case clang::Decl::Friend: {
- continue;
- } break;
- case clang::Decl::FunctionTemplate: {
- this->AddFunctionTemplateDecl(
- static_cast<clang::FunctionTemplateDecl const*>(d), &emitted);
- continue;
- } break;
- case clang::Decl::Using: {
- continue;
- } break;
- case clang::Decl::UsingDirective: {
- continue;
- } break;
- default:
- break;
- }
-
- // Queue this decl and print its id.
- if(unsigned int id = this->AddDumpNode(d, true)) {
- emitted.insert(id);
- }
- }
+ this->AddDeclContextMembers(dc, emitted);
if(!emitted.empty()) {
this->OS << " members=\"";