[cfe-commits] r93246 - in /cfe/trunk: lib/Basic/Targets.cpp test/Rewriter/rewrite-weak-attr.m

Daniel Dunbar daniel at zuster.org
Tue Jan 12 11:44:01 PST 2010


Hi Fariborz,

On Tue, Jan 12, 2010 at 10:33 AM, Fariborz Jahanian <fjahanian at apple.com> wrote:
> Author: fjahanian
> Date: Tue Jan 12 12:33:57 2010
> New Revision: 93246
>
> URL: http://llvm.org/viewvc/llvm-project?rev=93246&view=rev
> Log:
> Define __weak attribute for objective-c pointers in
> win32 targets. Fixes radar 7530235. Daniel please review.

This isn't the right fix, this defines __weak for all win32 targets
which isn't valid. Similarly, it doesn't fix the bug on other
platforms, like linux.

What we want is that the rewriter action specifically enables blocks
supports for *all* targets, since the rewriter is capable of rewriting
away the blocks. We may need to shuffle some of the code in
driver/cc1_main.cpp to make this easier, but the idea should be to
give specific FrontendAction objects the opportunity to override
values in the CompilerInvocation.

 - Daniel

> Added:
>    cfe/trunk/test/Rewriter/rewrite-weak-attr.m
> Modified:
>    cfe/trunk/lib/Basic/Targets.cpp
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=93246&r1=93245&r2=93246&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Tue Jan 12 12:33:57 2010
> @@ -994,6 +994,10 @@
>     DefineStd(Builder, "WIN32", Opts);
>     DefineStd(Builder, "WINNT", Opts);
>     Builder.defineMacro("_X86_");
> +    if (Opts.ObjC1)
> +      // __weak is always defined, for use in blocks and with objc pointers,
> +      // even for i686-pc-win32 targets.
> +      Builder.defineMacro("__weak", "__attribute__((objc_gc(weak)))");
>   }
>  };
>  } // end anonymous namespace
>
> Added: cfe/trunk/test/Rewriter/rewrite-weak-attr.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-weak-attr.m?rev=93246&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Rewriter/rewrite-weak-attr.m (added)
> +++ cfe/trunk/test/Rewriter/rewrite-weak-attr.m Tue Jan 12 12:33:57 2010
> @@ -0,0 +1,13 @@
> +// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -fblocks -Dnil=0 -rewrite-objc  -o - %s
> +int main() {
> +        __weak __block id foo = nil;
> +        __block id foo2 = nil;
> +        id foo3 = nil;
> +
> +        void (^myblock)() = ^{
> +                foo = nil;
> +                foo2 = nil;
> +                [foo3 bar];
> +                id foo4 = foo3;
> +        };
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list