<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Mar 19, 2013, at 8:43 AM, Harald Servat <<a href="mailto:harald.servat@bsc.es">harald.servat@bsc.es</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">El dt 19 de 03 de 2013 a les 12:43 +0100, en/na Harald Servat va<br>escriure:<br><blockquote type="cite">Dear list,<br><br> I'm a newcommer to Clang/LLVM and I'm not sure whether this is the<br>correct place to ask this topic. If it's not, would you mind to point me<br>to the correct place/list?<br><br> I'm looking for a mechanism to detect basic blocks in C codes<br>(optionally C++, and eventually Fortran, in a future). I'm wondering<br>whether how can Clang help me? Is it an appropriate tool for doing such<br>thing? I'm not looking for something very difficult (I think).<span class="Apple-converted-space"> </span><br><br> Imagine I have the following code (line numbering on the left, source<br>code on the right)<br><br>01: void foo(void)<br>02: {<br>03:    int a = 10;<br>04:    int b = 11;<br>05:    if (a > b)<br>06:    {<br>07:       printf ("a is greater than b\n");<br>08:    }<br>09:    else<br>10:   {<br>11:      printf ("b is greater or equal than a\n");<br>12:   }<br>13: }<br><br> I'd like to have a obtain a list of pairs that delimit the basic<br>blocks of the code. For the previous example, for instance it should<br>return something like : [01-05], [06-08], [10-12].<span class="Apple-converted-space"> </span><br><br> Is there any Clang mechanism to provide such information? If not, is<br>it possible to do it through Clang?<br><br>Thank you very much!<br><br><br><br>WARNING / LEGAL TEXT: This message is intended only for the use of the<br>individual or entity to which it is addressed and may contain<br>information which is privileged, confidential, proprietary, or exempt<br>from disclosure under applicable law. If you are not the intended<br>recipient or the person responsible for delivering the message to the<br>intended recipient, you are strictly prohibited from disclosing,<br>distributing, copying, or in any way using this message. If you have<br>received this communication in error, please notify the sender and<br>destroy and delete any copies you may have received.<br><br><a href="http://www.bsc.es/disclaimer">http://www.bsc.es/disclaimer</a><br>_______________________________________________<br>cfe-users mailing list<br>cfe-users@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users<br></blockquote><br>Hello,<br><br> I found the following command exceptionally useful for the purposes I<br>wanted:<br><br>   clang -cc1 -ast-dump file.c<br><br></div></blockquote><div>This would dump AST, not Basic Blocks from Control Flow Graph. Clang does have CFG as well. </div><div><span style="color: rgb(34, 34, 34); line-height: 19px; background-color: rgb(255, 255, 255);">To view/dump CFG use </span><tt style="background-color: rgb(255, 255, 255);">debug.ViewCFG</tt><span style="color: rgb(34, 34, 34); line-height: 19px; background-color: rgb(255, 255, 255);"> or </span><tt style="background-color: rgb(255, 255, 255);">debug.DumpCFG</tt><span style="color: rgb(34, 34, 34); line-height: 19px; background-color: rgb(255, 255, 255);"> checkers:<font face="Lucida Grande, Lucida Sans Unicode, Arial, Verdana, Helvetica, sans-serif" style="font-size: small;"> </font></span><br style="color: rgb(34, 34, 34); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Verdana, Helvetica, sans-serif; font-size: small; line-height: 19px; background-color: rgb(255, 255, 255);"><tt style="background-color: rgb(255, 255, 255);">$ <b>clang -cc1 -analyze -analyzer-checker=debug.Dump/CFG test.c</b></tt></div><div><br></div><div>Note, this is a debugging facility and not a user feature of clang, so the interface is not guaranteed to be stable.</div><div><br></div><div>Cheers,</div><div>Anna.</div><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"> With that and some scripting I can do what I was looking for.<br><br>Thank you and sorry for disturbing your mailboxes<br><br><br><br>WARNING / LEGAL TEXT: This message is intended only for the use of the<br>individual or entity to which it is addressed and may contain<br>information which is privileged, confidential, proprietary, or exempt<br>from disclosure under applicable law. If you are not the intended<br>recipient or the person responsible for delivering the message to the<br>intended recipient, you are strictly prohibited from disclosing,<br>distributing, copying, or in any way using this message. If you have<br>received this communication in error, please notify the sender and<br>destroy and delete any copies you may have received.<br><br><a href="http://www.bsc.es/disclaimer">http://www.bsc.es/disclaimer</a><br>_______________________________________________<br>cfe-users mailing list<br><a href="mailto:cfe-users@cs.uiuc.edu">cfe-users@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users</a></div></blockquote></div><br></body></html>