File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313import cpp
1414import codingstandards.c.cert
1515
16- from
16+ /* 1. Declaring an integer variable to hold a pointer value */
17+ predicate integerVariableWithPointerValue ( Variable var ) {
18+ var .getUnderlyingType ( ) instanceof IntType and
19+ var .getAnAssignedValue ( ) .getUnderlyingType ( ) instanceof PointerType
20+ }
21+
22+ /* 2. Assigning an integer variable a pointer a pointer value */
23+ predicate assigningPointerValueToInteger ( Assignment assign ) {
24+ assign .getLValue ( ) .getUnderlyingType ( ) instanceof IntType and
25+ assign .getRValue ( ) .getUnderlyingType ( ) instanceof PointerType
26+ }
27+
28+ /* 3. Casting a pointer value to integer */
29+ predicate castingPointerToInteger ( Cast cast ) {
30+ cast .getExpr ( ) .getUnderlyingType ( ) instanceof PointerType and
31+ cast .getUnderlyingType ( ) instanceof PointerType
32+ }
33+
34+ from Variable x
1735where
1836 not isExcluded ( x , TypesPackage:: convertingAPointerToIntegerOrIntegerToPointerQuery ( ) ) and
19- select
37+ x .getType ( ) instanceof PointerType
38+ select x , x .getType ( ) .getAPrimaryQlClass ( )
You can’t perform that action at this time.
0 commit comments