From a033ba934755e7e80b723195362c3031cc253b2d Mon Sep 17 00:00:00 2001 From: Calum Grant Date: Wed, 29 Jan 2025 13:36:10 +0000 Subject: [PATCH] C++: Detect multiple definitions based on the format parameter index --- cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql b/cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql index 738760656b0..75fe855c6f9 100644 --- a/cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql +++ b/cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql @@ -152,10 +152,6 @@ 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 ( @@ -176,7 +172,8 @@ where not arg.isFromUninstantiatedTemplate(_) and not actual.stripType() instanceof ErroneousType and not arg.(Call).mayBeFromImplicitlyDeclaredFunction() and - functionHasUniqueArguments(ffc.getTarget()) + // Make sure that the format function definition is consistent + count(ffc.getTarget().getFormatParameterIndex()) = 1 select arg, "This format specifier for type '" + expected.getName() + "' does not match the argument type '" + actual.getUnspecifiedType().getName() + "'."