[PATCH] D92474: [analyzer][StdLibraryFunctionsChecker] Add return value constraint to functions with BufferSize

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 2 05:14:21 PST 2020


steakhal added a comment.

I've double-checked the return values of each touched summary.
Everything seems fine to me, besides the two I've highlighted.



================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1771
+            .Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+                   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
             .ArgConstraint(NotNull(ArgNo(0)))
----------------



================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1788
+            .Case({ReturnValueCondition(LessThanOrEq, ArgNo(3)),
+                   ReturnValueCondition(WithinRange, Range(-1, Ssize_tMax))})
             .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)))
----------------
Same here.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1860
         Summary(NoEvalCall)
+            .Case({ReturnValueCondition(WithinRange, Range(-1, IntMax))})
             .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)));
----------------
Aaa, I get it. We deal with this in a single transition. Fine.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:2076
         Summary(NoEvalCall)
+            .Case({ReturnValueCondition(WithinRange, Range(-1, 0))})
             .ArgConstraint(NotNull(ArgNo(3)))
----------------
BTW, this is quite frequently repeated.
Do you think worth hoisting such a return value constraint?

I'm thinking of something like `ReturnsZeroOrMinusOne`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92474



More information about the cfe-commits mailing list