[PATCH] D92771: [analyzer][StdLibraryFunctionsChecker] Add more return value contraints
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 8 08:03:07 PST 2020
martong marked 3 inline comments as done.
martong added a comment.
Thanks for the review!
================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1367-1368
+ .Case(ReturnsZeroOrMinusOne)
.ArgConstraint(ArgumentCondition(
0, WithinRange, Range(0, IntMax))));
----------------
steakhal wrote:
> I think you should hoist this ArgumentCondition construction with a lambda call. It would lead to more readable summaries.
>
> ```lang=c++
> const auto ValidFileDescriptorArgAt = [](unsigned ArgIdx) {
> return ArgumentCondition(ArgIdx, WithinRange, Range(0, IntMax))));
> };
> ```
> Probably the very same principle would apply for handling `off_t` arguments.
>
> You can probably find a better name, but you get the idea.
> If you agree on this, you could create a follow-up patch.
Good idea, thanks! I am going to create another patch for this (and another for exec* functions).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92771/new/
https://reviews.llvm.org/D92771
More information about the cfe-commits
mailing list