To extract all the guarding conditions that ensure the inputs can reach a specific target line (e.g., “cplus-dem.c:4319”) in a C/C++ program, currently I am exploring to write CodeQL queries to complete this tasks. Are there any other tools or techniques I can use?
Take this code snippet as example, we can see that guarding conditions are
- x > 0
- y < 10
- x + y > 5
void exampleFunction(int x, int y) {
if (x > 0) {
if (y < 10) {
// Some code
if (x + y > 5) {
// Target line
printf("Target linen"); // line 4319
}
}
}
}
I have tried to write CodeQL queries, but the code still contains errors and can’t run.
null024 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.