diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-05-11 23:01:34 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-05-11 23:01:34 +0000 |
commit | 097353cbb576b68be28f6c98c88601042af76a0e (patch) | |
tree | 0575b7161748c33e1f9aa357af11d6350d6730fe /clang/lib/CodeGen | |
parent | 388117089899a3e27a24f2f7f5cfa64255ca4d08 (diff) | |
download | bcm5719-llvm-097353cbb576b68be28f6c98c88601042af76a0e.tar.gz bcm5719-llvm-097353cbb576b68be28f6c98c88601042af76a0e.zip |
Darwin x86-32: Multi-dimensional arrays were not handled correctly,
spotted by Eli!
llvm-svn: 71490
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 36b6b92ab82..c46e7901d9f 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -166,10 +166,9 @@ static bool isEmptyField(ASTContext &Context, const FieldDecl *FD) { return true; QualType FT = FD->getType(); - // Arrays of empty records count as empty. - if (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) - if (isEmptyRecord(Context, AT->getElementType())) - return true; + // Constant arrays of empty records count as empty, strip them off. + while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) + FT = AT->getElementType(); return isEmptyRecord(Context, FT); } @@ -218,14 +217,18 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) { if (isEmptyField(Context, FD)) continue; - // Treat single element arrays as the element - if (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) - if (AT->getSize().getZExtValue() == 1) - FT = AT->getElementType(); - + // If we already found an element then this isn't a single-element + // struct. if (Found) return 0; + // Treat single element arrays as the element. + while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) { + if (AT->getSize().getZExtValue() != 1) + break; + FT = AT->getElementType(); + } + if (!CodeGenFunction::hasAggregateLLVMType(FT)) { Found = FT.getTypePtr(); } else { |