[PATCH] D79430: [analyzer] StdLibraryFunctionsChecker: Add LazyRanges to support type dependent Max

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 5 10:14:17 PDT 2020


martong created this revision.
martong added reviewers: Szelethus, NoQ, baloghadamsoftware, balazske, steakhal.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
Herald added a project: clang.
martong added parent revisions: D79423: [analyzer][NFC] StdLibraryFunctionsChecker: Add empty Signatures, D79425: [analyzer] StdLibraryFunctionsChecker: Add overload for adding the same summary for different names.

Some functions uses a platform dependent `ssize_t` (e.g. `read`). Currently, we
provide different summaries for the possible variants depending on the
canonical type of `ssize_t` (int, long, long long). In this patch we get rid of
this burden, thus making the administration of summaries easier. The newly
introduced `LazyRangeInt` is a union of a `RangeInt` and a function pointer. We
get the ranges lazily. By the time we need the ranges we already have a
concrete FunctionDecl set for the summary. When a function pointer is used
amongst the range values then we evaluate the function. This way we can get a
type dependent Max value and instead of providing 3 summaries to `read` we can
provide only one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79430

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79430.262148.patch
Type: text/x-patch
Size: 11809 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200505/38db74a9/attachment-0001.bin>


More information about the cfe-commits mailing list