[cfe-dev] CFGBlock: Multiple CFGElements for one statement

Tobias Ludwig via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 23 00:27:09 PDT 2015


Hello,


I'm using libTooling to receive an AST. 
Afterwards I'm generating a CFG for specific methods.
The goal is to analyze the dataflow within a CFGBlock. 
Therefore I'm iterating over each Element and convert it to a Stmt and
use the RecursiveVistor to figure out what is happening. 
Please don't worry now about complexity I'm using a really restricted
subset of C++.
 
Now to my problem, if I have a piece of code like this:

>memberVar = obj->method();

I expect one CFGElement for this statement.
But, the CFGBlock contains three Elements like this:

>[B2]
>1: this->obj (OperatorCall)
>2: [B2.1]->method()
>3: this->memberVar = [B2.2]

This is really confusing to me and does not cope with my expected
behavior. I'm still running Clang3.5, in case this issue is solved with
later versions I'd be happy to know :)

Questios:
1) Why is that? The top Stmt is the BinaryOperation and everything else
is just nested statements and is contained by 3?

2) How do I geht the information, that Stmt 1 and 2 are contained by 3
and I do not have to run an analysis on them?


Thank you very much for any help!


Best
Tobias






More information about the cfe-dev mailing list