[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 08:23:38 PDT 2024
================
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=nullability \
+// RUN: -analyzer-output=text -verify %s
+//
+// expected-no-diagnostics
+//
+// This case previously crashed because of an assert in CheckerManager.cpp,
+// checking for registered event dispatchers. This check is too strict so
+// was removed by this commit. This test case covers the previous crash,
+// and is expected to simply not crash. The source file can be anything,
+// and does not need to be empty.
----------------
NagyDonat wrote:
```suggestion
// Previously there was an assertion requiring that if an Event is handled by
// some enabled checker, then there must be at least one enabled checker which
// can emit that kind of Event.
// This assertion failed when NullabilityChecker (which is a subclass of
// check::Event<ImplicitNullDerefEvent>) was enabled, but the checkers
// inheriting from EventDispatcher<ImplicitNullDerefEvent> were all disabled.
// This test file validates that enabling the nullability checkers (without any
// other checkers) no longer causes a crash.
```
I rewrote this explanation to make it (hopefully) more useful for someone who encounters this test file without any context.
https://github.com/llvm/llvm-project/pull/107294
More information about the cfe-commits
mailing list