diff options
| author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-11-23 00:30:24 +0000 |
|---|---|---|
| committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-11-23 00:30:24 +0000 |
| commit | 2b2bfce5803d1b47325a65d26cf35a5dda47786d (patch) | |
| tree | cdda27fdd2a3bd020ccaae7e350efbd3504a95f6 | |
| parent | 15a91d854661773c1291c83ff86720fc30564a4e (diff) | |
| download | bcm5719-llvm-2b2bfce5803d1b47325a65d26cf35a5dda47786d.tar.gz bcm5719-llvm-2b2bfce5803d1b47325a65d26cf35a5dda47786d.zip | |
[ADT] Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D27001
llvm-svn: 287725
| -rw-r--r-- | llvm/include/llvm/ADT/DAGDeltaAlgorithm.h | 6 | ||||
| -rw-r--r-- | llvm/include/llvm/ADT/DepthFirstIterator.h | 16 | ||||
| -rw-r--r-- | llvm/include/llvm/ADT/EquivalenceClasses.h | 17 | ||||
| -rw-r--r-- | llvm/include/llvm/ADT/FoldingSet.h | 39 | ||||
| -rw-r--r-- | llvm/include/llvm/ADT/ImmutableSet.h | 35 | ||||
| -rw-r--r-- | llvm/include/llvm/ADT/IntervalMap.h | 38 | ||||
| -rw-r--r-- | llvm/include/llvm/ADT/IntrusiveRefCntPtr.h | 22 | ||||
| -rw-r--r-- | llvm/include/llvm/ADT/PointerUnion.h | 19 | ||||
| -rw-r--r-- | llvm/include/llvm/ADT/SmallString.h | 8 | ||||
| -rw-r--r-- | llvm/include/llvm/ADT/StringMap.h | 23 | ||||
| -rw-r--r-- | llvm/include/llvm/ADT/iterator.h | 7 |
11 files changed, 130 insertions, 100 deletions
diff --git a/llvm/include/llvm/ADT/DAGDeltaAlgorithm.h b/llvm/include/llvm/ADT/DAGDeltaAlgorithm.h index 3dd862c8b22..5ea0fe87286 100644 --- a/llvm/include/llvm/ADT/DAGDeltaAlgorithm.h +++ b/llvm/include/llvm/ADT/DAGDeltaAlgorithm.h @@ -10,6 +10,7 @@ #define LLVM_ADT_DAGDELTAALGORITHM_H #include <set> +#include <utility> #include <vector> namespace llvm { @@ -37,6 +38,7 @@ namespace llvm { /// should satisfy. class DAGDeltaAlgorithm { virtual void anchor(); + public: typedef unsigned change_ty; typedef std::pair<change_ty, change_ty> edge_ty; @@ -46,7 +48,7 @@ public: typedef std::vector<changeset_ty> changesetlist_ty; public: - virtual ~DAGDeltaAlgorithm() {} + virtual ~DAGDeltaAlgorithm() = default; /// Run - Minimize the DAG formed by the \p Changes vertices and the /// \p Dependencies edges by executing \see ExecuteOneTest() on subsets of @@ -74,4 +76,4 @@ public: } // end namespace llvm -#endif +#endif // LLVM_ADT_DAGDELTAALGORITHM_H diff --git a/llvm/include/llvm/ADT/DepthFirstIterator.h b/llvm/include/llvm/ADT/DepthFirstIterator.h index 634438d9e2b..c5457320458 100644 --- a/llvm/include/llvm/ADT/DepthFirstIterator.h +++ b/llvm/include/llvm/ADT/DepthFirstIterator.h @@ -34,10 +34,13 @@ #define LLVM_ADT_DEPTHFIRSTITERATOR_H #include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/iterator_range.h" +#include <iterator> #include <set> +#include <utility> #include <vector> namespace llvm { @@ -55,6 +58,7 @@ class df_iterator_storage<SetType, true> { public: df_iterator_storage(SetType &VSet) : Visited(VSet) {} df_iterator_storage(const df_iterator_storage &S) : Visited(S.Visited) {} + SetType &Visited; }; @@ -63,8 +67,8 @@ public: // node have been processed. It is intended to distinguish of back and // cross edges in the spanning tree but is not used in the common case. template <typename NodeRef, unsigned SmallSize=8> -struct df_iterator_default_set : public llvm::SmallPtrSet<NodeRef, SmallSize> { - typedef llvm::SmallPtrSet<NodeRef, SmallSize> BaseSet; +struct df_iterator_default_set : public SmallPtrSet<NodeRef, SmallSize> { + typedef SmallPtrSet<NodeRef, SmallSize> BaseSet; typedef typename BaseSet::iterator iterator; std::pair<iterator,bool> insert(NodeRef N) { return BaseSet::insert(N) ; } template <typename IterT> @@ -99,9 +103,7 @@ private: this->Visited.insert(Node); VisitStack.push_back(StackElement(Node, None)); } - inline df_iterator() { - // End is when stack is empty - } + inline df_iterator() = default; // End is when stack is empty inline df_iterator(NodeRef Node, SetType &S) : df_iterator_storage<SetType, ExtStorage>(S) { if (this->Visited.insert(Node).second) @@ -298,6 +300,6 @@ iterator_range<idf_ext_iterator<T, SetTy>> inverse_depth_first_ext(const T& G, return make_range(idf_ext_begin(G, S), idf_ext_end(G, S)); } -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_ADT_DEPTHFIRSTITERATOR_H diff --git a/llvm/include/llvm/ADT/EquivalenceClasses.h b/llvm/include/llvm/ADT/EquivalenceClasses.h index d6a26f88e67..8fcac178ffc 100644 --- a/llvm/include/llvm/ADT/EquivalenceClasses.h +++ b/llvm/include/llvm/ADT/EquivalenceClasses.h @@ -15,9 +15,10 @@ #ifndef LLVM_ADT_EQUIVALENCECLASSES_H #define LLVM_ADT_EQUIVALENCECLASSES_H -#include "llvm/Support/DataTypes.h" #include <cassert> #include <cstddef> +#include <cstdint> +#include <iterator> #include <set> namespace llvm { @@ -70,6 +71,7 @@ class EquivalenceClasses { friend class EquivalenceClasses; mutable const ECValue *Leader, *Next; ElemTy Data; + // ECValue ctor - Start out with EndOfList pointing to this node, Next is // Null, isLeader = true. ECValue(const ElemTy &Elt) @@ -81,6 +83,7 @@ class EquivalenceClasses { // Path compression. return Leader = Leader->getLeader(); } + const ECValue *getEndOfList() const { assert(isLeader() && "Cannot get the end of a list for a non-leader!"); return Leader; @@ -90,6 +93,7 @@ class EquivalenceClasses { assert(getNext() == nullptr && "Already has a next pointer!"); Next = (const ECValue*)((intptr_t)NewNext | (intptr_t)isLeader()); } + public: ECValue(const ECValue &RHS) : Leader(this), Next((ECValue*)(intptr_t)1), Data(RHS.Data) { @@ -115,7 +119,7 @@ class EquivalenceClasses { std::set<ECValue> TheMapping; public: - EquivalenceClasses() {} + EquivalenceClasses() = default; EquivalenceClasses(const EquivalenceClasses &RHS) { operator=(RHS); } @@ -187,7 +191,6 @@ public: return NC; } - //===--------------------------------------------------------------------===// // Mutation methods @@ -210,7 +213,6 @@ public: return findLeader(TheMapping.find(V)); } - /// union - Merge the two equivalence sets for the specified values, inserting /// them if they do not already exist in the equivalence set. member_iterator unionSets(const ElemTy &V1, const ElemTy &V2) { @@ -243,12 +245,13 @@ public: const ElemTy, ptrdiff_t> super; const ECValue *Node; friend class EquivalenceClasses; + public: typedef size_t size_type; typedef typename super::pointer pointer; typedef typename super::reference reference; - explicit member_iterator() {} + explicit member_iterator() = default; explicit member_iterator(const ECValue *N) : Node(N) {} reference operator*() const { @@ -278,6 +281,6 @@ public: }; }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_ADT_EQUIVALENCECLASSES_H diff --git a/llvm/include/llvm/ADT/FoldingSet.h b/llvm/include/llvm/ADT/FoldingSet.h index f16258af4ae..dab18297dd3 100644 --- a/llvm/include/llvm/ADT/FoldingSet.h +++ b/llvm/include/llvm/ADT/FoldingSet.h @@ -19,8 +19,13 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/iterator.h" #include "llvm/Support/Allocator.h" +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <utility> namespace llvm { + /// This folding set used for two purposes: /// 1. Given information about a node we want to create, look up the unique /// instance of the node in the set. If the node already exists, return @@ -184,6 +189,7 @@ public: /// EltCount-th node won't cause a rebucket operation. reserve is permitted /// to allocate more space than requested by EltCount. void reserve(unsigned EltCount); + /// capacity - Returns the number of nodes permitted in the folding set /// before a rebucket operation is performed. unsigned capacity() { @@ -200,14 +206,17 @@ private: /// NewBucketCount must be a power of two, and must be greater than the old /// bucket count. void GrowBucketCount(unsigned NewBucketCount); + protected: /// GetNodeProfile - Instantiations of the FoldingSet template implement /// this function to gather data bits for the given node. virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const = 0; + /// NodeEquals - Instantiations of the FoldingSet template implement /// this function to compare the given node with the given ID. virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID) const=0; + /// ComputeNodeHash - Instantiations of the FoldingSet template implement /// this function to compute a hash value for the given node. virtual unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const = 0; @@ -215,8 +224,6 @@ protected: //===----------------------------------------------------------------------===// -template<typename T> struct FoldingSetTrait; - /// DefaultFoldingSetTrait - This class provides default implementations /// for FoldingSetTrait implementations. /// @@ -252,8 +259,6 @@ template<typename T> struct DefaultFoldingSetTrait { template<typename T> struct FoldingSetTrait : public DefaultFoldingSetTrait<T> {}; -template<typename T, typename Ctx> struct ContextualFoldingSetTrait; - /// DefaultContextualFoldingSetTrait - Like DefaultFoldingSetTrait, but /// for ContextualFoldingSets. template<typename T, typename Ctx> @@ -261,6 +266,7 @@ struct DefaultContextualFoldingSetTrait { static void Profile(T &X, FoldingSetNodeID &ID, Ctx Context) { X.Profile(ID, Context); } + static inline bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID, Ctx Context); static inline unsigned ComputeHash(T &X, FoldingSetNodeID &TempID, @@ -279,11 +285,11 @@ template<typename T, typename Ctx> struct ContextualFoldingSetTrait /// is often much larger than necessary, and the possibility of heap /// allocation means it requires a non-trivial destructor call. class FoldingSetNodeIDRef { - const unsigned *Data; - size_t Size; + const unsigned *Data = nullptr; + size_t Size = 0; public: - FoldingSetNodeIDRef() : Data(nullptr), Size(0) {} + FoldingSetNodeIDRef() = default; FoldingSetNodeIDRef(const unsigned *D, size_t S) : Data(D), Size(S) {} /// ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef, @@ -313,7 +319,7 @@ class FoldingSetNodeID { SmallVector<unsigned, 32> Bits; public: - FoldingSetNodeID() {} + FoldingSetNodeID() = default; FoldingSetNodeID(FoldingSetNodeIDRef Ref) : Bits(Ref.getData(), Ref.getData() + Ref.getSize()) {} @@ -418,6 +424,7 @@ private: T *TN = static_cast<T *>(N); FoldingSetTrait<T>::Profile(*TN, ID); } + /// NodeEquals - Instantiations may optionally provide a way to compare a /// node with a specified ID. bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash, @@ -425,6 +432,7 @@ private: T *TN = static_cast<T *>(N); return FoldingSetTrait<T>::Equals(*TN, ID, IDHash, TempID); } + /// ComputeNodeHash - Instantiations may optionally provide a way to compute a /// hash value directly from a node. unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const override { @@ -483,7 +491,7 @@ public: /// /// T must be a subclass of FoldingSetNode and implement a Profile /// function with signature -/// void Profile(llvm::FoldingSetNodeID &, Ctx); +/// void Profile(FoldingSetNodeID &, Ctx); template <class T, class Ctx> class ContextualFoldingSet final : public FoldingSetImpl { // Unfortunately, this can't derive from FoldingSet<T> because the @@ -501,12 +509,14 @@ private: T *TN = static_cast<T *>(N); ContextualFoldingSetTrait<T, Ctx>::Profile(*TN, ID, Context); } + bool NodeEquals(FoldingSetImpl::Node *N, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID) const override { T *TN = static_cast<T *>(N); return ContextualFoldingSetTrait<T, Ctx>::Equals(*TN, ID, IDHash, TempID, Context); } + unsigned ComputeNodeHash(FoldingSetImpl::Node *N, FoldingSetNodeID &TempID) const override { T *TN = static_cast<T *>(N); @@ -558,7 +568,7 @@ public: /// to provide the interface of FoldingSet but with deterministic iteration /// order based on the insertion order. T must be a subclass of FoldingSetNode /// and implement a Profile function. -template <class T, class VectorT = SmallVector<T*, 8> > +template <class T, class VectorT = SmallVector<T*, 8>> class FoldingSetVector { FoldingSet<T> Set; VectorT Vector; @@ -623,7 +633,9 @@ public: class FoldingSetIteratorImpl { protected: FoldingSetNode *NodePtr; + FoldingSetIteratorImpl(void **Bucket); + void advance(); public: @@ -754,11 +766,12 @@ template<typename T> struct FoldingSetTrait<T*> { template <typename T1, typename T2> struct FoldingSetTrait<std::pair<T1, T2>> { static inline void Profile(const std::pair<T1, T2> &P, - llvm::FoldingSetNodeID &ID) { + FoldingSetNodeID &ID) { ID.Add(P.first); ID.Add(P.second); } }; -} // End of namespace llvm. -#endif +} // end namespace llvm + +#endif // LLVM_ADT_FOLDINGSET_H diff --git a/llvm/include/llvm/ADT/ImmutableSet.h b/llvm/include/llvm/ADT/ImmutableSet.h index 87026f019fe..0724a28306a 100644 --- a/llvm/include/llvm/ADT/ImmutableSet.h +++ b/llvm/include/llvm/ADT/ImmutableSet.h @@ -16,12 +16,16 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/Allocator.h" -#include "llvm/Support/DataTypes.h" #include "llvm/Support/ErrorHandling.h" #include <cassert> #include <functional> #include <vector> +#include <cstdint> +#include <iterator> +#include <new> namespace llvm { @@ -329,11 +333,13 @@ private: public: void retain() { ++refCount; } + void release() { assert(refCount > 0); if (--refCount == 0) destroy(); } + void destroy() { if (left) left->release(); @@ -375,7 +381,7 @@ class ImutAVLFactory { std::vector<TreeTy*> freeNodes; bool ownsAllocator() const { - return Allocator & 0x1 ? false : true; + return (Allocator & 0x1) == 0; } BumpPtrAllocator& getAllocator() const { @@ -414,7 +420,6 @@ public: TreeTy* getEmptyTree() const { return nullptr; } protected: - //===--------------------------------------------------===// // A bunch of quick helper functions used for reasoning // about the properties of trees and their children. @@ -649,13 +654,14 @@ class ImutAVLTreeGenericIterator : public std::iterator<std::bidirectional_iterator_tag, ImutAVLTree<ImutInfo>> { SmallVector<uintptr_t,20> stack; + public: enum VisitFlag { VisitedNone=0x0, VisitedLeft=0x1, VisitedRight=0x3, Flags=0x3 }; typedef ImutAVLTree<ImutInfo> TreeTy; - ImutAVLTreeGenericIterator() {} + ImutAVLTreeGenericIterator() = default; ImutAVLTreeGenericIterator(const TreeTy *Root) { if (Root) stack.push_back(reinterpret_cast<uintptr_t>(Root)); } @@ -671,7 +677,6 @@ public: return stack.back() & Flags; } - bool atEnd() const { return stack.empty(); } bool atBeginning() const { @@ -881,7 +886,6 @@ struct ImutProfileInfo<bool> { } }; - /// Generic profile trait for pointer types. We treat pointers as /// references to unique objects. template <typename T> @@ -901,7 +905,6 @@ struct ImutProfileInfo<T*> { // for element profiling. //===----------------------------------------------------------------------===// - /// ImutContainerInfo - Generic definition of comparison operations for /// elements of immutable containers that defaults to using /// std::equal_to<> and std::less<> to perform comparison of elements. @@ -954,7 +957,7 @@ struct ImutContainerInfo<T*> : public ImutProfileInfo<T*> { // Immutable Set //===----------------------------------------------------------------------===// -template <typename ValT, typename ValInfo = ImutContainerInfo<ValT> > +template <typename ValT, typename ValInfo = ImutContainerInfo<ValT>> class ImmutableSet { public: typedef typename ValInfo::value_type value_type; @@ -972,9 +975,11 @@ public: explicit ImmutableSet(TreeTy* R) : Root(R) { if (Root) { Root->retain(); } } + ImmutableSet(const ImmutableSet &X) : Root(X.Root) { if (Root) { Root->retain(); } } + ImmutableSet &operator=(const ImmutableSet &X) { if (Root != X.Root) { if (X.Root) { X.Root->retain(); } @@ -983,6 +988,7 @@ public: } return *this; } + ~ImmutableSet() { if (Root) { Root->release(); } } @@ -998,6 +1004,9 @@ public: Factory(BumpPtrAllocator& Alloc, bool canonicalize = true) : F(Alloc), Canonicalize(canonicalize) {} + Factory(const Factory& RHS) = delete; + void operator=(const Factory& RHS) = delete; + /// getEmptySet - Returns an immutable set that contains no elements. ImmutableSet getEmptySet() { return ImmutableSet(F.getEmptyTree()); @@ -1032,10 +1041,6 @@ public: typename TreeTy::Factory *getTreeFactory() const { return const_cast<typename TreeTy::Factory *>(&F); } - - private: - Factory(const Factory& RHS) = delete; - void operator=(const Factory& RHS) = delete; }; friend class Factory; @@ -1104,7 +1109,7 @@ public: }; // NOTE: This may some day replace the current ImmutableSet. -template <typename ValT, typename ValInfo = ImutContainerInfo<ValT> > +template <typename ValT, typename ValInfo = ImutContainerInfo<ValT>> class ImmutableSetRef { public: typedef typename ValInfo::value_type value_type; @@ -1126,11 +1131,13 @@ public: Factory(F) { if (Root) { Root->retain(); } } + ImmutableSetRef(const ImmutableSetRef &X) : Root(X.Root), Factory(X.Factory) { if (Root) { Root->retain(); } } + ImmutableSetRef &operator=(const ImmutableSetRef &X) { if (Root != X.Root) { if (X.Root) { X.Root->retain(); } @@ -1215,4 +1222,4 @@ public: } // end namespace llvm -#endif +#endif // LLVM_ADT_IMMUTABLESET_H diff --git a/llvm/include/llvm/ADT/IntervalMap.h b/llvm/include/llvm/ADT/IntervalMap.h index 0dcf1266a2b..430b9671bd1 100644 --- a/llvm/include/llvm/ADT/IntervalMap.h +++ b/llvm/include/llvm/ADT/IntervalMap.h @@ -104,11 +104,14 @@ #include "llvm/Support/AlignOf.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/RecyclingAllocator.h" +#include <algorithm> +#include <cassert> #include <iterator> +#include <new> +#include <utility> namespace llvm { - //===----------------------------------------------------------------------===// //--- Key traits ---// //===----------------------------------------------------------------------===// @@ -131,7 +134,6 @@ namespace llvm { template <typename T> struct IntervalMapInfo { - /// startLess - Return true if x is not in [a;b]. /// This is x < a both for closed intervals and for [a;b) half-open intervals. static inline bool startLess(const T &x, const T &a) { @@ -155,12 +157,10 @@ struct IntervalMapInfo { static inline bool nonEmpty(const T &a, const T &b) { return a <= b; } - }; template <typename T> struct IntervalMapHalfOpenInfo { - /// startLess - Return true if x is not in [a;b). static inline bool startLess(const T &x, const T &a) { return x < a; @@ -180,20 +180,14 @@ struct IntervalMapHalfOpenInfo { static inline bool nonEmpty(const T &a, const T &b) { return a < b; } - }; /// IntervalMapImpl - Namespace used for IntervalMap implementation details. /// It should be considered private to the implementation. namespace IntervalMapImpl { -// Forward declarations. -template <typename, typename, unsigned, typename> class LeafNode; -template <typename, typename, unsigned, typename> class BranchNode; - typedef std::pair<unsigned,unsigned> IdxPair; - //===----------------------------------------------------------------------===// //--- IntervalMapImpl::NodeBase ---// //===----------------------------------------------------------------------===// @@ -417,7 +411,6 @@ IdxPair distribute(unsigned Nodes, unsigned Elements, unsigned Capacity, const unsigned *CurSize, unsigned NewSize[], unsigned Position, bool Grow); - //===----------------------------------------------------------------------===// //--- IntervalMapImpl::NodeSizer ---// //===----------------------------------------------------------------------===// @@ -470,10 +463,8 @@ struct NodeSizer { /// different kinds of maps. typedef RecyclingAllocator<BumpPtrAllocator, char, AllocBytes, CacheLineBytes> Allocator; - }; - //===----------------------------------------------------------------------===// //--- IntervalMapImpl::NodeRef ---// //===----------------------------------------------------------------------===// @@ -505,7 +496,7 @@ class NodeRef { public: /// NodeRef - Create a null ref. - NodeRef() {} + NodeRef() = default; /// operator bool - Detect a null ref. explicit operator bool() const { return pip.getOpaqueValue(); } @@ -685,7 +676,6 @@ insertFrom(unsigned &Pos, unsigned Size, KeyT a, KeyT b, ValT y) { return Size + 1; } - //===----------------------------------------------------------------------===// //--- IntervalMapImpl::BranchNode ---// //===----------------------------------------------------------------------===// @@ -930,8 +920,7 @@ public: } }; -} // namespace IntervalMapImpl - +} // end namespace IntervalMapImpl //===----------------------------------------------------------------------===// //--- IntervalMap ----// @@ -939,7 +928,7 @@ public: template <typename KeyT, typename ValT, unsigned N = IntervalMapImpl::NodeSizer<KeyT, ValT>::LeafSize, - typename Traits = IntervalMapInfo<KeyT> > + typename Traits = IntervalMapInfo<KeyT>> class IntervalMap { typedef IntervalMapImpl::NodeSizer<KeyT, ValT> Sizer; typedef IntervalMapImpl::LeafNode<KeyT, ValT, Sizer::LeafSize, Traits> Leaf; @@ -1006,6 +995,7 @@ private: assert(!branched() && "Cannot acces leaf data in branched root"); return dataAs<RootLeaf>(); } + RootBranchData &rootBranchData() const { assert(branched() && "Cannot access branch data in non-branched root"); return dataAs<RootBranchData>(); @@ -1014,6 +1004,7 @@ private: assert(branched() && "Cannot access branch data in non-branched root"); return dataAs<RootBranchData>(); } + const RootBranch &rootBranch() const { return rootBranchData().node; } RootBranch &rootBranch() { return rootBranchData().node; } KeyT rootBranchStart() const { return rootBranchData().start; } @@ -1160,7 +1151,6 @@ treeSafeLookup(KeyT x, ValT NotFound) const { return NR.get<Leaf>().safeLookup(x, NotFound); } - // branchRoot - Switch from a leaf root to a branched root. // Return the new (root offset, node offset) corresponding to Position. template <typename KeyT, typename ValT, unsigned N, typename Traits> @@ -1295,6 +1285,7 @@ clear() { template <typename KeyT, typename ValT, unsigned N, typename Traits> class IntervalMap<KeyT, ValT, N, Traits>::const_iterator : public std::iterator<std::bidirectional_iterator_tag, ValT> { + protected: friend class IntervalMap; @@ -1447,7 +1438,6 @@ public: path.leafOffset() = map->rootLeaf().findFrom(path.leafOffset(), map->rootSize, x); } - }; /// pathFillFind - Complete path by searching for x. @@ -1534,7 +1524,7 @@ class IntervalMap<KeyT, ValT, N, Traits>::iterator : public const_iterator { public: /// iterator - Create null iterator. - iterator() {} + iterator() = default; /// setStart - Move the start of the current interval. /// This may cause coalescing with the previous interval. @@ -1600,7 +1590,6 @@ public: operator--(); return tmp; } - }; /// canCoalesceLeft - Can the current interval coalesce to the left after @@ -1801,7 +1790,6 @@ iterator::insert(KeyT a, KeyT b, ValT y) { treeInsert(a, b, y); } - template <typename KeyT, typename ValT, unsigned N, typename Traits> void IntervalMap<KeyT, ValT, N, Traits>:: iterator::treeInsert(KeyT a, KeyT b, ValT y) { @@ -2162,6 +2150,6 @@ public: } }; -} // namespace llvm +} // end namespace llvm -#endif +#endif // LLVM_ADT_INTERVALMAP_H diff --git a/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h b/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h index 3417e9cf038..b0c2ce76a33 100644 --- a/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h +++ b/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h @@ -27,9 +27,6 @@ namespace llvm { - template <class T> - class IntrusiveRefCntPtr; - //===----------------------------------------------------------------------===// /// RefCountedBase - A generic base class for objects that wish to /// have their lifetimes managed using reference counts. Classes @@ -42,10 +39,10 @@ namespace llvm { //===----------------------------------------------------------------------===// template <class Derived> class RefCountedBase { - mutable unsigned ref_cnt; + mutable unsigned ref_cnt = 0; public: - RefCountedBase() : ref_cnt(0) {} + RefCountedBase() = default; RefCountedBase(const RefCountedBase &) : ref_cnt(0) {} void Retain() const { ++ref_cnt; } @@ -64,14 +61,15 @@ namespace llvm { /// attempting to do this will produce a compile error. //===----------------------------------------------------------------------===// class RefCountedBaseVPTR { - mutable unsigned ref_cnt; + mutable unsigned ref_cnt = 0; + virtual void anchor(); protected: - RefCountedBaseVPTR() : ref_cnt(0) {} + RefCountedBaseVPTR() = default; RefCountedBaseVPTR(const RefCountedBaseVPTR &) : ref_cnt(0) {} - virtual ~RefCountedBaseVPTR() {} + virtual ~RefCountedBaseVPTR() = default; void Retain() const { ++ref_cnt; } void Release() const { @@ -133,12 +131,12 @@ public: //===----------------------------------------------------------------------===// template <typename T> class IntrusiveRefCntPtr { - T* Obj; + T* Obj = nullptr; public: typedef T element_type; - explicit IntrusiveRefCntPtr() : Obj(nullptr) {} + explicit IntrusiveRefCntPtr() = default; IntrusiveRefCntPtr(T* obj) : Obj(obj) { retain(); @@ -269,14 +267,14 @@ public: template <typename From> struct simplify_type; - template<class T> struct simplify_type<IntrusiveRefCntPtr<T> > { + template<class T> struct simplify_type<IntrusiveRefCntPtr<T>> { typedef T* SimpleType; static SimpleType getSimplifiedValue(IntrusiveRefCntPtr<T>& Val) { return Val.get(); } }; - template<class T> struct simplify_type<const IntrusiveRefCntPtr<T> > { + template<class T> struct simplify_type<const IntrusiveRefCntPtr<T>> { typedef /*const*/ T* SimpleType; static SimpleType getSimplifiedValue(const IntrusiveRefCntPtr<T>& Val) { return Val.get(); diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h index 6b3fe5749ad..a8ac18645f3 100644 --- a/llvm/include/llvm/ADT/PointerUnion.h +++ b/llvm/include/llvm/ADT/PointerUnion.h @@ -17,7 +17,10 @@ #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/PointerIntPair.h" -#include "llvm/Support/Compiler.h" +#include "llvm/Support/PointerLikeTypeTraits.h" +#include <cassert> +#include <cstdint> +#include <cstddef> namespace llvm { @@ -57,6 +60,7 @@ template <typename PT1, typename PT2> class PointerUnionUIntTraits { public: static inline void *getAsVoidPointer(void *P) { return P; } static inline void *getFromVoidPointer(void *P) { return P; } + enum { PT1BitsAv = (int)(PointerLikeTypeTraits<PT1>::NumLowBitsAvailable), PT2BitsAv = (int)(PointerLikeTypeTraits<PT2>::NumLowBitsAvailable), @@ -97,7 +101,7 @@ private: template <typename T> struct UNION_DOESNT_CONTAIN_TYPE {}; public: - PointerUnion() {} + PointerUnion() = default; PointerUnion(PT1 V) : Val(const_cast<void *>( @@ -208,6 +212,7 @@ public: static inline void *getAsVoidPointer(const PointerUnion<PT1, PT2> &P) { return P.getOpaqueValue(); } + static inline PointerUnion<PT1, PT2> getFromVoidPointer(void *P) { return PointerUnion<PT1, PT2>::getFromOpaqueValue(P); } @@ -249,7 +254,7 @@ private: }; public: - PointerUnion3() {} + PointerUnion3() = default; PointerUnion3(PT1 V) { Val = InnerUnion(V); } PointerUnion3(PT2 V) { Val = InnerUnion(V); } @@ -328,6 +333,7 @@ public: static inline void *getAsVoidPointer(const PointerUnion3<PT1, PT2, PT3> &P) { return P.getOpaqueValue(); } + static inline PointerUnion3<PT1, PT2, PT3> getFromVoidPointer(void *P) { return PointerUnion3<PT1, PT2, PT3>::getFromOpaqueValue(P); } @@ -352,7 +358,7 @@ private: ValTy Val; public: - PointerUnion4() {} + PointerUnion4() = default; PointerUnion4(PT1 V) { Val = InnerUnion1(V); } PointerUnion4(PT2 V) { Val = InnerUnion1(V); } @@ -435,6 +441,7 @@ public: getAsVoidPointer(const PointerUnion4<PT1, PT2, PT3, PT4> &P) { return P.getOpaqueValue(); } + static inline PointerUnion4<PT1, PT2, PT3, PT4> getFromVoidPointer(void *P) { return PointerUnion4<PT1, PT2, PT3, PT4>::getFromOpaqueValue(P); } @@ -469,6 +476,6 @@ template <typename T, typename U> struct DenseMapInfo<PointerUnion<T, U>> { } }; -} +} // end namespace llvm -#endif +#endif // LLVM_ADT_POINTERUNION_H diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h index e569f54481a..ff46e85ccb0 100644 --- a/llvm/include/llvm/ADT/SmallString.h +++ b/llvm/include/llvm/ADT/SmallString.h @@ -16,6 +16,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include <cstddef> namespace llvm { @@ -25,7 +26,7 @@ template<unsigned InternalLen> class SmallString : public SmallVector<char, InternalLen> { public: /// Default ctor - Initialize to empty. - SmallString() {} + SmallString() = default; /// Initialize from a StringRef. SmallString(StringRef S) : SmallVector<char, InternalLen>(S.begin(), S.end()) {} @@ -79,7 +80,6 @@ public: SmallVectorImpl<char>::append(NumInputs, Elt); } - /// Append from a StringRef. void append(StringRef RHS) { SmallVectorImpl<char>::append(RHS.begin(), RHS.end()); @@ -292,6 +292,6 @@ public: } }; -} +} // end namespace llvm -#endif +#endif // LLVM_ADT_SMALLSTRING_H diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h index 8bb7ef05b96..24e3ecf71b1 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h @@ -17,10 +17,17 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/PointerLikeTypeTraits.h" +#include <cassert> +#include <cstdint> +#include <cstdlib> #include <cstring> #include <utility> +#include <initializer_list> +#include <new> +#include <utility> namespace llvm { + template<typename ValueT> class StringMapConstIterator; template<typename ValueT> @@ -119,8 +126,6 @@ public: /// and data. template<typename ValueTy> class StringMapEntry : public StringMapEntryBase { - StringMapEntry(StringMapEntry &E) = delete; - public: ValueTy second; @@ -129,6 +134,7 @@ public: template <typename... InitTy> StringMapEntry(unsigned strLen, InitTy &&... InitVals) : StringMapEntryBase(strLen), second(std::forward<InitTy>(InitVals)...) {} + StringMapEntry(StringMapEntry &E) = delete; StringRef getKey() const { return StringRef(getKeyData(), getKeyLength()); @@ -440,12 +446,12 @@ public: template <typename ValueTy> class StringMapConstIterator { protected: - StringMapEntryBase **Ptr; + StringMapEntryBase **Ptr = nullptr; public: typedef StringMapEntry<ValueTy> value_type; - StringMapConstIterator() : Ptr(nullptr) { } + StringMapConstIterator() = default; explicit StringMapConstIterator(StringMapEntryBase **Bucket, bool NoAdvance = false) @@ -486,11 +492,13 @@ private: template<typename ValueTy> class StringMapIterator : public StringMapConstIterator<ValueTy> { public: - StringMapIterator() {} + StringMapIterator() = default; + explicit StringMapIterator(StringMapEntryBase **Bucket, bool NoAdvance = false) : StringMapConstIterator<ValueTy>(Bucket, NoAdvance) { } + StringMapEntry<ValueTy> &operator*() const { return *static_cast<StringMapEntry<ValueTy>*>(*this->Ptr); } @@ -498,6 +506,7 @@ public: return static_cast<StringMapEntry<ValueTy>*>(*this->Ptr); } }; -} -#endif +} // end namespace llvm + +#endif // LLVM_ADT_STRINGMAP_H diff --git a/llvm/include/llvm/ADT/iterator.h b/llvm/include/llvm/ADT/iterator.h index 6a70545f0e0..9ccacc10db0 100644 --- a/llvm/include/llvm/ADT/iterator.h +++ b/llvm/include/llvm/ADT/iterator.h @@ -12,6 +12,7 @@ #include <cstddef> #include <iterator> +#include <type_traits> namespace llvm { @@ -264,7 +265,7 @@ class pointer_iterator mutable T Ptr; public: - pointer_iterator() {} + pointer_iterator() = default; explicit pointer_iterator(WrappedIteratorT u) : pointer_iterator::iterator_adaptor_base(std::move(u)) {} @@ -273,6 +274,6 @@ public: const T &operator*() const { return Ptr = &*this->I; } }; -} // namespace llvm +} // end namespace llvm -#endif +#endif // LLVM_ADT_ITERATOR_H |

