]> granicus.if.org Git - clang/commit
[ObjC++] Make parameter passing and function return compatible with ObjC
authorAkira Hatanaka <ahatanaka@apple.com>
Wed, 28 Mar 2018 21:13:14 +0000 (21:13 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Wed, 28 Mar 2018 21:13:14 +0000 (21:13 +0000)
commitc4bfd75d786a2a77c779cee6976534f37202ac21
tree7d3c598ba8143ab5196aed15a7573593c53dabe5
parent1ec33d54dfc07388c7bc7d637723ceeaa74869ee
[ObjC++] Make parameter passing and function return compatible with ObjC

ObjC and ObjC++ pass non-trivial structs in a way that is incompatible
with each other. For example:

typedef struct {
  id f0;
  __weak id f1;
} S;

// this code is compiled in c++.
extern "C" {
  void foo(S s);
}

void caller() {
  // the caller passes the parameter indirectly and destructs it.
  foo(S());
}

// this function is compiled in c.
// 'a' is passed directly and is destructed in the callee.
void foo(S a) {
}

This patch fixes the incompatibility by passing and returning structs
with __strong or weak fields using the C ABI in C++ mode. __strong and
__weak fields in a struct do not cause the struct to be destructed in
the caller and __strong fields do not cause the struct to be passed
indirectly.

Also, this patch fixes the microsoft ABI bug mentioned here:

https://reviews.llvm.org/D41039?id=128767#inline-364710

rdar://problem/38887866

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328731 91177308-0d34-0410-b5e6-96231b3b80d8
27 files changed:
include/clang/AST/Decl.h
include/clang/AST/DeclCXX.h
include/clang/AST/Type.h
include/clang/Basic/LangOptions.def
include/clang/Basic/LangOptions.h
include/clang/Basic/TargetInfo.h
include/clang/Frontend/CodeGenOptions.def
lib/AST/ASTContext.cpp
lib/AST/Decl.cpp
lib/AST/DeclCXX.cpp
lib/AST/Type.cpp
lib/Basic/TargetInfo.cpp
lib/Basic/Targets/X86.h
lib/CodeGen/CGCall.cpp
lib/CodeGen/ItaniumCXXABI.cpp
lib/CodeGen/MicrosoftCXXABI.cpp
lib/CodeGen/TargetInfo.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriter.cpp
lib/Serialization/ASTWriterDecl.cpp
test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
test/CodeGenObjCXX/arc-special-member-functions.mm
test/CodeGenObjCXX/objc-struct-cxx-abi.mm [moved from test/CodeGenObjCXX/trivial_abi.mm with 73% similarity]
test/CodeGenObjCXX/property-dot-copy-elision.mm