This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Path-insensitive checker for writes into an auto-releasing pointer from the wrong pool
ClosedPublic

Authored by george.karpenkov on Mar 20 2018, 6:54 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

george.karpenkov retitled this revision from [analyzer] Path-insensitive checker for writes into an auto-releasing pointer from the wrong queue to [analyzer] Path-insensitive checker for writes into an auto-releasing pointer from the wrong pool.
dcoughlin accepted this revision.Mar 29 2018, 10:59 AM

Looks good with updated diagnostic text and a test for non-ARC behavior.

lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
11 ↗(On Diff #139696)

I would say "warns about writes to autoreleasing out parameters that are likely to cause crashes".

16 ↗(On Diff #139696)

I would use the -enumerateObjectsUsingBlock: as the canonical example. The queue/threading aspect is incidental to the problem here.

102 ↗(On Diff #139696)

The queue aspect is incidental here. I suggest:

"write to autoreleasing out parameter inside autorelease pool that may exit before function returns; consider writing first to a strong local variable declared outside of the block"

and

"write to autoreleasing out parameter inside autorelease pool that may exit before method returns; consider writing first to a strong local variable declared outside of the block"

for the method case.

test/Analysis/autoreleasewritechecker_test.m
1 ↗(On Diff #139696)

Can you add a test that makes sure we don't warn on a write to an out parameter when ARC is disabled.

This revision is now accepted and ready to land.Mar 29 2018, 10:59 AM
george.karpenkov marked 4 inline comments as done.
This revision was automatically updated to reflect the committed changes.