Index: include/llvm/ADT/ArrayRef.h =================================================================== --- include/llvm/ADT/ArrayRef.h +++ include/llvm/ADT/ArrayRef.h @@ -13,6 +13,13 @@ #include "llvm/ADT/Hashing.h" #include "llvm/ADT/None.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Compiler.h" +#include +#include +#include +#include +#include +#include #include namespace llvm { @@ -30,12 +37,11 @@ template class ArrayRef { public: - typedef const T *iterator; - typedef const T *const_iterator; - typedef size_t size_type; + using iterator = const T *; + using const_iterator = const T *; + using size_type = size_t; + using reverse_iterator = std::reverse_iterator; - typedef std::reverse_iterator reverse_iterator; - private: /// The start of the array, in an external buffer. const T *Data; @@ -225,10 +231,9 @@ template class MutableArrayRef : public ArrayRef { public: - typedef T *iterator; + using iterator = T *; + using reverse_iterator = std::reverse_iterator; - typedef std::reverse_iterator reverse_iterator; - /// Construct an empty MutableArrayRef. /*implicit*/ MutableArrayRef() : ArrayRef() {} Index: include/llvm/ADT/SmallSet.h =================================================================== --- include/llvm/ADT/SmallSet.h +++ include/llvm/ADT/SmallSet.h @@ -17,7 +17,11 @@ #include "llvm/ADT/None.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Compiler.h" +#include +#include #include +#include namespace llvm { @@ -35,16 +39,18 @@ /// we will never use. SmallVector Vector; std::set Set; - typedef typename SmallVector::const_iterator VIterator; - typedef typename SmallVector::iterator mutable_iterator; + using VIterator = typename SmallVector::const_iterator; + using mutable_iterator = typename SmallVector::iterator; + // In small mode SmallPtrSet uses linear search for the elements, so it is // not a good idea to choose this value too high. You may consider using a // DenseSet<> instead if you expect many elements in the set. static_assert(N <= 32, "N should be small"); public: - typedef size_t size_type; + using size_type = size_t; + SmallSet() {} bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { @@ -133,4 +139,4 @@ } // end namespace llvm -#endif +#endif // LLVM_ADT_SMALLSET_H Index: include/llvm/ADT/SmallVector.h =================================================================== --- include/llvm/ADT/SmallVector.h +++ include/llvm/ADT/SmallVector.h @@ -27,6 +27,8 @@ #include #include #include +#include +#include namespace llvm { @@ -57,8 +59,6 @@ bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { return BeginX == EndX; } }; -template struct SmallVectorStorage; - /// This is the part of SmallVectorTemplateBase which does not depend on whether /// the type T is a POD. The extra dummy template argument is used by ArrayRef /// to avoid unnecessarily requiring T to be complete. @@ -70,7 +70,7 @@ // Allocate raw space for N elements of type T. If T has a ctor or dtor, we // don't want it to be automatically run, so we need to represent the space as // something else. Use an array of char of sufficient alignment. - typedef llvm::AlignedCharArrayUnion U; + using U = llvm::AlignedCharArrayUnion; U FirstEl; // Space after 'FirstEl' is clobbered, do not add any instance vars after it. @@ -94,20 +94,18 @@ void setEnd(T *P) { this->EndX = P; } 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 *; + using const_reverse_iterator = std::reverse_iterator; + using reverse_iterator = std::reverse_iterator; + using reference = T &; + using const_reference = const T &; + using pointer = T *; + using const_pointer = const T *; - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; - - typedef T &reference; - typedef const T &const_reference; - typedef T *pointer; - typedef const T *const_pointer; - // forward iterator creation methods. LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin() { return (iterator)this->BeginX; } @@ -117,11 +115,12 @@ iterator end() { return (iterator)this->EndX; } LLVM_ATTRIBUTE_ALWAYS_INLINE const_iterator end() const { return (const_iterator)this->EndX; } + protected: iterator capacity_ptr() { return (iterator)this->CapacityX; } const_iterator capacity_ptr() const { return (const_iterator)this->CapacityX;} -public: +public: // reverse iterator creation methods. reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); } @@ -251,7 +250,6 @@ this->CapacityX = this->begin()+NewCapacity; } - /// SmallVectorTemplateBase - This is where we put method /// implementations that are designed to work with POD-like T's. template @@ -311,18 +309,18 @@ } }; - /// This class consists of common code factored out of the SmallVector class to /// reduce code duplication based on the SmallVector 'N' template parameter. template class SmallVectorImpl : public SmallVectorTemplateBase::value> { - typedef SmallVectorTemplateBase::value > SuperClass; + using SuperClass = SmallVectorTemplateBase::value >; SmallVectorImpl(const SmallVectorImpl&) = delete; + public: - typedef typename SuperClass::iterator iterator; - typedef typename SuperClass::const_iterator const_iterator; - typedef typename SuperClass::size_type size_type; + using iterator = typename SuperClass::iterator; + using const_iterator = typename SuperClass::const_iterator; + using size_type = typename SuperClass::size_type; protected: // Default ctor - Initialize to empty. @@ -340,7 +338,6 @@ free(this->begin()); } - void clear() { this->destroy_range(this->begin(), this->end()); this->EndX = this->BeginX; @@ -668,7 +665,6 @@ } }; - template void SmallVectorImpl::swap(SmallVectorImpl &RHS) { if (this == &RHS) return; @@ -841,6 +837,7 @@ class SmallVector : public SmallVectorImpl { /// Inline space for elements which aren't stored in the base class. SmallVectorStorage Storage; + public: SmallVector() : SmallVectorImpl(N) { } @@ -906,7 +903,7 @@ return X.capacity_in_bytes(); } -} // End llvm namespace +} // end namespace llvm namespace std { /// Implement std::swap in terms of SmallVector swap. @@ -922,6 +919,6 @@ swap(llvm::SmallVector &LHS, llvm::SmallVector &RHS) { LHS.swap(RHS); } -} +} // end namespace std -#endif +#endif // LLVM_ADT_SMALLVECTOR_H Index: include/llvm/ADT/StringRef.h =================================================================== --- include/llvm/ADT/StringRef.h +++ include/llvm/ADT/StringRef.h @@ -17,6 +17,7 @@ #include #include #include +#include #include namespace llvm { @@ -41,10 +42,10 @@ /// general safe to store a StringRef. class StringRef { public: - typedef const char *iterator; - typedef const char *const_iterator; + using iterator = const char *; + using const_iterator = const char *; + using size_type = size_t; static const size_t npos = ~size_t(0); - typedef size_t size_type; private: /// The start of the string, in an external buffer. @@ -627,6 +628,6 @@ // StringRefs can be treated like a POD type. template struct isPodLike; template <> struct isPodLike { static const bool value = true; }; -} +} // end namespace llvm -#endif +#endif // LLVM_ADT_STRINGREF_H