[CPP-340] Delete ArgumentsToImplicit.ql and associated files.

Reduce MistypedFunctionArguments.ql precision to `medium`.
This commit is contained in:
Ziemowit Laski
2019-04-28 13:49:46 -07:00
parent ac58bdfc58
commit 4a760b1561
6 changed files with 1 additions and 88 deletions

View File

@@ -1,9 +0,0 @@
void calls() {
undeclared(); // GOOD
undeclared(1); // BAD
undeclared(1, 2); // BAD
}

View File

@@ -1,29 +0,0 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>An implicitly-declared function is called with arguments.</p>
<p>This may indicate that an incorrect function is being called, or that the signature
(parameter list) of the called function is not known to the author.</p>
<p>In C, an implicitly declared function is assumed to accept no arguments. Providing
these arguments incurs an unneeded computational overhead, both
in terms of time and of additional stack space.</p>
</overview>
<recommendation>
<p>Call the function without any arguments.</p>
</recommendation>
<example><sample src="ArgumentsToImplicit.c" />
</example>
<references>
<li>SEI CERT C Coding Standard: <a href="https://wiki.sei.cmu.edu/confluence/display/c/DCL20-C.+Explicitly+specify+void+when+a+function+accepts+no+arguments"> DCL20-C. Explicitly specify void when a function accepts no arguments </a></li>
</references>
</qhelp>

View File

@@ -1,47 +0,0 @@
/**
* @name Call with arguments to an implicitly declared function
* @description A function call passed arguments even though the
* function in question is only implicitly declared (and
* hence accepting no arguments). This may indicate
* that the code does not follow the author's intent.
* @kind problem
* @problem.severity warning
* @precision very-high
* @id cpp/arguments-to-implicit
* @tags correctness
* maintainability
*/
import cpp
// True if there is no explicit definition of the function
predicate hasNoExplicitDecl(Function f) {
not exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() | not fde.isImplicit())
}
// True if this file (or header) was compiled as a C file
predicate isCompiledAsC(Function f) {
exists(File file | file.compiledAsC() |
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
)
}
predicate isWhitelisted(Function f) {
f instanceof BuiltInFunction
or
// The following list can be expanded as the need arises
exists(string name | name = f.getName() |
name = "static_assert" or
name = "_Static_assert" or
name = "strptime"
)
}
from FunctionCall fc, Function f
where
f = fc.getTarget() and
hasNoExplicitDecl(f) and
isCompiledAsC(f) and
not isWhitelisted(f) and
fc.getNumberOfArguments() > 0
select fc, "This call to an implicitly declared function $@ has arguments.", f, f.toString()

View File

@@ -6,7 +6,7 @@
* arguments on a stack may lead to unpredictable function behavior.
* @kind problem
* @problem.severity warning
* @precision high
* @precision medium
* @id cpp/mistyped-function-arguments
* @tags correctness
* maintainability

View File

@@ -1 +0,0 @@
| test.c:28:3:28:12 | call to undeclared | This call to an implicitly declared function $@ has arguments. | test.c:27:3:27:3 | undeclared | undeclared |

View File

@@ -1 +0,0 @@
Likely Bugs/Underspecified Functions/ArgumentsToImplicit.ql