From 461a67fa15370a9ec88f8f8a240bf7c123bb2029 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 18 Dec 2017 20:11:37 +0000 Subject: Vendor import of clang trunk r321017: https://llvm.org/svn/llvm-project/cfe/trunk@321017 --- include/clang/Analysis/Support/BumpVector.h | 53 ++++++++++++++++------------- 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'include/clang/Analysis/Support/BumpVector.h') diff --git a/include/clang/Analysis/Support/BumpVector.h b/include/clang/Analysis/Support/BumpVector.h index 591d17b9bc03c..5940520855ef2 100644 --- a/include/clang/Analysis/Support/BumpVector.h +++ b/include/clang/Analysis/Support/BumpVector.h @@ -1,4 +1,4 @@ -//===-- BumpVector.h - Vector-like ADT that uses bump allocation --*- C++ -*-=// +//===- BumpVector.h - Vector-like ADT that uses bump allocation -*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -21,16 +21,18 @@ #include "llvm/ADT/PointerIntPair.h" #include "llvm/Support/Allocator.h" -#include "llvm/Support/type_traits.h" -#include +#include +#include #include #include #include +#include namespace clang { class BumpVectorContext { llvm::PointerIntPair Alloc; + public: /// Construct a new BumpVectorContext that creates a new BumpPtrAllocator /// and destroys it when the BumpVectorContext object is destroyed. @@ -56,11 +58,13 @@ public: template class BumpVector { - T *Begin, *End, *Capacity; + T *Begin = nullptr; + T *End = nullptr; + T *Capacity = nullptr; + public: // Default ctor - Initialize to empty. - explicit BumpVector(BumpVectorContext &C, unsigned N) - : Begin(nullptr), End(nullptr), Capacity(nullptr) { + explicit BumpVector(BumpVectorContext &C, unsigned N) { reserve(C, N); } @@ -71,19 +75,19 @@ public: } } - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef T value_type; - typedef T* iterator; - typedef const T* const_iterator; + using size_type = size_t; + using difference_type = ptrdiff_t; + using value_type = T; + using iterator = T *; + using const_iterator = const T *; - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; + using const_reverse_iterator = std::reverse_iterator; + using reverse_iterator = std::reverse_iterator; - typedef T& reference; - typedef const T& const_reference; - typedef T* pointer; - typedef const T* const_pointer; + using reference = T &; + using const_reference = const T &; + using pointer = T *; + using const_pointer = const T *; // forward iterator creation methods. iterator begin() { return Begin; } @@ -92,10 +96,12 @@ public: const_iterator end() const { return End; } // reverse iterator creation methods. - reverse_iterator rbegin() { return reverse_iterator(end()); } + reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { return const_reverse_iterator(begin());} + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } bool empty() const { return Begin == End; } size_type size() const { return End-Begin; } @@ -166,7 +172,7 @@ public: /// iterator to position after last inserted copy. iterator insert(iterator I, size_t Cnt, const_reference E, BumpVectorContext &C) { - assert (I >= Begin && I <= End && "Iterator out of bounds."); + assert(I >= Begin && I <= End && "Iterator out of bounds."); if (End + Cnt <= Capacity) { Retry: move_range_right(I, End, Cnt); @@ -246,5 +252,6 @@ void BumpVector::grow(BumpVectorContext &C, size_t MinSize) { Capacity = Begin+NewCapacity; } -} // end: clang namespace -#endif +} // namespace clang + +#endif // LLVM_CLANG_ANALYSIS_SUPPORT_BUMPVECTOR_H -- cgit v1.2.3