summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ASTContext.cpp7
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp5
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp3
3 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 6823fa08d3d..12a92f8ac6f 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3282,6 +3282,13 @@ bool ASTContext::BlockRequiresCopying(QualType Ty) {
return true;
if (Ty->isObjCObjectPointerType())
return true;
+ if (getLangOptions().CPlusPlus) {
+ if (const RecordType *RT = Ty->getAs<RecordType>()) {
+ CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
+ return RD->hasConstCopyConstructor(*this);
+
+ }
+ }
return false;
}
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index e21664607cf..c40cfaf6a97 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1016,9 +1016,8 @@ GenerateCopyHelperFunction(const llvm::StructType *T,
Srcv = Builder.CreateBitCast(Srcv, PtrStructTy);
Srcv = Builder.CreateStructGEP(Srcv, CGF.getByRefValueLLVMField(VD),
VD->getNameAsString());
- Dstv = Builder.CreateStructGEP(DstObj, index);
- Dstv = Builder.CreateLoad(Dstv);
- Dstv = Builder.CreateBitCast(Dstv, PtrStructTy);
+
+ Dstv = Builder.CreateBitCast(DstObj, PtrStructTy);
Dstv = Builder.CreateStructGEP(Dstv, CGF.getByRefValueLLVMField(VD),
VD->getNameAsString());
CGF.EmitSynthesizedCXXCopyCtor(Dstv, Srcv,
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index cb0b09da5c6..7ccd80d0e8f 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -659,7 +659,8 @@ void CodeGenFunction::EmitAutoVarDecl(const VarDecl &D,
if (Ty->isBlockPointerType()) {
flag |= BLOCK_FIELD_IS_BLOCK;
flags |= BLOCK_HAS_COPY_DISPOSE;
- } else if (BlockRequiresCopying(Ty)) {
+ } else if (getContext().isObjCNSObjectType(Ty) ||
+ Ty->isObjCObjectPointerType()) {
flag |= BLOCK_FIELD_IS_OBJECT;
flags |= BLOCK_HAS_COPY_DISPOSE;
}
OpenPOWER on IntegriCloud