]> granicus.if.org Git - clang/commitdiff
Do not add "byval" attribute to records with non-trivial copy constructors
authorJan Wen Voung <jvoung@google.com>
Thu, 3 Nov 2011 00:59:44 +0000 (00:59 +0000)
committerJan Wen Voung <jvoung@google.com>
Thu, 3 Nov 2011 00:59:44 +0000 (00:59 +0000)
and destructors in the DefaultABIInfo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143601 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetInfo.cpp

index 2bd341ce2187e2b13e3dad4333f87f8af6bacdb0..2c93249e3b6ac7905e8f2b9a9cd1d3425b74d2fd 100644 (file)
@@ -339,8 +339,14 @@ llvm::Value *DefaultABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
 }
 
 ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const {
-  if (isAggregateTypeForABI(Ty))
+  if (isAggregateTypeForABI(Ty)) {
+    // Records with non trivial destructors/constructors should not be passed
+    // by value.
+    if (isRecordWithNonTrivialDestructorOrCopyConstructor(Ty))
+      return ABIArgInfo::getIndirect(0, /*ByVal=*/false);
+
     return ABIArgInfo::getIndirect(0);
+  }
 
   // Treat an enum type as its underlying type.
   if (const EnumType *EnumTy = Ty->getAs<EnumType>())