Skip to content

Commit a033ba9

Browse files
committed
C++: Detect multiple definitions based on the format parameter index
1 parent cc35ec4 commit a033ba9

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ 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-
159155
from FormattingFunctionCall ffc, int n, Expr arg, Type expected, Type actual
160156
where
161157
(
@@ -176,7 +172,8 @@ where
176172
not arg.isFromUninstantiatedTemplate(_) and
177173
not actual.stripType() instanceof ErroneousType and
178174
not arg.(Call).mayBeFromImplicitlyDeclaredFunction() and
179-
functionHasUniqueArguments(ffc.getTarget())
175+
// Make sure that the format function definition is consistent
176+
count(ffc.getTarget().getFormatParameterIndex()) = 1
180177
select arg,
181178
"This format specifier for type '" + expected.getName() + "' does not match the argument type '" +
182179
actual.getUnspecifiedType().getName() + "'."

0 commit comments

Comments
 (0)