[cfe-commits] r170763 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/SemaObjC/arc.m

John McCall rjmccall at apple.com
Thu Dec 20 13:11:16 PST 2012


On Dec 20, 2012, at 12:55 PM, Ted Kremenek <kremenek at apple.com> wrote:

> Author: kremenek
> Date: Thu Dec 20 14:55:03 2012
> New Revision: 170763
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=170763&view=rev
> Log:
> Warn if a __weak variable is initialized with an Objective-C object literal.
> 
> Such variables may immediately become nil or may have unpredictable
> behavior.
> 
> Fixes <rdar://problem/12569201>.
> 
> Modified:
>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>    cfe/trunk/lib/Sema/SemaDecl.cpp
>    cfe/trunk/test/SemaObjC/arc.m
> 
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=170763&r1=170762&r2=170763&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Dec 20 14:55:03 2012
> @@ -1788,6 +1788,10 @@
>   "__weak attribute cannot be specified on an automatic variable when ARC "
>   "is not enabled">,
>   InGroup<IgnoredAttributes>;
> +def warn_attribute_weak_objc_literal : Warning<
> +  "__weak variable initialized with an object literal may "
> +  "immediately become nil">,
> +  InGroup<DiagGroup<"objc-weak-assigned-literal">>;

This is probably worth tweaking to say "block literal" instead of
"object literal" in the appropriate case.

John.



More information about the cfe-commits mailing list