Index: clang/lib/CodeGen/CGDecl.cpp =================================================================== --- clang/lib/CodeGen/CGDecl.cpp +++ clang/lib/CodeGen/CGDecl.cpp @@ -2181,14 +2181,15 @@ Destroyer *destroyer, bool useEHCleanupForArray) { const ArrayType *arrayType = getContext().getAsArrayType(type); - if (!arrayType) - return destroyer(*this, addr, type); + if (!arrayType) { + destroyer(*this, addr, type); + return; + } llvm::Value *length = emitArrayLength(arrayType, type, addr); - CharUnits elementAlign = - addr.getAlignment() - .alignmentOfArrayElement(getContext().getTypeSizeInChars(type)); + CharUnits elementAlign = addr.getAlignment().alignmentOfArrayElement( + getContext().getTypeSizeInChars(type)); // Normally we have to check whether the array is zero-length. bool checkZeroLength = true; @@ -2196,15 +2197,16 @@ // But if the array length is constant, we can suppress that. if (llvm::ConstantInt *constLength = dyn_cast(length)) { // ...and if it's constant zero, we can just skip the entire thing. - if (constLength->isZero()) return; + if (constLength->isZero()) + return; checkZeroLength = false; } llvm::Value *begin = addr.getPointer(); llvm::Value *end = Builder.CreateInBoundsGEP(addr.getElementType(), begin, length); - emitArrayDestroy(begin, end, type, elementAlign, destroyer, - checkZeroLength, useEHCleanupForArray); + emitArrayDestroy(begin, end, type, elementAlign, destroyer, checkZeroLength, + useEHCleanupForArray); } /// emitArrayDestroy - Destroys all the elements of the given array,