Skip to content

Commit 9ea33bc

Browse files
authored
Merge pull request #21553 from geoffw0/implicitfn
C++: Disable cpp/implicit-function-declaration on build mode none databases
2 parents dfa8d72 + 56af9a8 commit 9ea33bc

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

cpp/ql/src/Likely Bugs/Underspecified Functions/ImplicitFunctionDeclaration.qhelp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function may behave unpredictably.</p>
1414
<p>This may indicate a misspelled function name, or that the required header containing
1515
the function declaration has not been included.</p>
1616

17+
<p>Note: This query is not compatible with <code>build mode: none</code> databases, and produces
18+
no results on those databases.</p>
19+
1720
</overview>
1821
<recommendation>
1922
<p>Provide an explicit declaration of the function before invoking it.</p>
@@ -26,4 +29,4 @@ the function declaration has not been included.</p>
2629
<references>
2730
<li>SEI CERT C Coding Standard: <a href="https://wiki.sei.cmu.edu/confluence/display/c/DCL31-C.+Declare+identifiers+before+using+them">DCL31-C. Declare identifiers before using them</a></li>
2831
</references>
29-
</qhelp>
32+
</qhelp>

cpp/ql/src/Likely Bugs/Underspecified Functions/ImplicitFunctionDeclaration.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* may lead to unpredictable behavior.
66
* @kind problem
77
* @problem.severity warning
8-
* @precision medium
8+
* @precision high
99
* @id cpp/implicit-function-declaration
1010
* @tags correctness
1111
* maintainability
@@ -17,6 +17,11 @@ import TooFewArguments
1717
import TooManyArguments
1818
import semmle.code.cpp.commons.Exclusions
1919

20+
/*
21+
* This query is not compatible with build mode: none databases, and produces
22+
* no results on those databases.
23+
*/
24+
2025
predicate locInfo(Locatable e, File file, int line, int col) {
2126
e.getFile() = file and
2227
e.getLocation().getStartLine() = line and
@@ -39,6 +44,7 @@ predicate isCompiledAsC(File f) {
3944
from FunctionDeclarationEntry fdeIm, FunctionCall fc
4045
where
4146
isCompiledAsC(fdeIm.getFile()) and
47+
not any(Compilation c).buildModeNone() and
4248
not isFromMacroDefinition(fc) and
4349
fdeIm.isImplicit() and
4450
sameLocation(fdeIm, fc) and
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The "Implicit function declaration" (`cpp/implicit-function-declaration`) query no longer produces results on `build mode: none` databases. These results were found to be very noisy and fundamentally imprecise in this mode.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The "Implicit function declaration" (`cpp/implicit-function-declaration`) query has been upgraded to `high` precision.

0 commit comments

Comments
 (0)