File tree Expand file tree Collapse file tree 3 files changed +19
-9
lines changed Expand file tree Collapse file tree 3 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,20 @@ class UnnamedParameter extends Parameter {
22
22
UnnamedParameter ( ) { not this .isNamed ( ) }
23
23
}
24
24
25
+ /*
26
+ * This is a copy of the private `hasZeroParamDecl` predicate from the standard set of
27
+ * queries as of the `codeql-cli/2.11.2` tag in `github/codeql`.
28
+ */
29
+
30
+ predicate hasZeroParamDecl ( Function f ) {
31
+ exists ( FunctionDeclarationEntry fde | fde = f .getADeclarationEntry ( ) |
32
+ not fde .isImplicit ( ) and
33
+ not fde .hasVoidParamList ( ) and
34
+ fde .getNumberOfParameters ( ) = 0 and
35
+ not fde .isDefinition ( )
36
+ )
37
+ }
38
+
25
39
from Function f , string msg
26
40
where
27
41
not isExcluded ( f , Declarations4Package:: functionTypesNotInPrototypeFormQuery ( ) ) and
30
44
f .getAParameter ( ) instanceof UnnamedParameter and
31
45
msg = "Function " + f + " declares parameter that is unnamed."
32
46
or
33
- //void keyword not present in function signature, no way to tell which
34
- not exists ( f .getAParameter ( ) ) and
35
- msg =
36
- "Function " + f +
37
- " may not specify all parameter types or may not specifiy void for no parameters present."
47
+ hasZeroParamDecl ( f ) and
48
+ msg = "Function " + f + " does not specifiy void for no parameters present."
38
49
or
39
50
exists ( Parameter p |
40
51
p .getFunction ( ) = f and
Original file line number Diff line number Diff line change 1
- | test.c:2:6:2:7 | f0 | Function f0 may not specify all parameter types or may not specifiy void for no parameters present. |
2
1
| test.c:3:6:3:7 | f1 | Function f1 declares parameter that is unnamed. |
3
- | test.c:4:6:4:7 | f2 | Function f2 may not specify all parameter types or may not specifiy void for no parameters present. |
4
- | test.c:5:6:5:7 | f3 | Function f3 may not specify all parameter types or may not specifiy void for no parameters present. |
2
+ | test.c:4:6:4:7 | f2 | Function f2 does not specifiy void for no parameters present. |
3
+ | test.c:5:6:5:7 | f3 | Function f3 does not specifiy void for no parameters present. |
5
4
| test.c:7:5:7:6 | f5 | Function f5 declares parameter in unsupported declaration list. |
Original file line number Diff line number Diff line change 1
1
void f (int x ); // COMPLIANT
2
- void f0 (void ); // COMPLIANT[FALSE_POSITIVE]
2
+ void f0 (void ); // COMPLIANT
3
3
void f1 (int ); // NON_COMPLIANT
4
4
void f2 (); // NON_COMPLIANT
5
5
void f3 (x ); // NON_COMPLIANT
You can’t perform that action at this time.
0 commit comments