[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 27 02:53:52 PDT 2016


NoQ added inline comments.


================
Comment at: test/Analysis/dispatch-once.m:62
+- (void)test_ivar_struct_from_inside {
+  dispatch_once(&s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 's' for the predicate value.}}
+}
----------------
dcoughlin wrote:
> Interesting. Have you seen this pattern in the wild?
> 
> I think this diagnostic is a little bit confusing since the ivar itself isn't being used for the predicate value.
> 
> Maybe "... uses a subfield of the instance variable 's' for the predicate value"? 
> 
> 
> 
> 
Not yet, so this is more of a "because we can" test. That said, i'm not sure about the warning message: it might also be an array element, not necessarily a field, and not necessarily a direct subfield or direct element.

Added array tests and an attempt on a safe warning message.


https://reviews.llvm.org/D25909





More information about the cfe-commits mailing list