[clang] [analyzer] Avoid unnecessary super region invalidation in `CStringChecker` (PR #146212)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 30 08:11:46 PDT 2025


flovent wrote:

> Thanks for the detailed PR summary. It makes sense. I had to think about it carefully but I agree with the motivation. When I looked at the code it looked really complicated. Probably more than I expected it to be.

`CStringChecker` is a very complicated checker indeed, it may took me more time to decide how to change this file than finding the cause of this problem, finally i added this parameter with default value to reduce the modifications required because `invalidateDestinationBufferBySize` is used in model to other functions like `memset`, `memcpy` too.

> I think adding another bool parameter to the already crowded function is not ideal. We should look for some other way, maybe a different overload, or restructuring the code in other ways.

I just find out there are three member functions whose name start with `invalidateDestinationBuffer`, seems `invalidateDestinationBufferNeverOverflows` should be the right call when `CouldAccessOutOfBound == false`.

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


More information about the cfe-commits mailing list