[ObjC] Allow declaring __strong pointer fields in structs in Objective-C
authorAkira Hatanaka <ahatanaka@apple.com>
Wed, 28 Feb 2018 07:15:55 +0000 (07:15 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Wed, 28 Feb 2018 07:15:55 +0000 (07:15 +0000)
commit7275da0f2ee24336fe83cb7cfe2ba22f9cefc117
tree9faf6e67f81d54afcaa45b6300b4c150070a2eb3
parentac799b05d42fee69a91bf35beb7f87c548827a42
[ObjC] Allow declaring __strong pointer fields in structs in Objective-C
ARC mode.

Declaring __strong pointer fields in structs was not allowed in
Objective-C ARC until now because that would make the struct non-trivial
to default-initialize, copy/move, and destroy, which is not something C
was designed to do. This patch lifts that restriction.

Special functions for non-trivial C structs are synthesized that are
needed to default-initialize, copy/move, and destroy the structs and
manage the ownership of the objects the __strong pointer fields point
to. Non-trivial structs passed to functions are destructed in the callee
function.

rdar://problem/33599681

Differential Revision: https://reviews.llvm.org/D41228

llvm-svn: 326307
27 files changed:
clang/docs/LanguageExtensions.rst
clang/include/clang/AST/Decl.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/Type.cpp
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGNonTrivialStruct.cpp [new file with mode: 0644]
clang/lib/CodeGen/CMakeLists.txt
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Sema/JumpDiagnostics.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/ARCMT/checking.m
clang/test/CodeGenObjC/nontrivial-c-struct-exception.m [new file with mode: 0644]
clang/test/CodeGenObjC/nontrivial-c-struct-func-name-collision.m [new file with mode: 0644]
clang/test/CodeGenObjC/strong-in-c-struct.m [new file with mode: 0644]
clang/test/Lexer/has_feature_objc_arc.m
clang/test/SemaObjC/arc-decls.m
clang/test/SemaObjC/arc-system-header.m
clang/test/SemaObjC/strong-in-c-struct.m [new file with mode: 0644]