[llvm-commits] [llvm] r48859 - /llvm/trunk/include/llvm/ADT/ilist

Nick Lewycky nicholas at mxc.ca
Wed Mar 26 22:01:56 PDT 2008


Maybe we only need to do that in DEBUG mode?

Nick

Chris Lattner wrote:
> Author: lattner
> Date: Wed Mar 26 21:43:03 2008
> New Revision: 48859
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=48859&view=rev
> Log:
> when a node is removed from an ilist, set its next/prev pointers to
> null.  This means that uses of invalidated iterators will explode violently
> with:
> ilist:143: failed assertion `NodePtr && "++'d off the end of an ilist!"'
> 
> instead of happening to work "most of the time".
> 
> 
> Modified:
>     llvm/trunk/include/llvm/ADT/ilist
> 
> Modified: llvm/trunk/include/llvm/ADT/ilist
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ilist?rev=48859&r1=48858&r2=48859&view=diff
> 
> ==============================================================================
> --- llvm/trunk/include/llvm/ADT/ilist (original)
> +++ llvm/trunk/include/llvm/ADT/ilist Wed Mar 26 21:43:03 2008
> @@ -356,6 +356,14 @@
>      setPrev(NextNode, PrevNode);
>      IT = NextNode;
>      removeNodeFromList(Node);  // Notify traits that we removed a node...
> +    
> +    // Set the next/prev pointers of the current node to null.  This isn't
> +    // strictly required, but this catches errors where a node is removed from
> +    // an ilist (and potentially deleted) with iterators still pointing at it.
> +    // When those iterators are incremented or decremented, they will assert on
> +    // the null next/prev pointer instead of "usually working".
> +    setNext(Node, 0);
> +    setPrev(Node, 0);
>      return Node;
>    }
>  
> 
> 
> _______________________________________________
> 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