about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2023-03-27 15:22:41 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2023-04-06 16:03:03 +0300
commit0bef0499cd9bfe75fd248abecc0146128e8a67a6 (patch)
tree5846542fbc44d366446b125f6b3206a849f79682
parent81ff90b3fc4f38abea2ab9472924dcdf0d1f10fe (diff)
downloadklee-0bef0499cd9bfe75fd248abecc0146128e8a67a6.tar.gz
Use newer C++ standard for KLEE's iterators; fixes deprecation warning
-rw-r--r--lib/Core/GetElementPtrTypeIterator.h74
-rw-r--r--lib/Core/SpecialFunctionHandler.h18
2 files changed, 50 insertions, 42 deletions
diff --git a/lib/Core/GetElementPtrTypeIterator.h b/lib/Core/GetElementPtrTypeIterator.h
index c24ff74b..d8b0e097 100644
--- a/lib/Core/GetElementPtrTypeIterator.h
+++ b/lib/Core/GetElementPtrTypeIterator.h
@@ -31,51 +31,53 @@ DISABLE_WARNING_POP
 
 namespace klee {
 template <typename ItTy = llvm::User::const_op_iterator>
-class generic_gep_type_iterator
-    : public std::iterator<std::forward_iterator_tag, llvm::Type *, ptrdiff_t> {
-  typedef std::iterator<std::forward_iterator_tag, llvm::Type *, ptrdiff_t>
-      super;
-
-    ItTy OpIt;
-    llvm::Type *CurTy;
-    generic_gep_type_iterator() {}
-
-    llvm::Value *asValue(llvm::Value *V) const { return V; }
-    llvm::Value *asValue(unsigned U) const {
-      return llvm::ConstantInt::get(CurTy->getContext(), llvm::APInt(32, U));
-    }
+class generic_gep_type_iterator {
+  using iterator_category = std::forward_iterator_tag;
+  using value_type = llvm::Type *;
+  using difference_type = ptrdiff_t;
+  using pointer = void;
+  using reference = void;
+
+  ItTy OpIt;
+  llvm::Type *CurTy;
+  generic_gep_type_iterator() {}
+
+  llvm::Value *asValue(llvm::Value *V) const { return V; }
+  llvm::Value *asValue(unsigned U) const {
+    return llvm::ConstantInt::get(CurTy->getContext(), llvm::APInt(32, U));
+  }
 
-  public:
-    static generic_gep_type_iterator begin(llvm::Type *Ty, ItTy It) {
-      generic_gep_type_iterator I;
-      I.CurTy = Ty;
-      I.OpIt = It;
-      return I;
-    }
-    static generic_gep_type_iterator end(ItTy It) {
-      generic_gep_type_iterator I;
-      I.CurTy = 0;
-      I.OpIt = It;
-      return I;
-    }
+public:
+  static generic_gep_type_iterator begin(llvm::Type *Ty, ItTy It) {
+    generic_gep_type_iterator I;
+    I.CurTy = Ty;
+    I.OpIt = It;
+    return I;
+  }
+  static generic_gep_type_iterator end(ItTy It) {
+    generic_gep_type_iterator I;
+    I.CurTy = 0;
+    I.OpIt = It;
+    return I;
+  }
 
-    bool operator==(const generic_gep_type_iterator& x) const {
-      return OpIt == x.OpIt;
-    }
-    bool operator!=(const generic_gep_type_iterator& x) const {
-      return !operator==(x);
-    }
+  bool operator==(const generic_gep_type_iterator &x) const {
+    return OpIt == x.OpIt;
+  }
+  bool operator!=(const generic_gep_type_iterator &x) const {
+    return !operator==(x);
+  }
 
-    llvm::Type *operator*() const { return CurTy; }
+  llvm::Type *operator*() const { return CurTy; }
 
-    llvm::Type *getIndexedType() const {
+  llvm::Type *getIndexedType() const {
 #if LLVM_VERSION_CODE >= LLVM_VERSION(11, 0)
       return llvm::GetElementPtrInst::getTypeAtIndex(CurTy, getOperand());
 #else
       llvm::CompositeType *CT = cast<llvm::CompositeType>(CurTy);
       return CT->getTypeAtIndex(getOperand());
 #endif
-    }
+  }
 
     // This is a non-standard operator->.  It allows you to call methods on the
     // current type directly.
@@ -104,7 +106,7 @@ class generic_gep_type_iterator
     generic_gep_type_iterator operator++(int) { // Postincrement
       generic_gep_type_iterator tmp = *this; ++*this; return tmp;
     }
-  };
+};
 
   typedef generic_gep_type_iterator<> gep_type_iterator;
   typedef generic_gep_type_iterator<llvm::ExtractValueInst::idx_iterator> ev_type_iterator;
diff --git a/lib/Core/SpecialFunctionHandler.h b/lib/Core/SpecialFunctionHandler.h
index 9487fdf5..230d3929 100644
--- a/lib/Core/SpecialFunctionHandler.h
+++ b/lib/Core/SpecialFunctionHandler.h
@@ -50,12 +50,18 @@ namespace klee {
 
     // const_iterator to iterate over stored HandlerInfo
     // FIXME: Implement >, >=, <=, < operators
-    class const_iterator : public std::iterator<std::random_access_iterator_tag, HandlerInfo>
-    {
-      private:
-        value_type* base;
-        int index;
-      public:
+    class const_iterator {
+      using iterator_category = std::random_access_iterator_tag;
+      using value_type = HandlerInfo;
+      using difference_type = ptrdiff_t;
+      using pointer = void;
+      using reference = void;
+
+    private:
+      value_type *base;
+      int index;
+
+    public:
       const_iterator(value_type* hi) : base(hi), index(0) {};
       const_iterator& operator++();  // pre-fix
       const_iterator operator++(int); // post-fix