diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-11-18 03:47:20 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-11-18 03:47:20 +0000 |
commit | 7e7ad3f8fa150de6144be332ae4bfe5d1acb5c6d (patch) | |
tree | 51d33141cf5098fa2b3a7081bfdb09b1acb9f12b /lib/CodeGen/TargetInfo.cpp | |
parent | 8d2fe42417fcc861b3324d585dc29ac4da59bee0 (diff) |
Fix the meaning of an "empty" record for the case of a zero-length array. Use isEmptyRecord for arguments on x86-32; there are structs of size 0 which don't count as empty.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144971 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TargetInfo.cpp')
-rw-r--r-- | lib/CodeGen/TargetInfo.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index 33291dd552..a2e15107f5 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -117,10 +117,14 @@ static bool isEmptyField(ASTContext &Context, const FieldDecl *FD, QualType FT = FD->getType(); - // Constant arrays of empty records count as empty, strip them off. + // Constant arrays of empty records count as empty, strip them off. + // Constant arrays of zero length always count as empty. if (AllowArrays) - while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) + while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) { + if (AT->getSize() == 0) + return true; FT = AT->getElementType(); + } const RecordType *RT = FT->getAs<RecordType>(); if (!RT) @@ -684,7 +688,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty) const { } // Ignore empty structs/unions. - if (Ty->isRecordType() && getContext().getTypeSize(Ty) == 0) + if (isEmptyRecord(Context, Ty, true)) return ABIArgInfo::getIgnore(); // Expand small (<= 128-bit) record types when we know that the stack layout |