diff options
| author | Sander de Smalen <sander.desmalen@arm.com> | 2018-02-03 13:55:59 +0000 |
|---|---|---|
| committer | Sander de Smalen <sander.desmalen@arm.com> | 2018-02-03 13:55:59 +0000 |
| commit | 6804b86ee9cc16b8a0dbc7024a497d179e88b4d4 (patch) | |
| tree | 5168609355ffdb9a1d5f9edad3043a7f139b6246 /lib/CodeGen/CodeGenFunction.cpp | |
| parent | f79c9a1752ced0887f7395040c17774bd6790fe5 (diff) | |
| download | clang-6804b86ee9cc16b8a0dbc7024a497d179e88b4d4.tar.gz | |
Recommit rL323952: [DebugInfo] Enable debug information for C99 VLA types.
Fixed build issue when building with g++-4.8 (specialization after instantiation).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324173 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
| -rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index e62d3e75b7..a7591b1045 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -1758,12 +1758,9 @@ CodeGenFunction::EmitNullInitialization(Address DestPtr, QualType Ty) { if (const VariableArrayType *vlaType = dyn_cast_or_null<VariableArrayType>( getContext().getAsArrayType(Ty))) { - QualType eltType; - llvm::Value *numElts; - std::tie(numElts, eltType) = getVLASize(vlaType); - - SizeVal = numElts; - CharUnits eltSize = getContext().getTypeSizeInChars(eltType); + auto VlaSize = getVLASize(vlaType); + SizeVal = VlaSize.NumElts; + CharUnits eltSize = getContext().getTypeSizeInChars(VlaSize.Type); if (!eltSize.isOne()) SizeVal = Builder.CreateNUWMul(SizeVal, CGM.getSize(eltSize)); vla = vlaType; @@ -1846,7 +1843,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)).first; + numVLAElements = getVLASize(cast<VariableArrayType>(arrayType)).NumElts; // Walk into all VLAs. This doesn't require changes to addr, // which has type T* where T is the first non-VLA element type. @@ -1927,14 +1924,13 @@ llvm::Value *CodeGenFunction::emitArrayLength(const ArrayType *origArrayType, return numElements; } -std::pair<llvm::Value*, QualType> -CodeGenFunction::getVLASize(QualType type) { +CodeGenFunction::VlaSizePair CodeGenFunction::getVLASize(QualType type) { const VariableArrayType *vla = getContext().getAsVariableArrayType(type); assert(vla && "type was not a variable array type!"); return getVLASize(vla); } -std::pair<llvm::Value*, QualType> +CodeGenFunction::VlaSizePair CodeGenFunction::getVLASize(const VariableArrayType *type) { // The number of elements so far; always size_t. llvm::Value *numElements = nullptr; @@ -1955,7 +1951,22 @@ CodeGenFunction::getVLASize(const VariableArrayType *type) { } } while ((type = getContext().getAsVariableArrayType(elementType))); - return std::pair<llvm::Value*,QualType>(numElements, 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() }; } void CodeGenFunction::EmitVariablyModifiedType(QualType type) { |
