This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] [WIP] Checker for detecting that the function was called with more function arguments than it could take
Needs RevisionPublic

Authored by george.karpenkov on Jun 12 2018, 5:47 PM.

Details

Reviewers
dcoughlin
NoQ
Summary

Useful for function pointers, as for those no compiler warning fires.

rdar://41067230

Diff Detail

Event Timeline

NoQ added inline comments.Jun 12 2018, 5:51 PM
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
103

I guess it's mostly Count or Number rather than Size of the arguments.

clang/lib/StaticAnalyzer/Checkers/ArgumentSizeChecker.cpp
20

< is also an error, right?

Also we could early-return instead of nesting.

This seems like a useful checker!

clang/lib/StaticAnalyzer/Checkers/ArgumentSizeChecker.cpp
2

Don't forget to add the license.

27

I don't think this is necessary.

But if you do remove it you'll need to make sure to not warn when the function decl is a non-prototype declaration.

35

Can you document why skipping implicit declarations is the right thing to do? I'm not sure why this is necessary.

44

It would be awesome to mention how many arguments are expected and also add a path note indicating where the function came from.

clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp
162

Don't forget to add a test for the variadics case.

george.karpenkov edited the summary of this revision. (Show Details)

Tests.

NoQ requested changes to this revision.Oct 5 2018, 3:44 PM

Apparently CallAndMessageChecker already has a similar check (see its checkPreCall()). Maybe merge them?

This revision now requires changes to proceed.Oct 5 2018, 3:44 PM