joern > config.tools.imageViewer = "/path/to/a/different/viewer"
cpg.method.isExternal
int i;
int buf[N];
for(i = 0; i <= N; i++){
buf[i] = 1;
}
buf[i]= 0;
joern> cpg.method.controlStructure.expressionDown.order(2).code.l
res45: List[String] = List("i <= N")
joern> val loopTo = cpg.method.controlStructure.expressionDown.order(2).isCallTo(Operators.lessEqualsThan).argument.order(2).code.l.head
loopTo: String = "N"
joern> cpg.method.local.typeFullNameExact(s"""int [ $loopTo ]""").code.l
res60: List[String] = List("buf")
cpg.method // query all methods
.controlStructure // filter for control structures
.parserTypeName("ForStatement") // only for statements
.expressionDown // "going one layer down"
.order(2) // choosing the second argument of the expression => for(i = 0; i <= N; i++){
.isCallTo(Operators.lessEqualsThan) // it has to be a call to "<="
.argument // going to the arguments of the call to "<="
.order(2) // second argument is the "N"
.code // get the code of the second argument
.l // as list (in this case it is only argument but could be more)
.head // get the first entry in the list
x42-c
for code at ./x42/c