[clang] [analyzer] Prevent crash due to missing EventDispatch in corner case (PR #107294)
DonĂ¡t Nagy via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 5 04:36:00 PDT 2024
https://github.com/NagyDonat commented:
I investigated this situation and I found that this crash is not limited to empty source files -- I'd guess that the analyzer would crash on any input if it's executed as
```
// RUN: %clang_analyze_cc1 -w -analyzer-checker=nullability \
// RUN: -analyzer-output=text -verify %s
```
The real reason why this crash is rare is that two core checkers (`core.NullDereference` and `core.NonNullParamChecker`) are derived from `EventDispatcher<ImplicitNullDerefEvent>` so the assertion is not triggered in the "normal" case when the core checkers are enabled.
Note that the documentation of core checkers says that _"These checkers must be always switched on as other checker rely on them."_; however we should still eliminate this assertion failure because it's ugly.
Registering `NullabilityChecker` as an `EventDispatcher` (which happens to never dispatch any events) definitely works, but I think it would be more elegant to simply remove the assertion that caused the crash. Registering a handler for an event which cannot be emitted (under the current unusual config) is not an error, it should not trigger an assertion failure.
https://github.com/llvm/llvm-project/pull/107294
More information about the cfe-commits
mailing list