diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-17 19:02:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-17 19:02:33 +0000 |
commit | 0a8d91a816b72899bc1038be1131045ff62016ec (patch) | |
tree | 35bf6a3a897ac140d2d8eaf2cbeaf7c2d9af510a /llvm/lib/Target/TargetData.cpp | |
parent | b927073f2ef00bfa88656dd228e700be52599b7d (diff) | |
download | bcm5719-llvm-0a8d91a816b72899bc1038be1131045ff62016ec.tar.gz bcm5719-llvm-0a8d91a816b72899bc1038be1131045ff62016ec.zip |
fix PR6332, allowing an index of zero into a zero sized array
even if the element of the array has no size.
llvm-svn: 101662
Diffstat (limited to 'llvm/lib/Target/TargetData.cpp')
-rw-r--r-- | llvm/lib/Target/TargetData.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Target/TargetData.cpp b/llvm/lib/Target/TargetData.cpp index abee2e19244..d89fafd8137 100644 --- a/llvm/lib/Target/TargetData.cpp +++ b/llvm/lib/Target/TargetData.cpp @@ -630,8 +630,8 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, Value* const* Indices, Ty = cast<SequentialType>(Ty)->getElementType(); // Get the array index and the size of each array element. - int64_t arrayIdx = cast<ConstantInt>(Indices[CurIDX])->getSExtValue(); - Result += arrayIdx * (int64_t)getTypeAllocSize(Ty); + if (int64_t arrayIdx = cast<ConstantInt>(Indices[CurIDX])->getSExtValue()) + Result += arrayIdx * (int64_t)getTypeAllocSize(Ty); } } |