File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 13
13
import cpp
14
14
import codingstandards.c.cert
15
15
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
17
35
where
18
36
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