]> granicus.if.org Git - clang/commitdiff
Fix the 32-bit ABI to return structures with non-trivial copy ctors or dtors indirectly.
authorAnders Carlsson <andersca@mac.com>
Tue, 20 Oct 2009 22:07:59 +0000 (22:07 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 20 Oct 2009 22:07:59 +0000 (22:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84686 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetABIInfo.cpp
test/CodeGenCXX/references.cpp

index ea1426277d19989fa9f47f7c5d20296b35a08e16..ad5dbd227630e71d40789772d13d63ca2aee4de6 100644 (file)
@@ -353,11 +353,17 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy,
 
     return ABIArgInfo::getDirect();
   } else if (CodeGenFunction::hasAggregateLLVMType(RetTy)) {
-    // Structures with flexible arrays are always indirect.
-    if (const RecordType *RT = RetTy->getAsStructureType())
+    if (const RecordType *RT = RetTy->getAsStructureType()) {
+      // Structures with either a non-trivial destructor or a non-trivial
+      // copy constructor are always indirect.
+      if (hasNonTrivialDestructorOrCopyConstructor(RT))
+        return ABIArgInfo::getIndirect(0, /*ByVal=*/false);
+      
+      // Structures with flexible arrays are always indirect.
       if (RT->getDecl()->hasFlexibleArrayMember())
         return ABIArgInfo::getIndirect(0);
-
+    }
+    
     // If specified, structs and unions are always indirect.
     if (!IsSmallStructInRegABI && !RetTy->isAnyComplexType())
       return ABIArgInfo::getIndirect(0);
index 7028ef338b5943409dec24832a05857b013bc790..8e0e1cbe84e831cec107e7181468a38167512c21 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: clang-cc -triple x86_64-apple-darwin -verify -emit-llvm -o - %s | FileCheck %s
+// RUN: clang-cc -verify -emit-llvm -o - %s | FileCheck %s
 
 void t1() {
   extern int& a;