C++: Remove linker-awareness FPs

This commit is contained in:
Calum Grant
2025-01-28 14:06:38 +00:00
parent 6df8fdc233
commit cc35ec49e4
2 changed files with 6 additions and 2 deletions

View File

@@ -152,6 +152,10 @@ predicate trivialConversion(ExpectedType expected, Type actual) {
*/
int sizeof_IntType() { exists(IntType it | result = it.getSize()) }
predicate functionHasUniqueArguments(Function fn) {
forall(Parameter p | p = fn.getAParameter() | count(p.getType().getUnspecifiedType()) = 1)
}
from FormattingFunctionCall ffc, int n, Expr arg, Type expected, Type actual
where
(
@@ -171,7 +175,8 @@ where
not arg.isAffectedByMacro() and
not arg.isFromUninstantiatedTemplate(_) and
not actual.stripType() instanceof ErroneousType and
not arg.(Call).mayBeFromImplicitlyDeclaredFunction()
not arg.(Call).mayBeFromImplicitlyDeclaredFunction() and
functionHasUniqueArguments(ffc.getTarget())
select arg,
"This format specifier for type '" + expected.getName() + "' does not match the argument type '" +
actual.getUnspecifiedType().getName() + "'."

View File

@@ -1,2 +1 @@
| tests.c:7:18:7:18 | 1 | This format specifier for type 'char *' does not match the argument type 'int'. |
| tests.c:29:27:29:27 | 1 | This format specifier for type 'char *' does not match the argument type 'int'. |