[llvm-dev] GraphTraits dereferencing
Jared Carlson via llvm-dev
llvm-dev at lists.llvm.org
Tue May 23 19:56:24 PDT 2017
Hello,
I’m trying to port a project up to 4.0 and I’m seeing the following error:
In file included from /Users/jaredcarlson/Projects/llvm-4.0.0.src/include/llvm/ADT/StringRef.h:13:
/Users/jaredcarlson/Projects/llvm-4.0.0.src/include/llvm/ADT/STLExtras.h:139:13: error: no type named 'type' in 'std::__1::result_of<std::__1::pointer_to_unary_function<llvm::DSNode *, llvm::DSNode &>
(llvm::DSNode &)>'
::type value_type;
~~^~~~
/Users/jaredcarlson/Projects/crab-llvm/dsa-seahorn/include/dsa/DSGraphTraits.h:122:25: note: in instantiation of template class
'llvm::mapped_iterator<llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::DSNode, true, false, void>, false, false>, std::__1::pointer_to_unary_function<llvm::DSNode *, llvm::DSNode &> >'
requested here
static nodes_iterator nodes_begin(DSGraph *G) {
So, it looks to me like in DSGraph, the iterator needs to be dereferenced correctly. Right now the source reads:
template <> struct GraphTraits<DSGraph*> {
typedef DSNode NodeType;
typedef DSNode::iterator ChildIteratorType;
// not sure this is necessary anymore as NodeRef must be a pointer
typedef std::pointer_to_unary_function<DSNode *, DSNode&> DerefFun;
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
typedef mapped_iterator<DSGraph::node_iterator, DerefFun> nodes_iterator;
static nodes_iterator nodes_begin(DSGraph *G) {
return map_iterator( G->node_begin(), DerefFun(dereference) );
}
static nodes_iterator nodes_end(DSGraph *G) {
return map_iterator( G->node_end(), DerefFun(dereference) );
}
static ChildIteratorType child_begin(NodeType *N) { return N->begin(); }
static ChildIteratorType child_end(NodeType *N) { return N->end(); }
};
I”m just unsure as in 4.0, there’s a need for a NodeRef to leverage the GraphTraits template which needs to be.a pointer but I don’t think that’s all that relevant here and the above code looks consistent with what I’m used to…
DSGraph::iterator by the way is ilist<DSNode>::iterator, as the graph allows walking the nodes….
Any hints, would be much appreciated…. Thanks!
More information about the llvm-dev
mailing list