Skip to content

Commit de6cd01

Browse files
author
Nikita Kraiouchkine
committed
Move PointerOrArrayType into Pointers.qll to deduplicate usage
1 parent 934811d commit de6cd01

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

c/cert/src/rules/EXP43-C/DoNotPassAlisedPointerToRestrictQualifiedParameter.ql

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ import semmle.code.cpp.dataflow.DataFlow
1717
import semmle.code.cpp.pointsto.PointsTo
1818
import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
1919

20-
/**
21-
* A type that is a pointer or array type.
22-
*/
23-
class PointerOrArrayType extends DerivedType {
24-
PointerOrArrayType() {
25-
this.stripTopLevelSpecifiers() instanceof PointerType or
26-
this.stripTopLevelSpecifiers() instanceof ArrayType
27-
}
28-
}
29-
3020
/**
3121
* A function that has a parameter with a restrict-qualified pointer type.
3222
*/

c/common/src/codingstandards/c/Pointers.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
import cpp
66
import codingstandards.cpp.Type
77

8+
/**
9+
* A type that is a pointer or array type.
10+
*/
11+
class PointerOrArrayType extends DerivedType {
12+
PointerOrArrayType() {
13+
this.stripTopLevelSpecifiers() instanceof PointerType or
14+
this.stripTopLevelSpecifiers() instanceof ArrayType
15+
}
16+
}
17+
818
/**
919
* An expression which performs pointer arithmetic
1020
*/

c/misra/src/rules/RULE-8-13/PointerShouldPointToConstTypeWhenPossible.ql

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,9 @@
1515

1616
import cpp
1717
import codingstandards.c.misra
18+
import codingstandards.c.Pointers
1819
import codingstandards.cpp.SideEffect
1920

20-
class PointerOrArrayType extends DerivedType {
21-
PointerOrArrayType() {
22-
this.stripTopLevelSpecifiers() instanceof PointerType or
23-
this.stripTopLevelSpecifiers() instanceof ArrayType
24-
}
25-
}
26-
2721
from Variable ptr, PointerOrArrayType type
2822
where
2923
not isExcluded(ptr, Pointers1Package::pointerShouldPointToConstTypeWhenPossibleQuery()) and

0 commit comments

Comments
 (0)