[cfe-commits] r93246 - in /cfe/trunk: lib/Basic/Targets.cpp test/Rewriter/rewrite-weak-attr.m
Fariborz Jahanian
fjahanian at apple.com
Tue Jan 12 10:33:58 PST 2010
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.
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;
+ };
+}
More information about the cfe-commits
mailing list