Skip to content

Commit 0431c73

Browse files
author
Nikita Kraiouchkine
committed
Resolve EXP32-C performance issue
1 parent c0f9767 commit 0431c73

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

c/cert/src/rules/EXP32-C/DoNotAccessVolatileObjectWithNonVolatileReference.ql

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ class CastFromVolatileToNonVolatileBaseType extends Cast, UndefinedVolatilePoint
5151
}
5252
}
5353

54+
/**
55+
* Holds if `va` has a subsequent `VariableAccess` which is dereferenced after access
56+
*/
57+
predicate hasSubsequentDereference(VariableAccess va) {
58+
dereferenced(va.getASuccessor+().(VariableAccess))
59+
}
60+
5461
/**
5562
* An `AssignExpr` with an *lvalue* that is a pointer to a volatile base type and
5663
* and *rvalue* that is not also a pointer to a volatile base type.
@@ -67,8 +74,7 @@ class NonVolatileObjectAssignedToVolatilePointer extends AssignExpr, UndefinedVo
6774
// considerations that this simple forward traversal of the control-flow graph does not account for.
6875
exists(VariableAccess va |
6976
va = this.getRValue().getAChild*().(VariableAccess).getTarget().getAnAccess() and
70-
this.getASuccessor+() = va and
71-
dereferenced(va)
77+
hasSubsequentDereference(va)
7278
)
7379
}
7480

0 commit comments

Comments
 (0)