[cfe-dev] Clang CFG - To build a variant of CFG
Shamiek Mangipudi via cfe-dev
cfe-dev at lists.llvm.org
Sat Jun 16 22:19:32 PDT 2018
Thanks for your response.
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.
I will check out other analyses in lib/Analysis.
Thanks.
On Sat, Jun 16, 2018 at 11:23 PM, Artem Dergachev <noqnoqneo at gmail.com>
wrote:
> 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.
>
> 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.
>
> 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.
>
> On 6/14/18 9:45 PM, Shamiek Mangipudi via cfe-dev wrote:
>
>> Hi,
>>
>> 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.
>>
>> 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.
>>
>> Thanks.
>> Shamiek
>>
>> My attempts:
>> I first looked at CFG::BuildOptions() (https://clang.llvm.org/doxyge
>> n/classclang_1_1CFG_1_1BuildOptions.html <https://clang.llvm.org/doxyge
>> n/classclang_1_1CFG_1_1BuildOptions.html>) and did not find anything
>> there.
>>
>> Then I went to to CFGBuilder::VisitIfStmt and found the line that causes
>> creation of basic blocks for individual conditions of the compound
>> condition (https://clang.llvm.org/doxygen/CFG_8cpp_source.html#l02180).
>> Should I try and change the code here or there might be deeper implications
>> for changing code here. Please suggest.
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
>
--
Shamiek Mangipudi
Graduate Student
Department of Computer Science
Purdue University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180617/10d9dcfb/attachment.html>
More information about the cfe-dev
mailing list