Skip to content

Commit 6ddab35

Browse files
committed
Create Call library
1 parent 7c5fb87 commit 6ddab35

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import cpp
2+
import codingstandards.cpp.types.Type
3+
4+
/**
5+
* Gets the `FunctionType` of an expression call.
6+
*/
7+
FunctionType getExprCallFunctionType(ExprCall call) {
8+
// A standard expression call
9+
// Returns a FunctionPointerIshType
10+
result = call.(ExprCall).getExpr().getType()
11+
or
12+
// An expression call using the pointer to member operator (.* or ->*)
13+
// This special handling is required because we don't have a CodeQL class representing the call
14+
// to a pointer to member function, but the right hand side is extracted as the -1 child of the
15+
// call.
16+
// Returns a RoutineType
17+
result = call.(ExprCall).getChild(-1).getType().(PointerToMemberType).getBaseType()
18+
}

cpp/misra/src/codingstandards/cpp/misra/BuiltInTypeRules.qll

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import cpp
66
import codingstandards.cpp.misra
7+
import codingstandards.cpp.Call
78
import codingstandards.cpp.Type
89

910
/**
@@ -120,19 +121,6 @@ class CanonicalIntegerTypes extends NumericType, IntegralType {
120121
CanonicalIntegerTypes() { this = this.getCanonicalArithmeticType() }
121122
}
122123

123-
FunctionType getExprCallFunctionType(ExprCall call) {
124-
// A standard expression call
125-
// Returns a FunctionPointerIshType
126-
result = call.(ExprCall).getExpr().getType()
127-
or
128-
// An expression call using the pointer to member operator (.* or ->*)
129-
// This special handling is required because we don't have a CodeQL class representing the call
130-
// to a pointer to member function, but the right hand side is extracted as the -1 child of the
131-
// call.
132-
// Returns a RoutineType
133-
result = call.(ExprCall).getChild(-1).getType().(PointerToMemberType).getBaseType()
134-
}
135-
136124
predicate isAssignment(Expr source, NumericType targetType, string context) {
137125
exists(Expr preConversionAssignment |
138126
isPreConversionAssignment(preConversionAssignment, targetType, context) and

0 commit comments

Comments
 (0)