From 65a3e69b26260427ee063e1d00eadf382487fc7d Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 26 Sep 2016 16:24:53 +0800 Subject: Debug - Clearer debug with item insertion and deletion --- src/ast/ast.cpp | 16 ++++++++++------ src/expand/cfg.cpp | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 7b92be33..35407cc4 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -256,14 +256,18 @@ UseStmt UseStmt::clone() const return rv; } -void Module::add_item( Named i ) { - m_items.push_back( mv$(i) ); - DEBUG("Item " << m_items.back().data.tag_str() << " - attrs = " << m_items.back().data.attrs); +void Module::add_item( Named named_item ) { + m_items.push_back( mv$(named_item) ); + const auto& i = m_items.back(); + if( i.name == "" ) { + } + else { + DEBUG(m_my_path << "::" << i.name << " = " << i.data.tag_str() << ", attrs = " << i.data.attrs); + } } void Module::add_item(bool is_pub, ::std::string name, Item it, MetaItems attrs) { - m_items.push_back( Named( mv$(name), mv$(it), is_pub ) ); - m_items.back().data.attrs = mv$(attrs); - DEBUG("Item " << ::AST::Item::tag_to_str( m_items.back().data.tag() ) << " - attrs = " << m_items.back().data.attrs); + it.attrs = mv$(attrs); + add_item( Named( mv$(name), mv$(it), is_pub ) ); } void Module::add_ext_crate(bool is_public, ::std::string ext_name, ::std::string imp_name, MetaItems attrs) { this->add_item( is_public, imp_name, Item::make_Crate({mv$(ext_name)}), mv$(attrs) ); diff --git a/src/expand/cfg.cpp b/src/expand/cfg.cpp index 746fd513..bc4dfa6e 100644 --- a/src/expand/cfg.cpp +++ b/src/expand/cfg.cpp @@ -129,7 +129,7 @@ class CCfgHandler: } } void handle(const Span& sp, const AST::MetaItem& mi, ::AST::Crate& crate, const AST::Path& path, AST::Module& mod, AST::Item&i) const override { - DEBUG("#[cfg] item - " << mi); + TRACE_FUNCTION_FR("#[cfg] item - " << mi, (i.is_None() ? "Deleted" : "")); if( check_cfg(sp, mi) ) { // Leave } -- cgit v1.2.3