-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathDoNotCallFunctionsWithIncompatibleArguments.ql
More file actions
34 lines (32 loc) · 1.17 KB
/
DoNotCallFunctionsWithIncompatibleArguments.ql
File metadata and controls
34 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* @id c/cert/do-not-call-functions-with-incompatible-arguments
* @name EXP37-C: Do not pass arguments with an incompatible count or type to a function
* @description The arguments passed to a function must be compatible with the function's
* parameters.
* @kind problem
* @precision high
* @problem.severity error
* @tags external/cert/id/exp37-c
* correctness
* external/cert/severity/medium
* external/cert/likelihood/probable
* external/cert/remediation-cost/high
* external/cert/priority/p4
* external/cert/level/l3
* coding-standards/baseline/safety
* external/cert/obligation/rule
*/
import cpp
import codingstandards.c.cert
import codingstandards.cpp.MistypedFunctionArguments
from FunctionCall fc, Function f, Parameter p
where
not isExcluded(fc, ExpressionsPackage::doNotCallFunctionsWithIncompatibleArgumentsQuery()) and
(
mistypedFunctionArguments(fc, f, p)
or
complexArgumentPassedToRealParameter(fc, f, p)
)
select fc,
"Argument $@ in call to " + f.toString() + " is incompatible with parameter " + p.getTypedName() +
".", fc.getArgument(p.getIndex()) as arg, arg.toString()