<div dir="ltr">Thanks for your response.<br><br>Yes, the current CFG is correct and represents the short-circuit (finer) paths. The basic blocks representing the short-circuit nature were creating many branches in the CFG which I did not want. I just wanted to have a single block for an if Stmt with a fork to represent whether the entire condition was evaluated to true or false.<br><br>I will check out other analyses in lib/Analysis.<div><br></div><div>Thanks.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 16, 2018 at 11:23 PM, Artem Dergachev <span dir="ltr"><<a href="mailto:noqnoqneo@gmail.com" target="_blank">noqnoqneo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yep, you've found the right piece of code, and you should be able to tweak it to change the CFG in that manner. CFGBuilder is solely responsible for the CFG.<br>
<br>
I also want to point out that the current CFG is correct: it reflects the short-circuit nature of logical operators. So i'm surprised you need this change.<br>
<br>
There is a selection of existing CFG-based analyses in lib/Analysis, you may be able to learn from them or even re-use some of them. And we've got the whole Static Analyzer that performs symbolic execution over the CFG.<span class=""><br>
<br>
On 6/14/18 9:45 PM, Shamiek Mangipudi via cfe-dev wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
Hi,<br>
<br>
I recently started working on control flow analysis of C programs using CFG generated by clang. I noticed that clang generates basic blocks for each condition of a compound condition it encounters in if statment (or in loop conditions). I wanted to have only one basic basic with the entire compound condition instead of having basic blocks for each condition.<br>
<br>
I am outlining my attempts and the direction in which I tried. Please let me know if there is a better way to what I am trying to achieve or I should take an entirely new direction.<br>
<br>
Thanks.<br>
Shamiek<br>
<br>
My attempts:<br></span>
I first looked at CFG::BuildOptions() (<a href="https://clang.llvm.org/doxygen/classclang_1_1CFG_1_1BuildOptions.html" rel="noreferrer" target="_blank">https://clang.llvm.org/doxyge<wbr>n/classclang_1_1CFG_1_1BuildOp<wbr>tions.html</a> <<a href="https://clang.llvm.org/doxygen/classclang_1_1CFG_1_1BuildOptions.html" rel="noreferrer" target="_blank">https://clang.llvm.org/doxyge<wbr>n/classclang_1_1CFG_1_1BuildOp<wbr>tions.html</a>>) and did not find anything there.<span class=""><br>
<br>
Then I went to to CFGBuilder::VisitIfStmt and found the line that causes creation of basic blocks for individual conditions of the compound condition (<a href="https://clang.llvm.org/doxygen/CFG_8cpp_source.html#l02180" rel="noreferrer" target="_blank">https://clang.llvm.org/doxyge<wbr>n/CFG_8cpp_source.html#l02180</a>)<wbr>. Should I try and change the code here or there might be deeper implications for changing code here. Please suggest.<br>
<br>
<br></span>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Shamiek Mangipudi<div>Graduate Student</div><div>Department of Computer Science</div><div>Purdue University</div></div></div></div></div>
</div>