[PATCH] D27535: [analyzer] Add ObjCPropertyChecker - check for autosynthesized copy-properties of mutable types.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 8 06:23:24 PST 2016


NoQ added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp:68
+    return;
+
+  BR.EmitBasicReport(
----------------
dcoughlin wrote:
> You'll also want to make sure to not warn on the following idiom, in which programmers use @synthesize to generate the storage but still provide their own accessors:
> 
> ```
> @interface Foo
> @property(copy) NSMutableString *foo;
> @end
> 
> @implementation Foo
> @synthesize foo;
> -(NSMutableString *)foo {
>   return foo;
> }
> - (void)setFoo:(NSMutableString *)newValue {
>   foo = [newValue mutableCopy];
> }
> @end
> ```
> I *think* a call to `ObjCContainerDecl::HasUserDeclaredSetterMethod()` should be sufficient to detect and early exit in this case.
> ObjCContainerDecl::HasUserDeclaredSetterMethod()

Didn't notice this one, that's much easier!


https://reviews.llvm.org/D27535





More information about the cfe-commits mailing list