[clang] [clang][analyzer] fix crash when modelling 'getline' function in checkers (PR #145229)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 23 04:35:34 PDT 2025


NagyDonat wrote:

Personally I feel that option 2 ("add more error handling to avoid crashes in `checkGetdelim`") would be more "natural" for the static analyzer, because checking the exact types of the parameters is rare in the analyzer (I don't know any significant example apart from `StdLibraryFunctionsChecker`). Not checking the exact types is also useful because this makes the analyzer more robust against slight differences between different standard library implementations (e.g. MSVC headers are notorious for minor awkward differences).

Your concern that "However, we will still try to model "incorrect" `getline` methods, wasting cpu." is _very_ premature optimization, the runtime change would be totally negligible -- and probably less than the (also negligible) cost of detailed type checking. The majority of the analyzer runtime is focused in a few hot spots, while the majority of the logic is mostly irrelevant from a performance POV.


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


More information about the cfe-commits mailing list