Skip to content

Commit cc35ec4

Browse files
committed
C++: Remove linker-awareness FPs
1 parent 6df8fdc commit cc35ec4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ predicate trivialConversion(ExpectedType expected, Type actual) {
152152
*/
153153
int sizeof_IntType() { exists(IntType it | result = it.getSize()) }
154154

155+
predicate functionHasUniqueArguments(Function fn) {
156+
forall(Parameter p | p = fn.getAParameter() | count(p.getType().getUnspecifiedType()) = 1)
157+
}
158+
155159
from FormattingFunctionCall ffc, int n, Expr arg, Type expected, Type actual
156160
where
157161
(
@@ -171,7 +175,8 @@ where
171175
not arg.isAffectedByMacro() and
172176
not arg.isFromUninstantiatedTemplate(_) and
173177
not actual.stripType() instanceof ErroneousType and
174-
not arg.(Call).mayBeFromImplicitlyDeclaredFunction()
178+
not arg.(Call).mayBeFromImplicitlyDeclaredFunction() and
179+
functionHasUniqueArguments(ffc.getTarget())
175180
select arg,
176181
"This format specifier for type '" + expected.getName() + "' does not match the argument type '" +
177182
actual.getUnspecifiedType().getName() + "'."
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
| tests.c:7:18:7:18 | 1 | This format specifier for type 'char *' does not match the argument type 'int'. |
2-
| tests.c:29:27:29:27 | 1 | This format specifier for type 'char *' does not match the argument type 'int'. |

0 commit comments

Comments
 (0)