aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorSander de Smalen <sander.desmalen@arm.com>2018-02-01 12:27:13 +0000
committerSander de Smalen <sander.desmalen@arm.com>2018-02-01 12:27:13 +0000
commit4e9a1264dd0b887c54aae30d9e1b83a09db5ea38 (patch)
tree94878ab6f273e479ecfc8e916ab882755f7c49da /clang/lib/CodeGen/CodeGenFunction.cpp
parentea8d07eb7635cef2fa07f841308e58204d1b2280 (diff)
downloadllvm-4e9a1264dd0b887c54aae30d9e1b83a09db5ea38.zip
llvm-4e9a1264dd0b887c54aae30d9e1b83a09db5ea38.tar.gz
llvm-4e9a1264dd0b887c54aae30d9e1b83a09db5ea38.tar.bz2
Reverting patch rL323952 due to build errors that I
haven't encountered in local builds. llvm-svn: 323956
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp33
1 files changed, 11 insertions, 22 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index a7591b1..e62d3e7 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/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) {