From becb428e092920d3c7f9ec7a20eee6201bdb1ed3 Mon Sep 17 00:00:00 2001 From: Eugene Zelenko Date: Wed, 23 Nov 2016 00:30:24 +0000 Subject: [PATCH] [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 --- include/llvm/ADT/DAGDeltaAlgorithm.h | 6 +++-- include/llvm/ADT/DepthFirstIterator.h | 16 ++++++----- include/llvm/ADT/EquivalenceClasses.h | 17 +++++++----- include/llvm/ADT/FoldingSet.h | 39 ++++++++++++++++++--------- include/llvm/ADT/ImmutableSet.h | 35 ++++++++++++++---------- include/llvm/ADT/IntervalMap.h | 38 +++++++++----------------- include/llvm/ADT/IntrusiveRefCntPtr.h | 22 +++++++-------- include/llvm/ADT/PointerUnion.h | 19 ++++++++----- include/llvm/ADT/SmallString.h | 8 +++--- include/llvm/ADT/StringMap.h | 23 +++++++++++----- include/llvm/ADT/iterator.h | 7 ++--- 11 files changed, 130 insertions(+), 100 deletions(-) diff --git a/include/llvm/ADT/DAGDeltaAlgorithm.h b/include/llvm/ADT/DAGDeltaAlgorithm.h index 3dd862c8b22..5ea0fe87286 100644 --- a/include/llvm/ADT/DAGDeltaAlgorithm.h +++ b/include/llvm/ADT/DAGDeltaAlgorithm.h @@ -10,6 +10,7 @@ #define LLVM_ADT_DAGDELTAALGORITHM_H #include +#include #include namespace llvm { @@ -37,6 +38,7 @@ namespace llvm { /// should satisfy. class DAGDeltaAlgorithm { virtual void anchor(); + public: typedef unsigned change_ty; typedef std::pair edge_ty; @@ -46,7 +48,7 @@ public: typedef std::vector 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/include/llvm/ADT/DepthFirstIterator.h b/include/llvm/ADT/DepthFirstIterator.h index 634438d9e2b..c5457320458 100644 --- a/include/llvm/ADT/DepthFirstIterator.h +++ b/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 #include +#include #include namespace llvm { @@ -55,6 +58,7 @@ class df_iterator_storage { 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 -struct df_iterator_default_set : public llvm::SmallPtrSet { - typedef llvm::SmallPtrSet BaseSet; +struct df_iterator_default_set : public SmallPtrSet { + typedef SmallPtrSet BaseSet; typedef typename BaseSet::iterator iterator; std::pair insert(NodeRef N) { return BaseSet::insert(N) ; } template @@ -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(S) { if (this->Visited.insert(Node).second) @@ -298,6 +300,6 @@ iterator_range> 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/include/llvm/ADT/EquivalenceClasses.h b/include/llvm/ADT/EquivalenceClasses.h index d6a26f88e67..8fcac178ffc 100644 --- a/include/llvm/ADT/EquivalenceClasses.h +++ b/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 #include +#include +#include #include 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 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/include/llvm/ADT/FoldingSet.h b/include/llvm/ADT/FoldingSet.h index f16258af4ae..dab18297dd3 100644 --- a/include/llvm/ADT/FoldingSet.h +++ b/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 +#include +#include +#include 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 struct FoldingSetTrait; - /// DefaultFoldingSetTrait - This class provides default implementations /// for FoldingSetTrait implementations. /// @@ -252,8 +259,6 @@ template struct DefaultFoldingSetTrait { template struct FoldingSetTrait : public DefaultFoldingSetTrait {}; -template struct ContextualFoldingSetTrait; - /// DefaultContextualFoldingSetTrait - Like DefaultFoldingSetTrait, but /// for ContextualFoldingSets. template @@ -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 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 Bits; public: - FoldingSetNodeID() {} + FoldingSetNodeID() = default; FoldingSetNodeID(FoldingSetNodeIDRef Ref) : Bits(Ref.getData(), Ref.getData() + Ref.getSize()) {} @@ -418,6 +424,7 @@ private: T *TN = static_cast(N); FoldingSetTrait::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(N); return FoldingSetTrait::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 ContextualFoldingSet final : public FoldingSetImpl { // Unfortunately, this can't derive from FoldingSet because the @@ -501,12 +509,14 @@ private: T *TN = static_cast(N); ContextualFoldingSetTrait::Profile(*TN, ID, Context); } + bool NodeEquals(FoldingSetImpl::Node *N, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID) const override { T *TN = static_cast(N); return ContextualFoldingSetTrait::Equals(*TN, ID, IDHash, TempID, Context); } + unsigned ComputeNodeHash(FoldingSetImpl::Node *N, FoldingSetNodeID &TempID) const override { T *TN = static_cast(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 > +template > class FoldingSetVector { FoldingSet Set; VectorT Vector; @@ -623,7 +633,9 @@ public: class FoldingSetIteratorImpl { protected: FoldingSetNode *NodePtr; + FoldingSetIteratorImpl(void **Bucket); + void advance(); public: @@ -754,11 +766,12 @@ template struct FoldingSetTrait { template struct FoldingSetTrait> { static inline void Profile(const std::pair &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/include/llvm/ADT/ImmutableSet.h b/include/llvm/ADT/ImmutableSet.h index 87026f019fe..0724a28306a 100644 --- a/include/llvm/ADT/ImmutableSet.h +++ b/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 #include #include +#include +#include +#include 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 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> { SmallVector stack; + public: enum VisitFlag { VisitedNone=0x0, VisitedLeft=0x1, VisitedRight=0x3, Flags=0x3 }; typedef ImutAVLTree TreeTy; - ImutAVLTreeGenericIterator() {} + ImutAVLTreeGenericIterator() = default; ImutAVLTreeGenericIterator(const TreeTy *Root) { if (Root) stack.push_back(reinterpret_cast(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 { } }; - /// Generic profile trait for pointer types. We treat pointers as /// references to unique objects. template @@ -901,7 +905,6 @@ struct ImutProfileInfo { // 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 : public ImutProfileInfo { // Immutable Set //===----------------------------------------------------------------------===// -template > +template > 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(&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 > +template > 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/include/llvm/ADT/IntervalMap.h b/include/llvm/ADT/IntervalMap.h index 0dcf1266a2b..430b9671bd1 100644 --- a/include/llvm/ADT/IntervalMap.h +++ b/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 +#include #include +#include +#include namespace llvm { - //===----------------------------------------------------------------------===// //--- Key traits ---// //===----------------------------------------------------------------------===// @@ -131,7 +134,6 @@ namespace llvm { template 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 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 class LeafNode; -template class BranchNode; - typedef std::pair 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 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 ::LeafSize, - typename Traits = IntervalMapInfo > + typename Traits = IntervalMapInfo> class IntervalMap { typedef IntervalMapImpl::NodeSizer Sizer; typedef IntervalMapImpl::LeafNode Leaf; @@ -1006,6 +995,7 @@ private: assert(!branched() && "Cannot acces leaf data in branched root"); return dataAs(); } + RootBranchData &rootBranchData() const { assert(branched() && "Cannot access branch data in non-branched root"); return dataAs(); @@ -1014,6 +1004,7 @@ private: assert(branched() && "Cannot access branch data in non-branched root"); return dataAs(); } + 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().safeLookup(x, NotFound); } - // branchRoot - Switch from a leaf root to a branched root. // Return the new (root offset, node offset) corresponding to Position. template @@ -1295,6 +1285,7 @@ clear() { template class IntervalMap::const_iterator : public std::iterator { + 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::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 void IntervalMap:: 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/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h index 3417e9cf038..b0c2ce76a33 100644 --- a/include/llvm/ADT/IntrusiveRefCntPtr.h +++ b/include/llvm/ADT/IntrusiveRefCntPtr.h @@ -27,9 +27,6 @@ namespace llvm { - template - 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 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 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 struct simplify_type; - template struct simplify_type > { + template struct simplify_type> { typedef T* SimpleType; static SimpleType getSimplifiedValue(IntrusiveRefCntPtr& Val) { return Val.get(); } }; - template struct simplify_type > { + template struct simplify_type> { typedef /*const*/ T* SimpleType; static SimpleType getSimplifiedValue(const IntrusiveRefCntPtr& Val) { return Val.get(); diff --git a/include/llvm/ADT/PointerUnion.h b/include/llvm/ADT/PointerUnion.h index 6b3fe5749ad..a8ac18645f3 100644 --- a/include/llvm/ADT/PointerUnion.h +++ b/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 +#include +#include namespace llvm { @@ -57,6 +60,7 @@ template class PointerUnionUIntTraits { public: static inline void *getAsVoidPointer(void *P) { return P; } static inline void *getFromVoidPointer(void *P) { return P; } + enum { PT1BitsAv = (int)(PointerLikeTypeTraits::NumLowBitsAvailable), PT2BitsAv = (int)(PointerLikeTypeTraits::NumLowBitsAvailable), @@ -97,7 +101,7 @@ private: template struct UNION_DOESNT_CONTAIN_TYPE {}; public: - PointerUnion() {} + PointerUnion() = default; PointerUnion(PT1 V) : Val(const_cast( @@ -208,6 +212,7 @@ public: static inline void *getAsVoidPointer(const PointerUnion &P) { return P.getOpaqueValue(); } + static inline PointerUnion getFromVoidPointer(void *P) { return PointerUnion::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 &P) { return P.getOpaqueValue(); } + static inline PointerUnion3 getFromVoidPointer(void *P) { return PointerUnion3::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 &P) { return P.getOpaqueValue(); } + static inline PointerUnion4 getFromVoidPointer(void *P) { return PointerUnion4::getFromOpaqueValue(P); } @@ -469,6 +476,6 @@ template struct DenseMapInfo> { } }; -} +} // end namespace llvm -#endif +#endif // LLVM_ADT_POINTERUNION_H diff --git a/include/llvm/ADT/SmallString.h b/include/llvm/ADT/SmallString.h index e569f54481a..ff46e85ccb0 100644 --- a/include/llvm/ADT/SmallString.h +++ b/include/llvm/ADT/SmallString.h @@ -16,6 +16,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include namespace llvm { @@ -25,7 +26,7 @@ template class SmallString : public SmallVector { public: /// Default ctor - Initialize to empty. - SmallString() {} + SmallString() = default; /// Initialize from a StringRef. SmallString(StringRef S) : SmallVector(S.begin(), S.end()) {} @@ -79,7 +80,6 @@ public: SmallVectorImpl::append(NumInputs, Elt); } - /// Append from a StringRef. void append(StringRef RHS) { SmallVectorImpl::append(RHS.begin(), RHS.end()); @@ -292,6 +292,6 @@ public: } }; -} +} // end namespace llvm -#endif +#endif // LLVM_ADT_SMALLSTRING_H diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index 8bb7ef05b96..24e3ecf71b1 100644 --- a/include/llvm/ADT/StringMap.h +++ b/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 +#include +#include #include #include +#include +#include +#include namespace llvm { + template class StringMapConstIterator; template @@ -119,8 +126,6 @@ public: /// and data. template class StringMapEntry : public StringMapEntryBase { - StringMapEntry(StringMapEntry &E) = delete; - public: ValueTy second; @@ -129,6 +134,7 @@ public: template StringMapEntry(unsigned strLen, InitTy &&... InitVals) : StringMapEntryBase(strLen), second(std::forward(InitVals)...) {} + StringMapEntry(StringMapEntry &E) = delete; StringRef getKey() const { return StringRef(getKeyData(), getKeyLength()); @@ -440,12 +446,12 @@ public: template class StringMapConstIterator { protected: - StringMapEntryBase **Ptr; + StringMapEntryBase **Ptr = nullptr; public: typedef StringMapEntry value_type; - StringMapConstIterator() : Ptr(nullptr) { } + StringMapConstIterator() = default; explicit StringMapConstIterator(StringMapEntryBase **Bucket, bool NoAdvance = false) @@ -486,11 +492,13 @@ private: template class StringMapIterator : public StringMapConstIterator { public: - StringMapIterator() {} + StringMapIterator() = default; + explicit StringMapIterator(StringMapEntryBase **Bucket, bool NoAdvance = false) : StringMapConstIterator(Bucket, NoAdvance) { } + StringMapEntry &operator*() const { return *static_cast*>(*this->Ptr); } @@ -498,6 +506,7 @@ public: return static_cast*>(*this->Ptr); } }; -} -#endif +} // end namespace llvm + +#endif // LLVM_ADT_STRINGMAP_H diff --git a/include/llvm/ADT/iterator.h b/include/llvm/ADT/iterator.h index 6a70545f0e0..9ccacc10db0 100644 --- a/include/llvm/ADT/iterator.h +++ b/include/llvm/ADT/iterator.h @@ -12,6 +12,7 @@ #include #include +#include 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