From ab85225be49b2abf5112823d84525e91d469d6bd Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 2 Dec 2016 02:24:42 +0000 Subject: IR: Change the gep_type_iterator API to avoid always exposing the "current" type. Instead, expose whether the current type is an array or a struct, if an array what the upper bound is, and if a struct the struct type itself. This is in preparation for a later change which will make PointerType derive from Type rather than SequentialType. Differential Revision: https://reviews.llvm.org/D26594 llvm-svn: 288458 --- llvm/lib/IR/Operator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/IR/Operator.cpp') diff --git a/llvm/lib/IR/Operator.cpp b/llvm/lib/IR/Operator.cpp index 8a94053a72c..2fba24d99b3 100644 --- a/llvm/lib/IR/Operator.cpp +++ b/llvm/lib/IR/Operator.cpp @@ -33,7 +33,7 @@ bool GEPOperator::accumulateConstantOffset(const DataLayout &DL, continue; // Handle a struct index, which adds its field offset to the pointer. - if (StructType *STy = dyn_cast(*GTI)) { + if (StructType *STy = GTI.getStructTypeOrNull()) { unsigned ElementIdx = OpC->getZExtValue(); const StructLayout *SL = DL.getStructLayout(STy); Offset += APInt(Offset.getBitWidth(), SL->getElementOffset(ElementIdx)); -- cgit v1.2.3