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

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 19 00:22:36 PDT 2023


balazske marked an inline comment as done.
balazske added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:413-414
+    using ValueConstraint::ValueConstraint;
+    ArgNo SizeArg1N;
+    std::optional<ArgNo> SizeArg2N;
+    // This variable has a role when we negate the constraint.
----------------
donat.nagy wrote:
> 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.
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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154509/new/

https://reviews.llvm.org/D154509



More information about the cfe-commits mailing list