From b640fcf217c848ad051977018c6dc8f3a5a37e1f Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 20 Jul 2011 18:36:48 +0000 Subject: Updates for LLVM 3.0. Based on changes by arrowdodger, thanks! git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@135598 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/klee/Config/Version.h | 6 ++++++ include/klee/util/GetElementPtrTypeIterator.h | 27 ++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/klee/Config/Version.h b/include/klee/Config/Version.h index f5adaa66..ea2af961 100644 --- a/include/klee/Config/Version.h +++ b/include/klee/Config/Version.h @@ -15,4 +15,10 @@ #define LLVM_VERSION(major, minor) (((major) << 8) | (minor)) #define LLVM_VERSION_CODE LLVM_VERSION(LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR) +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0) +# define LLVM_TYPE_Q +#else +# define LLVM_TYPE_Q const +#endif + #endif diff --git a/include/klee/util/GetElementPtrTypeIterator.h b/include/klee/util/GetElementPtrTypeIterator.h index 302c19ef..4446914d 100644 --- a/include/klee/util/GetElementPtrTypeIterator.h +++ b/include/klee/util/GetElementPtrTypeIterator.h @@ -18,6 +18,8 @@ #ifndef KLEE_UTIL_GETELEMENTPTRTYPE_H #define KLEE_UTIL_GETELEMENTPTRTYPE_H +#include "klee/Config/Version.h" + #include "llvm/User.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" @@ -29,12 +31,13 @@ namespace klee { template class generic_gep_type_iterator - : public std::iterator { + : public std::iterator { typedef std::iterator super; + LLVM_TYPE_Q llvm::Type *, ptrdiff_t> super; ItTy OpIt; - const llvm::Type *CurTy; + LLVM_TYPE_Q llvm::Type *CurTy; generic_gep_type_iterator() {} llvm::Value *asValue(llvm::Value *V) const { return V; } @@ -44,7 +47,8 @@ namespace klee { public: - static generic_gep_type_iterator begin(const llvm::Type *Ty, ItTy It) { + static generic_gep_type_iterator begin(LLVM_TYPE_Q llvm::Type *Ty, + ItTy It) { generic_gep_type_iterator I; I.CurTy = Ty; I.OpIt = It; @@ -64,23 +68,24 @@ namespace klee { return !operator==(x); } - const llvm::Type *operator*() const { + LLVM_TYPE_Q llvm::Type *operator*() const { return CurTy; } - const llvm::Type *getIndexedType() const { - const llvm::CompositeType *CT = cast(CurTy); + LLVM_TYPE_Q llvm::Type *getIndexedType() const { + LLVM_TYPE_Q llvm::CompositeType *CT = cast(CurTy); return CT->getTypeAtIndex(getOperand()); } // This is a non-standard operator->. It allows you to call methods on the // current type directly. - const llvm::Type *operator->() const { return operator*(); } + LLVM_TYPE_Q llvm::Type *operator->() const { return operator*(); } llvm::Value *getOperand() const { return asValue(*OpIt); } generic_gep_type_iterator& operator++() { // Preincrement - if (const llvm::CompositeType *CT = dyn_cast(CurTy)) { + if (LLVM_TYPE_Q llvm::CompositeType *CT = + dyn_cast(CurTy)) { CurTy = CT->getTypeAtIndex(getOperand()); } else { CurTy = 0; @@ -140,13 +145,13 @@ namespace klee { template inline generic_gep_type_iterator - gep_type_begin(const llvm::Type *Op0, ItTy I, ItTy E) { + gep_type_begin(LLVM_TYPE_Q llvm::Type *Op0, ItTy I, ItTy E) { return generic_gep_type_iterator::begin(Op0, I); } template inline generic_gep_type_iterator - gep_type_end(const llvm::Type *Op0, ItTy I, ItTy E) { + gep_type_end(LLVM_TYPE_Q llvm::Type *Op0, ItTy I, ItTy E) { return generic_gep_type_iterator::end(E); } } // end namespace klee -- cgit 1.4.1