[PATCH] D78099: [analyzer][RetainCount] Tie diagnostics to osx.cocoa.RetainCount rather then RetainCountBase, for the most part

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 15 08:12:00 PDT 2020


Szelethus marked an inline comment as done.
Szelethus added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp:1500
+                                            RefCountBug::KIND);
+  // TODO: Ideally, we should have a checker for each of these bug types.
+  INIT_BUGTYPE(UseAfterRelease)
----------------
martong wrote:
> So, this is an intermediate patch before we reach that? That is the reason why we must use unique_ptrs and lazily init them?
I lack the knowledge required to do that myself, unfortunately, and I'm no client of this checker, I'm not even sure what I would want to see it do.

We need unique pointers because `BugType` has no default constructor, and we receive the checker name //after// adding the checker object to `CheckerManager` (this happens in `registerRetainCountBase`). Other checkers use unique pointers for this type as well.

The lazy init, as opposed to simple initializing happens so that the checker name associated with the bug report doesn't depend on the registration order of `RetainCount` and `OSObjectRetainCount` (I guess I could've explained this in the code as well, huh). Right now, it only depends on which checker is enabled, which is bad enough, but addressing this TODO will fix that in an instant.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78099/new/

https://reviews.llvm.org/D78099





More information about the cfe-commits mailing list