4#ifndef SVF_GEPTYPEBRIDGEITERATOR_H
5#define SVF_GEPTYPEBRIDGEITERATOR_H
7#include "llvm/IR/DerivedTypes.h"
8#include "llvm/IR/Operator.h"
9#include "llvm/IR/User.h"
10#include "llvm/ADT/PointerIntPair.h"
11#include "llvm/IR/GetElementPtrTypeIterator.h"
16template<
typename ItTy = User::const_op_iterator>
20 typedef std::iterator<std::forward_iterator_tag,Type*, ptrdiff_t>
super;
30 I.
CurTy.setPointer(Ty);
39 I.
CurTy.setPointer(Ty);
67 return CurTy.getPointer();
72 assert(
false &&
"needs to be refactored");
74 return CurTy.getPointer();
75#if LLVM_VERSION_MAJOR >= 11
76 Type* CT =
CurTy.getPointer();
77 if (
auto ST = dyn_cast<StructType>(CT))
79 else if (
auto Array = dyn_cast<ArrayType>(CT))
80 return Array->getElementType();
81 else if (
auto Vector = dyn_cast<VectorType>(CT))
82 return Vector->getElementType();
86 CompositeType *CT = llvm::cast<CompositeType>(
CurTy.getPointer() );
100 return const_cast<Value*
>(&**
OpIt);
106 if (
CurTy.getInt() )
110#if LLVM_VERSION_MAJOR >= 11
111 else if ( Type* CT =
CurTy.getPointer() )
113 if (
auto ST = dyn_cast<StructType>(CT))
115 else if (
auto Array = dyn_cast<ArrayType>(CT))
116 CurTy.setPointer(Array->getElementType());
117 else if (
auto Vector = dyn_cast<VectorType>(CT))
118 CurTy.setPointer(Vector->getElementType());
120 CurTy.setPointer(
nullptr);
123 else if ( CompositeType * CT = dyn_cast<CompositeType>(
CurTy.getPointer()) )
130 CurTy.setPointer(
nullptr);
151 auto *GEPOp = llvm::cast<GEPOperator>(GEP);
153 llvm::cast<PointerType>(GEPOp->getPointerOperandType()->getScalarType())->getAddressSpace(),
154 GEP->op_begin() + 1);
164 auto &GEPOp = llvm::cast<GEPOperator>(GEP);
166 llvm::cast<PointerType>(GEPOp.getPointerOperandType()->getScalarType())->getAddressSpace(),
bool operator==(const generic_bridge_gep_type_iterator &x) const
static generic_bridge_gep_type_iterator begin(Type *Ty, unsigned AddrSpace, ItTy It)
static generic_bridge_gep_type_iterator end(ItTy It)
generic_bridge_gep_type_iterator operator++(int)
Type * getIndexedType() const
Value * getOperand() const
generic_bridge_gep_type_iterator & operator++()
generic_bridge_gep_type_iterator()
static generic_bridge_gep_type_iterator begin(Type *Ty, ItTy It)
std::iterator< std::forward_iterator_tag, Type *, ptrdiff_t > super
bool operator!=(const generic_bridge_gep_type_iterator &x) const
Type * operator->() const
PointerIntPair< Type *, 1 > CurTy
bridge_gep_iterator bridge_gep_end(const User *GEP)
bridge_gep_iterator bridge_gep_begin(const User *GEP)
generic_bridge_gep_type_iterator bridge_gep_iterator