This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] MacOSXAPIChecker: Improve warning messages for __block vars in dispatch_once().
ClosedPublic

Authored by NoQ on Oct 31 2016, 11:51 AM.

Details

Summary

The checker already warns for __block-storage variables being used as a dispatch_once() predicate, however it refers to them as local which is not quite accurate, so we fix that.

Also add tests to make sure it works.

FIXME: The analyzer sets stack memory space for __block variables when they are referenced outside the block (eg. test_block_var_from_outside_block() line 108). Will try to fix in a separate patch; i'm not relying on the memory space in this patch.

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ updated this revision to Diff 76453.Oct 31 2016, 11:51 AM
NoQ retitled this revision from to [analyzer] MacOSXAPIChecker: Improve warning messages for __block vars in dispatch_once()..
NoQ updated this object.
NoQ added reviewers: zaks.anna, dcoughlin.
NoQ added a subscriber: cfe-commits.
dcoughlin accepted this revision.Oct 31 2016, 1:26 PM
dcoughlin edited edge metadata.

LGTM.

We should probably be warning any time the address of a block variable is taken since the address is not stable -- but that's a job for a different checker or possibly even Sema.

This revision is now accepted and ready to land.Oct 31 2016, 1:26 PM
NoQ added a comment.Oct 31 2016, 1:47 PM

FIXME: The analyzer sets stack memory space for __block variables when they are referenced outside the block (eg. test_block_var_from_outside_block() line 108). Will try to fix in a separate patch; i'm not relying on the memory space in this patch.

That's actually correct, never mind.

This revision was automatically updated to reflect the committed changes.