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!
+Tim who did some GraphTraits refactoring On Tue, May 23, 2017 at 7:56 PM Jared Carlson via llvm-dev < llvm-dev at lists.llvm.org> wrote:> 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! > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170524/5ae8d30c/attachment.html>
On Tue, May 23, 2017 at 7:56 PM Jared Carlson via llvm-dev < llvm-dev at lists.llvm.org> wrote:> 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… >Please refer to include/llvm/ADT/GraphTraits.h for the documentation. In your case, for nodes, simply change `typedef DSNode NodeType;` to `typedef DSNode* NodeRef;` I'm not sure what DSGraph::iterator returns on dereference; but ultimately you want both ChildIteratorType and nodes_iterator to dereference to a NodeRef, as documented. You may find llvm::pointer_iterator or llvm::pointee_iterator helpful. I'd try to remove DerefFun and the usage of mapped_iterator.> > DSGraph::iterator by the way is ilist<DSNode>::iterator, as the graph > allows walking the nodes…. > > Any hints, would be much appreciated…. Thanks! > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170525/fece3ca3/attachment.html>
Thanks Tim, That’s the direction I was trying to go, but it felt as if I were making things worse so I backed out. I think I might have been missing the llvm::pointer_iterator and the llvm::pointee_iterator as means to remedy some of this. I’ll give it a shot and see where I end up, thanks! Jared> On May 24, 2017, at 8:17 PM, Tim Shen <timshen at google.com> wrote: > > On Tue, May 23, 2017 at 7:56 PM Jared Carlson via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote: > 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… > > Please refer to include/llvm/ADT/GraphTraits.h for the documentation. > > In your case, for nodes, simply change `typedef DSNode NodeType;` to `typedef DSNode* NodeRef;` > > I'm not sure what DSGraph::iterator returns on dereference; but ultimately you want both ChildIteratorType and nodes_iterator to dereference to a NodeRef, as documented. You may find llvm::pointer_iterator or llvm::pointee_iterator helpful. > > I'd try to remove DerefFun and the usage of mapped_iterator. > > > DSGraph::iterator by the way is ilist<DSNode>::iterator, as the graph allows walking the nodes…. > > Any hints, would be much appreciated…. Thanks! > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170525/b98c6d4f/attachment.html>
Apparently Analagous Threads
- [LLVMdev] CallGraph, GraphTraits and DominatorTree
- [5.0.0 Release] Release Candidate 3 tagged
- [PATCH] vsock/virtio: annotate 'the_virtio_vsock' RCU pointer
- [PATCH] vsock/virtio: annotate 'the_virtio_vsock' RCU pointer
- sparse warnings in net/vmw_vsock/virtio_transport.c