diff options
| author | Sander de Smalen <sander.desmalen@arm.com> | 2018-02-01 12:27:13 +0000 |
|---|---|---|
| committer | Sander de Smalen <sander.desmalen@arm.com> | 2018-02-01 12:27:13 +0000 |
| commit | 294a4f68ffd3bfbd9cde07f3c0b37f37077c66c5 (patch) | |
| tree | 70701aadb00355ee9d57c1dea65ad8e693b11b9e /lib/CodeGen/CodeGenFunction.cpp | |
| parent | 835a31e2eff12ee909b131e07a44e0b8558d801a (diff) | |
| download | clang-294a4f68ffd3bfbd9cde07f3c0b37f37077c66c5.tar.gz | |
Reverting patch rL323952 due to build errors that I
haven't encountered in local builds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323956 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
| -rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index a7591b1045..e62d3e75b7 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -1758,9 +1758,12 @@ CodeGenFunction::EmitNullInitialization(Address DestPtr, QualType Ty) { if (const VariableArrayType *vlaType = dyn_cast_or_null<VariableArrayType>( getContext().getAsArrayType(Ty))) { - auto VlaSize = getVLASize(vlaType); - SizeVal = VlaSize.NumElts; - CharUnits eltSize = getContext().getTypeSizeInChars(VlaSize.Type); + QualType eltType; + llvm::Value *numElts; + std::tie(numElts, eltType) = getVLASize(vlaType); + + SizeVal = numElts; + CharUnits eltSize = getContext().getTypeSizeInChars(eltType); if (!eltSize.isOne()) SizeVal = Builder.CreateNUWMul(SizeVal, CGM.getSize(eltSize)); vla = vlaType; @@ -1843,7 +1846,7 @@ llvm::Value *CodeGenFunction::emitArrayLength(const ArrayType *origArrayType, // this is the size of the VLA in bytes, not its size in elements. llvm::Value *numVLAElements = nullptr; if (isa<VariableArrayType>(arrayType)) { - numVLAElements = getVLASize(cast<VariableArrayType>(arrayType)).NumElts; + numVLAElements = getVLASize(cast<VariableArrayType>(arrayType)).first; // Walk into all VLAs. This doesn't require changes to addr, // which has type T* where T is the first non-VLA element type. @@ -1924,13 +1927,14 @@ llvm::Value *CodeGenFunction::emitArrayLength(const ArrayType *origArrayType, return numElements; } -CodeGenFunction::VlaSizePair CodeGenFunction::getVLASize(QualType type) { +std::pair<llvm::Value*, QualType> +CodeGenFunction::getVLASize(QualType type) { const VariableArrayType *vla = getContext().getAsVariableArrayType(type); assert(vla && "type was not a variable array type!"); return getVLASize(vla); } -CodeGenFunction::VlaSizePair +std::pair<llvm::Value*, QualType> CodeGenFunction::getVLASize(const VariableArrayType *type) { // The number of elements so far; always size_t. llvm::Value *numElements = nullptr; @@ -1951,22 +1955,7 @@ CodeGenFunction::getVLASize(const VariableArrayType *type) { } } while ((type = getContext().getAsVariableArrayType(elementType))); - return { numElements, elementType }; -} - -CodeGenFunction::VlaSizePair -CodeGenFunction::getVLAElements1D(QualType type) { - const VariableArrayType *vla = getContext().getAsVariableArrayType(type); - assert(vla && "type was not a variable array type!"); - return getVLAElements1D(vla); -} - -CodeGenFunction::VlaSizePair -CodeGenFunction::getVLAElements1D(const VariableArrayType *Vla) { - llvm::Value *VlaSize = VLASizeMap[Vla->getSizeExpr()]; - assert(VlaSize && "no size for VLA!"); - assert(VlaSize->getType() == SizeTy); - return { VlaSize, Vla->getElementType() }; + return std::pair<llvm::Value*,QualType>(numElements, elementType); } void CodeGenFunction::EmitVariablyModifiedType(QualType type) { |
