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

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 23 13:57:07 PDT 2025


vbvictor wrote:

> would it be easier to use this Signature class for implementing the matching code instead of hand-rolling out something custom?

It's "easier" to some extent, I think it's more readable and maintainable with full dedicated signature matching. I created a small PR in my LLVM fork to demonstrate how it can look like https://github.com/vbvictor/llvm-project/pull/1.

I updated this PR and implemented option 2. It has more gentle error handling, just avoid crushes. But it still accept all functions that "look like" `getline`. Note how there are false-positives with absurd functions, like in `TEST_GETLINE_2`.

I think it's still helpful to have strict function signature matching. Even in option 2 I needed to explicitly check types to avoid crush, so having a dedicated instrument would make it better.

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


More information about the cfe-commits mailing list