Hi All,

I have a question on performing analysis of if-conditions in the code
using dehydra/treehydra?

In the example below, I would like to get the condition (s.a > s.b)
and contents of the then-clause and else-clause of the if block.

#include <iostream>
struct my_struct{
int a;
int b;
int c;
};

int function()
{
 return 1;
}
main()
{
 struct my_struct s;
 s.a=function();
 s.b=1;
 s.c=0;
 if(s.a > s.b)
 {
  s.c=2;
 }
else
{
  s.c=3;
}
return 0;
}

I tried compiling the code using treehydra plugin using the following
javascript.

function process_function(f,arr) {
  print("process_function: " + f)
  print("process_statements: " + arr)
}

The data obtained from treehydra for the if condition is given below.

{statements:[{name:"my_struct::a", memberOf:#4#, type:#5#, loc:
{file:"./test1.c", line:3, column:5, _source_location:5721657},
fieldOf:{name:"s", type:#4#, loc:{file:"./test1.c", line:10, column:
19, _source_location:5722567}}}, {name:"my_struct::b", memberOf:#4#,
type:#5#, loc:{file:"./test1.c", line:4, column:5, _source_location:
5721785}, fieldOf:{name:"s", type:#4#, loc:{file:"./test1.c", line:10,
column:19, _source_location:5722567}}}, {name:"my_struct::c",
memberOf:#4#, type:#5#, loc:{file:"./test1.c", line:5, column:5,
_source_location:5721913}, fieldOf:{name:"s", type:#4#, loc:{file:"./
test1.c", line:10, column:19, _source_location:5722567}}, assign:
[{value:"0", type:#5#}]}, {name:"my_struct::c", memberOf:#4#,
type:#5#, loc:{file:"./test1.c", line:5, column:5, _source_location:
5721913}, fieldOf:{name:"s", type:#4#, loc:{file:"./test1.c", line:10,
column:19, _source_location:5722567}}, assign:[{value:"1",
type:#5#}]}], loc:{file:"./test1.c", line:13, column:2,
_source_location:5722934}},

The above statement seems to be flow insensitive. Is there any other
function that I can use to get flow sensitive data?

Thanks
Sreekumar
_______________________________________________
dev-static-analysis mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-static-analysis

Reply via email to