This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] pr43179: CallDescription: Check number of parameters as well as number of arguments.
ClosedPublic

Authored by NoQ on Aug 30 2019, 1:41 PM.

Details

Summary

This is https://bugs.llvm.org/show_bug.cgi?id=43179.

Most functions that our checkers react upon are not C-style variadic functions, and therefore they have as many actual arguments as they have formal parameters.

However, it's not impossible to define a variadic function with the same name. This will crash any checker that relies on CallDescription to check the number of arguments but then silently assumes that the number of parameters is the same.

Change CallDescription to check both the number of arguments and the number of parameters by default.

If we're intentionally trying to match variadic functions, allow specifying arguments and parameters separately (possibly omitting any of them). For now we only have one CallDescription which would make use of those, namely __builtin_va_start itself.

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ created this revision.Aug 30 2019, 1:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2019, 1:41 PM
NoQ retitled this revision from [analyzer] CallDescription: Check number of parameters as well as number of arguments. to [analyzer] pr43179: CallDescription: Check number of parameters as well as number of arguments..Aug 30 2019, 1:41 PM
NoQ edited the summary of this revision. (Show Details)
Charusso accepted this revision.Aug 30 2019, 1:43 PM

I like the isolation of this kind of stuff. Thanks you!

This revision is now accepted and ready to land.Aug 30 2019, 1:43 PM
NoQ added a comment.Aug 30 2019, 2:31 PM

For the actual variadic functions i'm thinking of something like {CDF_Variadic, "fprintf", 2} which will match all calls to variadic functions named "fprintf" that have exactly two non-variadic parameters and at least two arguments on the call site [which occupy those non-variadic parameters]. I'm not implementing it yet because we don't need it yet.

I'm not sure if that's the best syntax. I didn't think too deeply about it because i'm waiting for more examples to generalize upon.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 6 2019, 1:53 PM