[PATCH] D113622: [wip] [analyzer] support ignoring use-after-free checking with reference_counted attribute

Chris D'Angelo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 14 13:22:17 PST 2021


chrisdangelo added a comment.

Hi @aaron.ballman,

It's nice to meet you, virtually.

I've been working with @NoQ on this change. I've now removed the [wip] prefix. When you have some time, I'd appreciate your feedback.

This change adds a new attribute "reference_counted". This attribute is intended to annotate struct declarations that are known to use a reference counting pattern before being freed.

The long term intention is that "reference_counted" may grow additional affordances for describing the expected retain and release conventions that can be wired up to train the static analyzer RetainCountChecker.

The short term intention, executed in these changes, is that "reference_counted" will be used to silence static analyzer use-after-free and double-free checks that are indicating false positives when the pointer is being monitored by a reference counting system.

This change does not currently enable warnings when the "reference_counted" attribute is written before the "struct" keyword. There may be other cases where the programmer may incorrectly use "reference_counted".

I've successfully run the tests locally via `ninja check-clang-analysis` and `ninja check-clang`.

I've successfully exercised these changes against a large C / C++ project and studied the output with @NoQ.

These changes are expected to be used in conjunction with additional work with ownership compiler attributes (https://reviews.llvm.org/D113530).

Thank you,
Chris


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

https://reviews.llvm.org/D113622



More information about the cfe-commits mailing list