This is an archive of the discontinued LLVM Phabricator instance.

[clang][analyzer] StdLibraryFunctionsChecker: Allow NULL buffer in `fread` and `fwrite` if size is zero.
ClosedPublic

Authored by balazske on Jul 5 2023, 6:55 AM.

Diff Detail

Event Timeline

balazske created this revision.Jul 5 2023, 6:55 AM
Herald added a reviewer: NoQ. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
balazske requested review of this revision.Jul 5 2023, 6:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2023, 6:55 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
donat.nagy accepted this revision.Jul 7 2023, 1:58 AM

LGTM.

clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
414–415

What would you think about a SmallVector<2> for these? It would allow you to handle them with a (short) for loop instead of separate commands.

This revision is now accepted and ready to land.Jul 7 2023, 1:58 AM
balazske marked an inline comment as done.Jul 19 2023, 12:22 AM
balazske added inline comments.
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
414–415

It does not look to be much better, the only place where a loop can be used is in the apply function but because optionals (that are to be checked at both values) it is not much better. And a vector could be constructed in the apply function too, but for 2 elements it is not important.

This revision was landed with ongoing or failed builds.Jul 19 2023, 12:58 AM
This revision was automatically updated to reflect the committed changes.
balazske marked an inline comment as done.