#include "rust-expand-visitor.h"
#include "rust-ast-fragment.h"
+#include "rust-hir-map.h"
#include "rust-item.h"
#include "rust-proc-macro.h"
#include "rust-attributes.h"
builtin_derive_item (AST::Item &item, const AST::Attribute &derive,
BuiltinMacro to_derive)
{
- return AST::DeriveVisitor::derive (item, derive, to_derive);
+ auto items = AST::DeriveVisitor::derive (item, derive, to_derive);
+ for (auto &item : items)
+ Analysis::Mappings::get ().add_derived_node (item->get_node_id ());
+ return items;
}
static std::vector<std::unique_ptr<AST::Item>>
switch (node.get_kind ())
{
case AST::SingleASTNode::Kind::Item:
+ Analysis::Mappings::get ().add_derived_node (
+ node.get_item ()->get_node_id ());
result.push_back (node.take_item ());
break;
default:
return cap->second;
}
+void
+Mappings::add_derived_node (NodeId node_id)
+{
+ derived_nodes.insert (node_id);
+}
+
+bool
+Mappings::is_derived_node (NodeId node_id)
+{
+ return derived_nodes.find (node_id) != derived_nodes.end ();
+}
+
} // namespace Analysis
} // namespace Rust
void add_capture (NodeId closure, NodeId definition);
tl::optional<std::vector<NodeId>> lookup_captures (NodeId closure);
+ void add_derived_node (NodeId node_id);
+ bool is_derived_node (NodeId node_id);
+
private:
Mappings ();
// Closure AST NodeId -> vector of Definition node ids
std::unordered_map<NodeId, std::vector<NodeId>> captures;
+
+ std::set<NodeId> derived_nodes;
};
} // namespace Analysis