Python control flow granularity.




I was exploring PyControlFlowProvider class to generate control flow. The generated control flow seems too detailed for me. I would like to have a less detailed control flow (like without ReadWriteInstruction, only expression-level control flow).

For this code snippet:

def control_flow():
    a = 20
    b = int(input('hi'))
    if b > 10:
        a = 30
        a = 20
    return a

I get this control flow using PyControlFlowProvider:

I would like to have a less granular version of this. Something like this:

    a = 20
b = int(input('hi'))
   b > 10
  /      \
a = 30    a = 20
  \      /
   \    /
   return a

Is there any way I can tune the amount of detail in the control flow provider?

Comment actions Permalink


PyControlFlowBuilder that is used in the provider does not have any options, feel free to take needed parts from the builder and create your own provider.


Please sign in to leave a comment.