diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2018-03-19 17:38:40 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2018-03-19 17:38:40 +0000 |
commit | d791e92b5fbd24eef539d5de738c41b835246539 (patch) | |
tree | 880a6ae213922227398cd812298e69e4290c4ca2 /clang/lib/Sema/SemaDecl.cpp | |
parent | 259eaa6e7cd021c75e36da2ea677103a6847eb38 (diff) | |
download | bcm5719-llvm-d791e92b5fbd24eef539d5de738c41b835246539.tar.gz bcm5719-llvm-d791e92b5fbd24eef539d5de738c41b835246539.zip |
[ObjC] Allow declaring __weak pointer fields in C structs in ARC.
This patch uses the infrastructure added in r326307 for enabling
non-trivial fields to be declared in C structs to allow __weak fields in
C structs in ARC.
This recommits r327206, which was reverted because it caused
module-enabled builders to fail. I discovered that the
CXXRecordDecl::CanPassInRegisters flag wasn't being set correctly in
some cases after I moved it to RecordDecl.
Thanks to Eric Liu for helping me investigate the bug.
rdar://problem/33599681
https://reviews.llvm.org/D44095
llvm-svn: 327870
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index ea971353039..6319e4b34ce 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -15266,7 +15266,6 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl, // Get the type for the field. const Type *FDTy = FD->getType().getTypePtr(); - Qualifiers QS = FD->getType().getQualifiers(); if (!FD->isAnonymousStructOrUnion()) { // Remember all fields written by the user. @@ -15407,10 +15406,7 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl, QualType T = Context.getObjCObjectPointerType(FD->getType()); FD->setType(T); } else if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() && - Record && !ObjCFieldLifetimeErrReported && - ((!getLangOpts().CPlusPlus && - QS.getObjCLifetime() == Qualifiers::OCL_Weak) || - Record->isUnion())) { + Record && !ObjCFieldLifetimeErrReported && Record->isUnion()) { // It's an error in ARC or Weak if a field has lifetime. // We don't want to report this in a system header, though, // so we just make the field unavailable. @@ -15456,6 +15452,8 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl, Record->setNonTrivialToPrimitiveCopy(true); if (FT.isDestructedType()) Record->setNonTrivialToPrimitiveDestroy(true); + if (!FT.canPassInRegisters()) + Record->setCanPassInRegisters(false); } if (Record && FD->getType().isVolatileQualified()) |