Darwin/x86-32: Enumerated types and block pointer types in structures were not

handled correctly.
 - <rdar://problem/7247671> Function arguments incorrect when function returns a
   struct on i386 w/ llvm-g++ and clang

llvm-svn: 82681
This commit is contained in:
Daniel Dunbar 2009-09-24 05:12:36 +00:00
parent 267e45adab
commit b3b1e53d33
2 changed files with 51 additions and 4 deletions

View File

@ -159,7 +159,9 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) {
}
static bool is32Or64BitBasicType(QualType Ty, ASTContext &Context) {
if (!Ty->getAs<BuiltinType>() && !Ty->isPointerType())
if (!Ty->getAs<BuiltinType>() && !Ty->isAnyPointerType() &&
!Ty->isAnyComplexType() && !Ty->isEnumeralType() &&
!Ty->isBlockPointerType())
return false;
uint64_t Size = Context.getTypeSize(Ty);
@ -291,8 +293,10 @@ bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty,
return true;
}
// If this is a builtin, pointer, or complex type, it is ok.
if (Ty->getAs<BuiltinType>() || Ty->isPointerType() || Ty->isAnyComplexType())
// If this is a builtin, pointer, enum, or complex type, it is ok.
if (Ty->getAs<BuiltinType>() || Ty->isAnyPointerType() ||
Ty->isAnyComplexType() || Ty->isEnumeralType() ||
Ty->isBlockPointerType())
return true;
// Arrays are treated like records.

View File

@ -1,4 +1,4 @@
// RUN: clang-cc -triple i386-apple-darwin9 -emit-llvm -o %t %s &&
// RUN: clang-cc -fblocks -triple i386-apple-darwin9 -emit-llvm -o %t %s &&
// RUN: grep 'define signext i8 @f0()' %t &&
// RUN: grep 'define signext i16 @f1()' %t &&
// RUN: grep 'define i32 @f2()' %t &&
@ -159,4 +159,47 @@ typedef int v39 __attribute((vector_size(16)));
struct s39 { v39 x; };
void f39(struct s39 x) {}
// <rdar://problem/7247671>
// RUN: grep 'define i32 @f40()' %t &&
enum e40 { ec0 = 0 };
enum e40 f40(void) { }
// RUN: grep 'define void ()\* @f41()' %t &&
typedef void (^vvbp)(void);
vvbp f41(void) { }
// RUN: grep 'define i32 @f42()' %t &&
struct s42 { enum e40 f0; } f42(void) { }
// RUN: grep 'define i64 @f43()' %t &&
struct s43 { enum e40 f0; int f1; } f43(void) { }
// RUN: grep 'define i32 @f44()' %t &&
struct s44 { vvbp f0; } f44(void) { }
// RUN: grep 'define i64 @f45()' %t &&
struct s45 { vvbp f0; int f1; } f45(void) { }
// RUN: grep 'define void @f46(i32 %a0)' %t &&
void f46(enum e40 a0) { }
// RUN: grep 'define void @f47(void ()\* %a1)' %t &&
void f47(vvbp a1) { }
// RUN: grep 'define void @f48(i32 %a0.0)' %t &&
struct s48 { enum e40 f0; };
void f48(struct s48 a0) { }
// RUN: grep 'define void @f49(i32 %a0.0, i32 %a0.1)' %t &&
struct s49 { enum e40 f0; int f1; };
void f49(struct s49 a0) { }
// RUN: grep 'define void @f50(void ()\* %a0.0)' %t &&
struct s50 { vvbp f0; };
void f50(struct s50 a0) { }
// RUN: grep 'define void @f51(void ()\* %a0.0, i32 %a0.1)' %t &&
struct s51 { vvbp f0; int f1; };
void f51(struct s51 a0) { }
// RUN: true