aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/TargetData.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-17 19:02:33 +0000
committerChris Lattner <sabre@nondot.org>2010-04-17 19:02:33 +0000
commit34e9d17d1b5fdba2b6fe75979c941209a442560e (patch)
treeace778ae97f986b23738b5f3885a2689c4bb2c21 /lib/Target/TargetData.cpp
parenteef6d78be1c3a685f277be3e89ff17f67ed65f49 (diff)
downloadexternal_llvm-34e9d17d1b5fdba2b6fe75979c941209a442560e.zip
external_llvm-34e9d17d1b5fdba2b6fe75979c941209a442560e.tar.gz
external_llvm-34e9d17d1b5fdba2b6fe75979c941209a442560e.tar.bz2
fix PR6332, allowing an index of zero into a zero sized array
even if the element of the array has no size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101662 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetData.cpp')
-rw-r--r--lib/Target/TargetData.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index abee2e1..d89fafd 100644
--- a/lib/Target/TargetData.cpp
+++ b/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);
}
}