зеркало из https://github.com/microsoft/clang-1.git
simplify code and smallvectorize.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149915 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
5b6a3ddda0
Коммит
6ef016f872
|
@ -1375,17 +1375,18 @@ llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) {
|
|||
return llvm::Constant::getNullValue(getTypes().ConvertTypeForMem(T));
|
||||
|
||||
if (const ConstantArrayType *CAT = Context.getAsConstantArrayType(T)) {
|
||||
llvm::ArrayType *ATy =
|
||||
cast<llvm::ArrayType>(getTypes().ConvertTypeForMem(T));
|
||||
|
||||
QualType ElementTy = CAT->getElementType();
|
||||
|
||||
llvm::Constant *Element = EmitNullConstant(ElementTy);
|
||||
unsigned NumElements = CAT->getSize().getZExtValue();
|
||||
std::vector<llvm::Constant *> Array(NumElements);
|
||||
for (unsigned i = 0; i != NumElements; ++i)
|
||||
Array[i] = Element;
|
||||
|
||||
llvm::ArrayType *ATy =
|
||||
cast<llvm::ArrayType>(getTypes().ConvertTypeForMem(T));
|
||||
|
||||
if (Element->isNullValue())
|
||||
return llvm::ConstantAggregateZero::get(ATy);
|
||||
|
||||
SmallVector<llvm::Constant *, 8> Array(NumElements, Element);
|
||||
return llvm::ConstantArray::get(ATy, Array);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче