Define weak and __weak to mean ARC-style weak references, even in MRC.
authorJohn McCall <rjmccall@apple.com>
Thu, 22 Oct 2015 18:38:17 +0000 (18:38 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 22 Oct 2015 18:38:17 +0000 (18:38 +0000)
commit460ce58fa6a165ebad98c848aaec2f09cefe7603
tree9520b5118e8d8cc7cbe1449609c40f3b9ec7b11b
parent63d23d1b127e43cff2b287b371fdbf6e0a6d83f0
Define weak and __weak to mean ARC-style weak references, even in MRC.

Previously, __weak was silently accepted and ignored in MRC mode.
That makes this a potentially source-breaking change that we have to
roll out cautiously.  Accordingly, for the time being, actual support
for __weak references in MRC is experimental, and the compiler will
reject attempts to actually form such references.  The intent is to
eventually enable the feature by default in all non-GC modes.
(It is, of course, incompatible with ObjC GC's interpretation of
__weak.)

If you like, you can enable this feature with
  -Xclang -fobjc-weak
but like any -Xclang option, this option may be removed at any point,
e.g. if/when it is eventually enabled by default.

This patch also enables the use of the ARC __unsafe_unretained qualifier
in MRC.  Unlike __weak, this is being enabled immediately.  Since
variables are essentially __unsafe_unretained by default in MRC,
the only practical uses are (1) communication and (2) changing the
default behavior of by-value block capture.

As an implementation matter, this means that the ObjC ownership
qualifiers may appear in any ObjC language mode, and so this patch
removes a number of checks for getLangOpts().ObjCAutoRefCount
that were guarding the processing of these qualifiers.  I don't
expect this to be a significant drain on performance; it may even
be faster to just check for these qualifiers directly on a type
(since it's probably in a register anyway) than to do N dependent
loads to grab the LangOptions.

rdar://9674298

llvm-svn: 251041
35 files changed:
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/ARCMigrate/ARCMT.cpp
clang/lib/ARCMigrate/Transforms.cpp
clang/lib/AST/ASTContext.cpp
clang/lib/Basic/Targets.cpp
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprCXX.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/Driver/Tools.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaObjCProperty.cpp
clang/lib/Sema/SemaType.cpp
clang/test/ARCMT/GC-no-arc-runtime.m
clang/test/CodeGenObjC/blocks.m
clang/test/CodeGenObjC/mrc-weak.m [new file with mode: 0644]
clang/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m
clang/test/Index/complete-property-flags.m
clang/test/SemaObjC/attr-objc-gc.m
clang/test/SemaObjC/mrc-weak.m [new file with mode: 0644]
clang/test/SemaObjC/no-gc-weak-test.m
clang/test/SemaObjC/nonarc-weak.m [deleted file]
clang/test/SemaObjC/property-in-class-extension-1.m
clang/test/SemaObjC/synthesized-ivar.m