@martong I kept your idea in mind for this warning message and implemented it as a new checker if you don't mind it.
If the size of an array is Undefined when it's allocated, this patch emits a warning, and ends the analysis.
Differential D131299
[analyzer] Warn if the size of the array in `new[]` is undefined isuckatcs on Aug 5 2022, 2:46 PM. Authored by
Details @martong I kept your idea in mind for this warning message and implemented it as a new checker if you don't mind it. If the size of an array is Undefined when it's allocated, this patch emits a warning, and ends the analysis.
Diff Detail
Event TimelineComment Actions Oh thanks a lot for handling this case!
Comment Actions I am not sure whether we actually use exclamation marks in diagnostic texts. Otherwise this looks good to me. Maybe adding expected-note's to the test would be nice, but overall this looks good to me. Comment Actions Great! I think this checker can be turned on by default pretty quickly. We should run it over some code but other than that it seems to be in good shape from the start. I agree with Gabor, we don't usually have exclamation marks in warnings. It could definitely be exciting to have exclamation marks! But I'm worried that since clang is part of multiple finished GUI products, various UI/UX review boards won't be happy with us for that :( So we limit exclamation marks to assertion failures. Side note, clang warning style and grammar doesn't seem to be documented anywhere. Side note, static analyzer warning style and grammar is completely different from clang warning style and grammar (we expect our warnings to be complete sentences).
Comment Actions
Thank you for taking care of this!
Comment Actions Updated
Comment Actions Ok I have some warning text bikeshedding but generally the patch looks great and the checker should probably be enabled by default from the start, or otherwise very soon.
Comment Actions Addressed comments
Comment Actions Looks great!
Comment Actions Added a documentation into checkers.rst.
Comment Actions Fixed the broken test file. Clang-format put a line break between {{ and }} and that caused the failure. Comment Actions This comment has been deleted.
Comment Actions Looks great. I agree that it can go straight to core because our undefined value checkers are roughly all the same and we're already pretty good at writing them. The checker appears to be very quiet in my experience, I'm yet to see a warning in the wild, but I think the path note tests give enough signal that warnings are going to look good. I have one tiny nitpick that should be addressed before committing.
|
Maybe alpha.core.uninitialized then, with the intent to eventually put it into core.uninitialized?