This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][StdLibraryFunctionsChecker] Add POSIX time handling functions
ClosedPublic

Authored by martong on Jul 21 2020, 9:57 AM.

Diff Detail

Event Timeline

martong created this revision.Jul 21 2020, 9:57 AM
balazske added inline comments.Aug 12 2020, 9:14 AM
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
2086

Should be ConstStructTimespecPtrTy.

2138

Is it possible to check for the size of the passed buffer? The man page says that buf should have room for 26 bytes (for ctime_r too).

martong updated this revision to Diff 285289.Aug 13 2020, 2:15 AM
martong marked 2 inline comments as done.
  • Handle minimum buffer sizes
  • Fix copy paste error
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
2086

Thanks!

2138

Yes, absolutely, this is a very good observation. I extended the BufferSize constraint to handle concrete values as well.

balazske accepted this revision.Aug 13 2020, 2:48 AM

Nice!

This revision is now accepted and ready to land.Aug 13 2020, 2:48 AM
Szelethus accepted this revision.Aug 13 2020, 5:59 AM
Szelethus added reviewers: NoQ, vsavchenko.

Lets make sure we invite the wider community to see whats going on. Otherwise, LGTM!

It seems like this patch adds two new additions at once -- infrastructure for when the arg constraint size is concrete with an appropriate test, and another round of adding mass function modeling. While this isn't the largest amount of new functions you're adding, it would still be nice that such changes were void of any other functional changes, imo. However, I don't think its worth splitting up at this point.

@NoQ, @vsavchenko My apologies, somehow I forgot to add you as reviewers.

martong updated this revision to Diff 289982.Sep 4 2020, 9:26 AM
  • Rebase to master, ie using optionals everywhere

Lets make sure we invite the wider community to see whats going on. Otherwise, LGTM!

I am committing this because it already has two accepts, plus I am very confident with the changes.
@NoQ @vsavchenko Let me know if you find anything, I am happy to fix post-commit or we can even revert.

This revision was landed with ongoing or failed builds.Sep 4 2020, 9:45 AM
This revision was automatically updated to reflect the committed changes.