diff options
Diffstat (limited to 'lib/VMCore/Constants.cpp')
-rw-r--r-- | lib/VMCore/Constants.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index df98d75864..55b97ef706 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -624,6 +624,15 @@ Constant *ConstantAggregateZero::getElementValue(Constant *C) { return getStructElement(cast<ConstantInt>(C)->getZExtValue()); } +/// getElementValue - Return a zero of the right value for the specified GEP +/// index. +Constant *ConstantAggregateZero::getElementValue(unsigned Idx) { + if (isa<SequentialType>(getType())) + return getSequentialElement(); + return getStructElement(Idx); +} + + //===----------------------------------------------------------------------===// // UndefValue Implementation //===----------------------------------------------------------------------===// @@ -648,6 +657,15 @@ UndefValue *UndefValue::getElementValue(Constant *C) { return getStructElement(cast<ConstantInt>(C)->getZExtValue()); } +/// getElementValue - Return an undef of the right value for the specified GEP +/// index. +UndefValue *UndefValue::getElementValue(unsigned Idx) { + if (isa<SequentialType>(getType())) + return getSequentialElement(); + return getStructElement(Idx); +} + + //===----------------------------------------------------------------------===// // ConstantXXX Classes |