<div dir="ltr">Hello,<div><br></div><div>This is my first post in this list. I am building an analysis tool in <span style="color:rgb(50,109,116);font-family:Menlo;font-size:12px">ClangTool.</span>I am getting segmentation fault while building a dominator tree in clang. <span style="color:rgb(50,109,116);font-family:Menlo;font-size:12px">The sample code that I am using to build the dominator tree is the following:</span></div><div><span style="color:rgb(50,109,116);font-family:Menlo;font-size:12px"></span></div><div><span style="color:rgb(50,109,116);font-family:Menlo;font-size:12px"><br></span></div><div>





<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(155,35,147)"><b>const</b><span class="gmail-s1" style="color:rgb(0,0,0)"> </span><span class="gmail-s2" style="color:rgb(50,109,116)">Decl</span><span class="gmail-s1" style="color:rgb(0,0,0)">* D=</span><b>static_cast</b><span class="gmail-s1" style="color:rgb(0,0,0)"><</span><span class="gmail-s2" style="color:rgb(50,109,116)">Decl</span><span class="gmail-s1" style="color:rgb(0,0,0)"> *>(f);     // </span><span style="color:rgb(50,109,116)">FunctionDecl f</span></p>






<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo"><font color="#326d74">AnalysisDeclContextManager</font><span class="gmail-s1" style="color:rgb(0,0,0)"><span class="gmail-Apple-converted-space">  </span>*analDeclCtxMgr=</span><span class="gmail-s3" style=""><b style=""><font color="#9b2393">new</font><font color="#000000"> </font></b></span><font color="#326d74">AnalysisDeclContextManager</font><span class="gmail-s1" style="color:rgb(0,0,0)">(</span><font color="#326d74">context</font><span class="gmail-s1" style="color:rgb(0,0,0)">);</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s3" style="color:rgb(155,35,147)"><b>if</b></span>(<span class="gmail-s2" style="color:rgb(50,109,116)">AnalysisDeclContext</span><span class="gmail-Apple-converted-space">  </span>*analDeclCtx=analDeclCtxMgr-><span class="gmail-s4" style="color:rgb(36,82,86)">getContext</span>(D)){</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-Apple-converted-space">   </span><span class="gmail-s2" style="color:rgb(50,109,116)">DominatorTree</span> domTree;</p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:14px"><span class="gmail-Apple-converted-space">   </span>domTree.<span class="gmail-s4" style="color:rgb(36,82,86)">buildDominatorTree</span>(*analDeclCtx);</p><p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:14px">}</p><p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:14px"><br></p><p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:14px">The input function for my tool is the following code from perlbench(CPU 2017)</p><p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:14px"><br></p><p class="gmail-p1" style="margin:0px;font:12px Menlo;color:rgb(155,35,147);background-color:rgb(255,255,255)"><b>static</b><span class="gmail-s1" style="color:rgb(0,0,0)"> </span><b>bool</b></p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">S_adjust_index(pTHX_ AV *av, <span class="gmail-s2" style="color:rgb(155,35,147)"><b>const</b></span> MAGIC *mg, SSize_t *keyp)</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">{</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-converted-space">    </span><span class="gmail-s2" style="color:rgb(155,35,147)"><b>bool</b></span> adjust_index = <span class="gmail-s3" style="color:rgb(28,0,207)">1</span>;</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-converted-space">    </span><span class="gmail-s2" style="color:rgb(155,35,147)"><b>if</b></span> (mg) {</p><p class="gmail-p3" style="margin:0px;font:12px Menlo;color:rgb(83,101,121);background-color:rgb(255,255,255)"><span class="gmail-s1" style="color:rgb(0,0,0)"><span class="gmail-Apple-tab-span" style="white-space:pre">    </span></span><i>/* Handle negative array indices 20020222 MJD */</i></p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>SV * <span class="gmail-s2" style="color:rgb(155,35,147)"><b>const</b></span> ref = SvTIED_obj(MUTABLE_SV(av), mg);</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>SvGETMAGIC(ref);</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-tab-span" style="white-space:pre">        </span><span class="gmail-s2" style="color:rgb(155,35,147)"><b>if</b></span> (SvROK(ref) && SvOBJECT(SvRV(ref))) {</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span><span class="gmail-Apple-converted-space">    </span>SV * <span class="gmail-s2" style="color:rgb(155,35,147)"><b>const</b></span> * <span class="gmail-s2" style="color:rgb(155,35,147)"><b>const</b></span> negative_indices_glob =</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-tab-span" style="white-space:pre">   </span><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>hv_fetchs(SvSTASH(SvRV(ref)), NEGATIVE_INDICES_VAR, <span class="gmail-s3" style="color:rgb(28,0,207)">0</span>);</p><p class="gmail-p4" style="margin:0px;font:12px Helvetica;background-color:rgb(255,255,255);min-height:14px"><br></p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-tab-span" style="white-space:pre">    </span><span class="gmail-Apple-converted-space">    </span><span class="gmail-s2" style="color:rgb(155,35,147)"><b>if</b></span> (negative_indices_glob && isGV(*negative_indices_glob)</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-tab-span" style="white-space:pre">   </span> <span class="gmail-Apple-converted-space">    </span>&& SvTRUE(GvSV(*negative_indices_glob)))</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-tab-span" style="white-space:pre">  </span><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>adjust_index = <span class="gmail-s3" style="color:rgb(28,0,207)">0</span>;</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>}</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-converted-space">    </span>}</p><p class="gmail-p4" style="margin:0px;font:12px Helvetica;background-color:rgb(255,255,255);min-height:14px"><br></p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-converted-space">    </span><span class="gmail-s2" style="color:rgb(155,35,147)"><b>if</b></span> (adjust_index) {</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>*keyp += AvFILL(av) + <span class="gmail-s3" style="color:rgb(28,0,207)">1</span>;</p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-tab-span" style="white-space:pre">      </span><span class="gmail-s2" style="color:rgb(155,35,147)"><b>if</b></span> (*keyp < <span class="gmail-s3" style="color:rgb(28,0,207)">0</span>)</p><p class="gmail-p1" style="margin:0px;font:12px Menlo;color:rgb(155,35,147);background-color:rgb(255,255,255)"><span class="gmail-s1" style="color:rgb(0,0,0)"><span class="gmail-Apple-tab-span" style="white-space:pre">       </span><span class="gmail-Apple-converted-space">    </span></span><b>return</b><span class="gmail-s1" style="color:rgb(0,0,0)"> </span><b>FALSE</b><span class="gmail-s1" style="color:rgb(0,0,0)">;</span></p><p class="gmail-p2" style="margin:0px;font:12px Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-Apple-converted-space">    </span>}</p><p class="gmail-p1" style="margin:0px;font:12px Menlo;color:rgb(155,35,147);background-color:rgb(255,255,255)"><span class="gmail-s1" style="color:rgb(0,0,0)"><span class="gmail-Apple-converted-space">    </span></span><b>return</b><span class="gmail-s1" style="color:rgb(0,0,0)"> </span><b>TRUE</b><span class="gmail-s1" style="color:rgb(0,0,0)">;</span></p><p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:14px">





























</p><p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">}</p><p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><br></p><p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">Would you please let me know where the problem is?</p><p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><br></p><p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">Thanks,</p><p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">Masud</p><p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><br></p></div>





</div>