[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 19 03:03:57 PDT 2024


balazske wrote:

> So, it seems removing them from `StdLibraryFunctionsChecker` is not out of the question. We can leave them together with other stream functions, or we could move them to `UnixAPIChecker`, which we have enabled downstream.
> 
> I think the latter is a reasonable compromise so `StreamChecker` scope is the stream itself, and not everything surrounding the `FILE*` APIs.

I like more if the new checks are moved to `UnixAPIChecker`, or into `StdLibraryFunctionsChecker`. The mentioned FIXME comment is about that these functions should be moved into the `ModelPOSIX` part in `StdLibraryFunctionsChecker`. 

Probably it would be better if `StdLibraryFunctionsChecker` would be an API (instead of checker) and in this way any checker can use it for the specific functions. But with the current solution the checks in `StdLibraryFunctionsChecker` can be changed for specific needs. (For example if a buffer size check is needed in a checker like `StreamChecker` it could use a simple API to do this. With the current implementation it can not use an API, but we can add the check into `StdLibraryFunctionsChecker` instead.) The checks like sufficient buffer size or NULL pointer arguments are common to many checkers and implementing these separately is code repetition and makes checker code more difficult.

https://github.com/llvm/llvm-project/pull/83027


More information about the cfe-commits mailing list