diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-05-13 15:18:06 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-05-13 15:18:06 +0000 |
commit | 3fa82837441d716a225427f7a924f36d21db3a32 (patch) | |
tree | 46504366629499f3e15ceeeb776376a7677ee694 /lib/VMCore | |
parent | eea6c95d5d9f202ccb4e90995dc8a4a4c439cec3 (diff) | |
download | external_llvm-3fa82837441d716a225427f7a924f36d21db3a32.zip external_llvm-3fa82837441d716a225427f7a924f36d21db3a32.tar.gz external_llvm-3fa82837441d716a225427f7a924f36d21db3a32.tar.bz2 |
Make codegen able to handle values of empty types. This is one way
to fix PR9900. I will keep it open until sable is able to comment on it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131294 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Type.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index b15304c..e4496db 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -197,6 +197,25 @@ bool Type::canLosslesslyBitCastTo(const Type *Ty) const { return false; // Other types have no identity values } +bool Type::isEmptyTy() const { + const ArrayType *ATy = dyn_cast<ArrayType>(this); + if (ATy) { + unsigned NumElements = ATy->getNumElements(); + return NumElements == 0 || ATy->getElementType()->isEmptyTy(); + } + + const StructType *STy = dyn_cast<StructType>(this); + if (STy) { + unsigned NumElements = STy->getNumElements(); + for (unsigned i = 0; i < NumElements; ++i) + if (!STy->getElementType(i)->isEmptyTy()) + return false; + return true; + } + + return false; +} + unsigned Type::getPrimitiveSizeInBits() const { switch (getTypeID()) { case Type::FloatTyID: return 32; |