[PATCH] Fix GraphTraits for "const CallGraphNode *" and "const CallGraph *"

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Nov 5 06:47:00 PST 2014


Is it possible to avoid the code duplication?

Since this is just an API change, can you add a unittest?

On 4 November 2014 20:11, Speziale Ettore <speziale.ettore at gmail.com> wrote:
> Hello,
>
> GraphTraits specialization for "const CallGraphNode *" and "const CallGraph
> *" seems to be broken. This example:
>
> void foo(const CallGraph *G) {
>   auto I = GraphTraits<const CallGraph *>::nodes_begin(G);
>   auto K = I++;
>
>   ...
> }
>
> void bar(const CallGraphNode *N) {
>   auto I = GraphTraits<const CallGraphNode *>::nodes_begin(G);
>   auto K = I++;
>
>   ....
> }
>
> does not compile as the GraphTraits specialization does not use a
> mapped_iterator, hence it is not possible to dereference a
> CallGraphNode::CallRecord and get the corresponding const CallGraphNode *.
>
> The attached patch fixes this problem using the same approach used for
> non-const specialization.
>
> Hope it could be useful,
> Ettore Speziale
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



More information about the llvm-commits mailing list