<div dir="ltr"><div>Hi,<br><br></div>I am writing a ClangTool that visits every function in a module, and edits source code based on the CFG. For a function I want to instrument, however, the CFG produces blocks that list a successor as NULL. This is a problem because I need to perform a breadth-first search of the CFG, and I cannot because of the null successor. I have listed the result of cfg->dump() below. What could be the cause of this? Any help would be appreciated. Thanks.<br><br> [B18 (ENTRY)]<br> Succs (1): B17<br><br> [B1]<br> 1: i += 30<br> Preds (1): B2<br> Succs (1): B5<br><br> [B2]<br> 1: strlen(json)<br> 2: MarsSendBlocking(1, json, [B2.1])<br> Preds (2): B3 B4<br> Succs (1): B1<br><br> [B3]<br> Preds (1): B4<br> Succs (1): B2<br><br> [B4]<br> T: if <null expr><br> Preds (1): B5<br> Succs (2): B3 B2<br><br> [B5]<br> T: for (; ; ...)<br> Preds (2): B1 B6<br> Succs (2): B4 NULL<br><br> [B6]<br> 1: strlen(json)<br> 2: MarsSendBlocking(1, json, [B6.1])<br> Succs (1): B5<br><br> [B7]<br> 1: i++<br> Preds (2): B8 B9<br> Succs (1): B10<br><br> [B8]<br> Preds (1): B9<br> Succs (1): B7<br><br> [B9]<br> 1: char tempString[6];<br> T: if <null expr><br> Preds (1): B10<br> Succs (2): B8 B7<br><br> [B10]<br> T: for (...; ; ...)<br> Preds (2): B7 B11<br> Succs (2): B9 NULL<br><br> [B11]<br> 1: ndc_str[14] = 0<br> 2: npi_str[12] = 0<br> 3: zip_str[5] = 0<br> 4: t.tm_isdst = -1<br> 5: mktime(&t)<br> 6: time_prescribed = [B11.5]<br> 7: printf("year:%u month:%u day:%u hour:%u min:%u sec:%u\n", t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec)<br> 8: i = 0<br> Preds (1): B12<br> Succs (1): B10<br><br> [B12]<br> T: if <null expr><br> Preds (2): B13 B14<br> Succs (2): B11 B0<br><br> [B13]<br> Preds (1): B14<br> Succs (1): B12<br><br> [B14]<br> T: if <null expr><br> Succs (2): B13 B12<br><br> [B15]<br> 1: i++<br> Preds (1): B16<br> Succs (1): B16<br><br> [B16]<br> T: for (...; ; ...)<br> Preds (2): B15 B17<br> Succs (2): B15 NULL<br><br> [B17]<br> 1: char ndc_str[15];<br> 2: char npi_str[13];<br> 3: char zip_str[6];<br> 4: char dosageIntervals;<br> 5: int last_msg_idx;<br> 6: int i;<br> 7: struct tm t;<br> 8: time_t time_prescribed;<br> 9: i = 0<br> Preds (1): B18<br> Succs (1): B16<br><br> [B0 (EXIT)]<br> Preds (1): B12<br clear="all"><div><div><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Derrick McKee<div>Ph.D. Student Computer Science</div><div>Purdue University</div><div>SensorHound, Inc.</div></div></div></div></div>
</div></div></div>