[clang] [clang][analyzer] Add support for detecting uninitialized dynamically-allocated objects (PR #193001)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 21 05:14:26 PDT 2026


https://github.com/NagyDonat approved this pull request.

The code change LGTM.

As the difference between static / dynamic allocation seems to be orthogonal to the other features of this checker, I find it excessive that you duplicate so many (every?) test with a dynamic allocation variant.

In general, if a software has N _clearly_ orthogonal features, then they should be covered by N independent tests instead of 2^N tests that cover every combination. Testing combinations should be reserved for the cases where (1) there is interference between them or (2) the reader would suspect that there is interference between them.

I can accept the patch as it is if this verbosity is important for you, but I would prefer reverting some of the changes in the tests because the duplication (e.g. repeated `expected-warning` markers) is annoying for the readers of these test files.

Alternatively, you could introduce something like
```c++
#ifdef DYNAMIC
#define INIT(CLS, ARGS) CLS Obj ARGS;
#else
#define INIT(CLS, ARGS) new CLS ARGS;
#endif
```
and have two run lines, one with `-DDYNAMIC` and one without it. This way the test would clearly encode that you expect the same behavior with static and dynamic initialization (unlike with the current setup, where the reader would need to pedantically read each duplicated `expected-warning` to conclude this).

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


More information about the cfe-commits mailing list