<div dir="ltr">I may be mistaken as I just took a quick look, but in ilist_node the function "getPrevNode()" actually calls a method on the previous node:<div><br></div><div><div>NodeTy *getPrevNode() {</div><div>
NodeTy *Prev = this->getPrev();</div><div><br></div><div> // Check for sentinel.</div><div> if (!Prev->getNext())</div><div> return 0;</div><div> </div><div> return Prev;</div><div>}</div></div><div><br></div>
<div><a href="http://llvm.org/docs/doxygen/html/ilist__node_8h_source.html#l00058">http://llvm.org/docs/doxygen/html/ilist__node_8h_source.html#l00058</a><br></div><div><br></div><div style>Try checking if current->getPrev() is null before calling current->getPrevNode().</div>
<div style><br></div><div style>Stephen</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 20 December 2012 10:42, Alexandru Ionut Diaconescu <span dir="ltr"><<a href="mailto:alexandruionutdiaconescu@gmail.com" target="_blank">alexandruionutdiaconescu@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello John,<br><br>I was following your procedures and I isolated the
problem. The problem are represented by the basic blocks with only one
element.<div class="im"><div><br><br>for (Function::iterator II = F.begin(), EE = F.end(); II != EE; ++II, ++ii) <br>
{ <br></div>BasicBlock* BB=II;<div><br><br>if (BB->getTerminator())<br> {<br> Instruction* current = BB->getTerminator();<br><br></div> Instruction* previous;<br> <br> errs()<<"AAA\n";<br>
if(<b><span style="color:rgb(153,0,0)">current->getPrevNode()</span></b>)<br> {<br> errs()<<"BBB\n";<br> previous = current->getPrevNode();<br> ok=1;<br>
}<br> <br></div> if (ok){<br> errs()<<"CCC\n";<br> ........<br><br><br>It does print AAA, but then I have the segfault. So when I am evaluating the <b><span style="color:rgb(153,0,0)">current->getPrevNode() </span></b>condition<span style="color:rgb(153,0,0)"><font color="#000000">, I got the segfault.<br>
Do you know how can I solve this?<br><br>Thank you <br>Alex<br></font></span>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>