mirror of
https://github.com/github/codeql.git
synced 2026-04-27 09:45:15 +02:00
[CPP-340] Re-work QL query; treat undeclared C functions the same way as
()-declared functions.
This commit is contained in:
@@ -17,11 +17,11 @@ from FunctionCall fc, Function f
|
||||
/* There must be a zero-parameter declaration */
|
||||
and exists ( FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() | fde.getNumberOfParameters() = 0)
|
||||
/* There must be a mismatch between number of call arguments and number of parameters in some
|
||||
* non-implicit declaration of Function f
|
||||
* declaration of Function f
|
||||
*/
|
||||
and exists ( FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() | not fde.isImplicit() and fde.getNumberOfParameters() != fc.getNumberOfArguments())
|
||||
/* There must be no _definition_ of Function f whose number of parameters matches number of call arguments */
|
||||
and not exists ( FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() | fde.isDefinition() and fde.getNumberOfParameters() = fc.getNumberOfArguments())
|
||||
select fc
|
||||
and exists ( FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() | fde.getNumberOfParameters() != fc.getNumberOfArguments())
|
||||
/* There must be no actual declaration of Function f whose number of parameters matches number of call arguments */
|
||||
and not exists ( FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() | not fde.isImplicit() and fde.getNumberOfParameters() = fc.getNumberOfArguments())
|
||||
select fc, "This call has arguments, but $@ is not declared with any parameters.", f, f.toString()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user