Comments taken into account

This commit is contained in:
Philippe Antoine
2020-07-09 16:05:24 +02:00
parent 5eff8d3165
commit d2763e8149
2 changed files with 3 additions and 8 deletions

View File

@@ -1,11 +1,11 @@
void test(char *arg1, int *arg2) {
if (arg1[0] == 'A') {
if (arg2 != NULL) {
if (arg2 != NULL) { //maybe redundant
*arg2 = 42;
}
}
if (arg1[1] == 'B')
{
*arg2 = 54;
*arg2 = 54; //dereferenced without checking first
}
}

View File

@@ -13,11 +13,6 @@
import cpp
predicate blockDominates(Block check, Block access) {
check.getLocation().getStartLine() <= access.getLocation().getStartLine() and
check.getLocation().getEndLine() >= access.getLocation().getEndLine()
}
predicate isCheckedInstruction(VariableAccess unchecked, VariableAccess checked) {
checked =
any(VariableAccess va |
@@ -25,7 +20,7 @@ predicate isCheckedInstruction(VariableAccess unchecked, VariableAccess checked)
) and
//Simple test if the first access in this code path is dereferenced
not dereferenced(checked) and
blockDominates(checked.getEnclosingBlock(), unchecked.getEnclosingBlock())
bbDominates(checked.getBasicBlock(), unchecked.getBasicBlock())
}
predicate candidateResultUnchecked(VariableAccess unchecked) {