]> granicus.if.org Git - clang/commit
[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)
commitf4ab7b42ebfeff74222e4fe541a878f0f6a83d48
treee5da93d0bfac3f17fdad0afadb785e2c3dc83263
parent6ba4f924d92bc11dc5c9c79892a16a769dbfb7ab
[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

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