fix a small oversight that broke the fhourstones app.
authorChris Lattner <sabre@nondot.org>
Tue, 31 Jan 2012 05:18:56 +0000 (05:18 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 31 Jan 2012 05:18:56 +0000 (05:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149357 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Constants.cpp

index 624dc2ef3982f557417182bd8fe2f9d1bd85a385..39c96c714db754588475dde227058be743acbcb3 100644 (file)
@@ -176,7 +176,7 @@ Constant *Constant::getAggregateElement(unsigned Elt) const {
     return UV->getElementValue(Elt);
   
   if (const ConstantDataSequential *CDS =dyn_cast<ConstantDataSequential>(this))
-    return CDS->getElementAsConstant(Elt);
+    return Elt < CDS->getNumElements() ? CDS->getElementAsConstant(Elt) : 0;
   return 0;
 }