forked from OSchip/llvm-project
Check for empty structs, and for consistency, zero-element arrays.
llvm-svn: 123383
This commit is contained in:
parent
d43037cb70
commit
c8056a952e
|
@ -1084,12 +1084,12 @@ static bool isHomogeneousAggregate(const Type *T, unsigned &NumElts,
|
||||||
const Type *&EltTy) {
|
const Type *&EltTy) {
|
||||||
if (const ArrayType *AT = dyn_cast<ArrayType>(T)) {
|
if (const ArrayType *AT = dyn_cast<ArrayType>(T)) {
|
||||||
NumElts = AT->getNumElements();
|
NumElts = AT->getNumElements();
|
||||||
EltTy = AT->getElementType();
|
EltTy = (NumElts == 0 ? 0 : AT->getElementType());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (const StructType *ST = dyn_cast<StructType>(T)) {
|
if (const StructType *ST = dyn_cast<StructType>(T)) {
|
||||||
NumElts = ST->getNumContainedTypes();
|
NumElts = ST->getNumContainedTypes();
|
||||||
EltTy = ST->getContainedType(0);
|
EltTy = (NumElts == 0 ? 0 : ST->getContainedType(0));
|
||||||
for (unsigned n = 1; n < NumElts; ++n) {
|
for (unsigned n = 1; n < NumElts; ++n) {
|
||||||
if (ST->getContainedType(n) != EltTy)
|
if (ST->getContainedType(n) != EltTy)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue