1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[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
This commit is contained in:
Eugene Zelenko 2016-11-23 00:30:24 +00:00
parent abe4ee5498
commit becb428e09
11 changed files with 130 additions and 100 deletions

View File

@ -10,6 +10,7 @@
#define LLVM_ADT_DAGDELTAALGORITHM_H #define LLVM_ADT_DAGDELTAALGORITHM_H
#include <set> #include <set>
#include <utility>
#include <vector> #include <vector>
namespace llvm { namespace llvm {
@ -37,6 +38,7 @@ namespace llvm {
/// should satisfy. /// should satisfy.
class DAGDeltaAlgorithm { class DAGDeltaAlgorithm {
virtual void anchor(); virtual void anchor();
public: public:
typedef unsigned change_ty; typedef unsigned change_ty;
typedef std::pair<change_ty, change_ty> edge_ty; typedef std::pair<change_ty, change_ty> edge_ty;
@ -46,7 +48,7 @@ public:
typedef std::vector<changeset_ty> changesetlist_ty; typedef std::vector<changeset_ty> changesetlist_ty;
public: public:
virtual ~DAGDeltaAlgorithm() {} virtual ~DAGDeltaAlgorithm() = default;
/// Run - Minimize the DAG formed by the \p Changes vertices and the /// Run - Minimize the DAG formed by the \p Changes vertices and the
/// \p Dependencies edges by executing \see ExecuteOneTest() on subsets of /// \p Dependencies edges by executing \see ExecuteOneTest() on subsets of
@ -74,4 +76,4 @@ public:
} // end namespace llvm } // end namespace llvm
#endif #endif // LLVM_ADT_DAGDELTAALGORITHM_H

View File

@ -34,10 +34,13 @@
#define LLVM_ADT_DEPTHFIRSTITERATOR_H #define LLVM_ADT_DEPTHFIRSTITERATOR_H
#include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h" #include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/iterator_range.h"
#include <iterator>
#include <set> #include <set>
#include <utility>
#include <vector> #include <vector>
namespace llvm { namespace llvm {
@ -55,6 +58,7 @@ class df_iterator_storage<SetType, true> {
public: public:
df_iterator_storage(SetType &VSet) : Visited(VSet) {} df_iterator_storage(SetType &VSet) : Visited(VSet) {}
df_iterator_storage(const df_iterator_storage &S) : Visited(S.Visited) {} df_iterator_storage(const df_iterator_storage &S) : Visited(S.Visited) {}
SetType &Visited; SetType &Visited;
}; };
@ -63,8 +67,8 @@ public:
// node have been processed. It is intended to distinguish of back and // 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. // cross edges in the spanning tree but is not used in the common case.
template <typename NodeRef, unsigned SmallSize=8> template <typename NodeRef, unsigned SmallSize=8>
struct df_iterator_default_set : public llvm::SmallPtrSet<NodeRef, SmallSize> { struct df_iterator_default_set : public SmallPtrSet<NodeRef, SmallSize> {
typedef llvm::SmallPtrSet<NodeRef, SmallSize> BaseSet; typedef SmallPtrSet<NodeRef, SmallSize> BaseSet;
typedef typename BaseSet::iterator iterator; typedef typename BaseSet::iterator iterator;
std::pair<iterator,bool> insert(NodeRef N) { return BaseSet::insert(N) ; } std::pair<iterator,bool> insert(NodeRef N) { return BaseSet::insert(N) ; }
template <typename IterT> template <typename IterT>
@ -99,9 +103,7 @@ private:
this->Visited.insert(Node); this->Visited.insert(Node);
VisitStack.push_back(StackElement(Node, None)); VisitStack.push_back(StackElement(Node, None));
} }
inline df_iterator() { inline df_iterator() = default; // End is when stack is empty
// End is when stack is empty
}
inline df_iterator(NodeRef Node, SetType &S) inline df_iterator(NodeRef Node, SetType &S)
: df_iterator_storage<SetType, ExtStorage>(S) { : df_iterator_storage<SetType, ExtStorage>(S) {
if (this->Visited.insert(Node).second) 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)); 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

View File

@ -15,9 +15,10 @@
#ifndef LLVM_ADT_EQUIVALENCECLASSES_H #ifndef LLVM_ADT_EQUIVALENCECLASSES_H
#define LLVM_ADT_EQUIVALENCECLASSES_H #define LLVM_ADT_EQUIVALENCECLASSES_H
#include "llvm/Support/DataTypes.h"
#include <cassert> #include <cassert>
#include <cstddef> #include <cstddef>
#include <cstdint>
#include <iterator>
#include <set> #include <set>
namespace llvm { namespace llvm {
@ -70,6 +71,7 @@ class EquivalenceClasses {
friend class EquivalenceClasses; friend class EquivalenceClasses;
mutable const ECValue *Leader, *Next; mutable const ECValue *Leader, *Next;
ElemTy Data; ElemTy Data;
// ECValue ctor - Start out with EndOfList pointing to this node, Next is // ECValue ctor - Start out with EndOfList pointing to this node, Next is
// Null, isLeader = true. // Null, isLeader = true.
ECValue(const ElemTy &Elt) ECValue(const ElemTy &Elt)
@ -81,6 +83,7 @@ class EquivalenceClasses {
// Path compression. // Path compression.
return Leader = Leader->getLeader(); return Leader = Leader->getLeader();
} }
const ECValue *getEndOfList() const { const ECValue *getEndOfList() const {
assert(isLeader() && "Cannot get the end of a list for a non-leader!"); assert(isLeader() && "Cannot get the end of a list for a non-leader!");
return Leader; return Leader;
@ -90,6 +93,7 @@ class EquivalenceClasses {
assert(getNext() == nullptr && "Already has a next pointer!"); assert(getNext() == nullptr && "Already has a next pointer!");
Next = (const ECValue*)((intptr_t)NewNext | (intptr_t)isLeader()); Next = (const ECValue*)((intptr_t)NewNext | (intptr_t)isLeader());
} }
public: public:
ECValue(const ECValue &RHS) : Leader(this), Next((ECValue*)(intptr_t)1), ECValue(const ECValue &RHS) : Leader(this), Next((ECValue*)(intptr_t)1),
Data(RHS.Data) { Data(RHS.Data) {
@ -115,7 +119,7 @@ class EquivalenceClasses {
std::set<ECValue> TheMapping; std::set<ECValue> TheMapping;
public: public:
EquivalenceClasses() {} EquivalenceClasses() = default;
EquivalenceClasses(const EquivalenceClasses &RHS) { EquivalenceClasses(const EquivalenceClasses &RHS) {
operator=(RHS); operator=(RHS);
} }
@ -187,7 +191,6 @@ public:
return NC; return NC;
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Mutation methods // Mutation methods
@ -210,7 +213,6 @@ public:
return findLeader(TheMapping.find(V)); return findLeader(TheMapping.find(V));
} }
/// union - Merge the two equivalence sets for the specified values, inserting /// union - Merge the two equivalence sets for the specified values, inserting
/// them if they do not already exist in the equivalence set. /// them if they do not already exist in the equivalence set.
member_iterator unionSets(const ElemTy &V1, const ElemTy &V2) { member_iterator unionSets(const ElemTy &V1, const ElemTy &V2) {
@ -243,12 +245,13 @@ public:
const ElemTy, ptrdiff_t> super; const ElemTy, ptrdiff_t> super;
const ECValue *Node; const ECValue *Node;
friend class EquivalenceClasses; friend class EquivalenceClasses;
public: public:
typedef size_t size_type; typedef size_t size_type;
typedef typename super::pointer pointer; typedef typename super::pointer pointer;
typedef typename super::reference reference; typedef typename super::reference reference;
explicit member_iterator() {} explicit member_iterator() = default;
explicit member_iterator(const ECValue *N) : Node(N) {} explicit member_iterator(const ECValue *N) : Node(N) {}
reference operator*() const { reference operator*() const {
@ -278,6 +281,6 @@ public:
}; };
}; };
} // End llvm namespace } // end namespace llvm
#endif #endif // LLVM_ADT_EQUIVALENCECLASSES_H

View File

@ -19,8 +19,13 @@
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator.h"
#include "llvm/Support/Allocator.h" #include "llvm/Support/Allocator.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <utility>
namespace llvm { namespace llvm {
/// This folding set used for two purposes: /// This folding set used for two purposes:
/// 1. Given information about a node we want to create, look up the unique /// 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 /// 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 /// EltCount-th node won't cause a rebucket operation. reserve is permitted
/// to allocate more space than requested by EltCount. /// to allocate more space than requested by EltCount.
void reserve(unsigned EltCount); void reserve(unsigned EltCount);
/// capacity - Returns the number of nodes permitted in the folding set /// capacity - Returns the number of nodes permitted in the folding set
/// before a rebucket operation is performed. /// before a rebucket operation is performed.
unsigned capacity() { unsigned capacity() {
@ -200,14 +206,17 @@ private:
/// NewBucketCount must be a power of two, and must be greater than the old /// NewBucketCount must be a power of two, and must be greater than the old
/// bucket count. /// bucket count.
void GrowBucketCount(unsigned NewBucketCount); void GrowBucketCount(unsigned NewBucketCount);
protected: protected:
/// GetNodeProfile - Instantiations of the FoldingSet template implement /// GetNodeProfile - Instantiations of the FoldingSet template implement
/// this function to gather data bits for the given node. /// this function to gather data bits for the given node.
virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const = 0; virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const = 0;
/// NodeEquals - Instantiations of the FoldingSet template implement /// NodeEquals - Instantiations of the FoldingSet template implement
/// this function to compare the given node with the given ID. /// this function to compare the given node with the given ID.
virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash, virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash,
FoldingSetNodeID &TempID) const=0; FoldingSetNodeID &TempID) const=0;
/// ComputeNodeHash - Instantiations of the FoldingSet template implement /// ComputeNodeHash - Instantiations of the FoldingSet template implement
/// this function to compute a hash value for the given node. /// this function to compute a hash value for the given node.
virtual unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const = 0; 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 /// DefaultFoldingSetTrait - This class provides default implementations
/// for FoldingSetTrait implementations. /// for FoldingSetTrait implementations.
/// ///
@ -252,8 +259,6 @@ template<typename T> struct DefaultFoldingSetTrait {
template<typename T> struct FoldingSetTrait template<typename T> struct FoldingSetTrait
: public DefaultFoldingSetTrait<T> {}; : public DefaultFoldingSetTrait<T> {};
template<typename T, typename Ctx> struct ContextualFoldingSetTrait;
/// DefaultContextualFoldingSetTrait - Like DefaultFoldingSetTrait, but /// DefaultContextualFoldingSetTrait - Like DefaultFoldingSetTrait, but
/// for ContextualFoldingSets. /// for ContextualFoldingSets.
template<typename T, typename Ctx> template<typename T, typename Ctx>
@ -261,6 +266,7 @@ struct DefaultContextualFoldingSetTrait {
static void Profile(T &X, FoldingSetNodeID &ID, Ctx Context) { static void Profile(T &X, FoldingSetNodeID &ID, Ctx Context) {
X.Profile(ID, Context); X.Profile(ID, Context);
} }
static inline bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash, static inline bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash,
FoldingSetNodeID &TempID, Ctx Context); FoldingSetNodeID &TempID, Ctx Context);
static inline unsigned ComputeHash(T &X, FoldingSetNodeID &TempID, 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 /// is often much larger than necessary, and the possibility of heap
/// allocation means it requires a non-trivial destructor call. /// allocation means it requires a non-trivial destructor call.
class FoldingSetNodeIDRef { class FoldingSetNodeIDRef {
const unsigned *Data; const unsigned *Data = nullptr;
size_t Size; size_t Size = 0;
public: public:
FoldingSetNodeIDRef() : Data(nullptr), Size(0) {} FoldingSetNodeIDRef() = default;
FoldingSetNodeIDRef(const unsigned *D, size_t S) : Data(D), Size(S) {} FoldingSetNodeIDRef(const unsigned *D, size_t S) : Data(D), Size(S) {}
/// ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef, /// ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef,
@ -313,7 +319,7 @@ class FoldingSetNodeID {
SmallVector<unsigned, 32> Bits; SmallVector<unsigned, 32> Bits;
public: public:
FoldingSetNodeID() {} FoldingSetNodeID() = default;
FoldingSetNodeID(FoldingSetNodeIDRef Ref) FoldingSetNodeID(FoldingSetNodeIDRef Ref)
: Bits(Ref.getData(), Ref.getData() + Ref.getSize()) {} : Bits(Ref.getData(), Ref.getData() + Ref.getSize()) {}
@ -418,6 +424,7 @@ private:
T *TN = static_cast<T *>(N); T *TN = static_cast<T *>(N);
FoldingSetTrait<T>::Profile(*TN, ID); FoldingSetTrait<T>::Profile(*TN, ID);
} }
/// NodeEquals - Instantiations may optionally provide a way to compare a /// NodeEquals - Instantiations may optionally provide a way to compare a
/// node with a specified ID. /// node with a specified ID.
bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash, bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash,
@ -425,6 +432,7 @@ private:
T *TN = static_cast<T *>(N); T *TN = static_cast<T *>(N);
return FoldingSetTrait<T>::Equals(*TN, ID, IDHash, TempID); return FoldingSetTrait<T>::Equals(*TN, ID, IDHash, TempID);
} }
/// ComputeNodeHash - Instantiations may optionally provide a way to compute a /// ComputeNodeHash - Instantiations may optionally provide a way to compute a
/// hash value directly from a node. /// hash value directly from a node.
unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const override { unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const override {
@ -483,7 +491,7 @@ public:
/// ///
/// T must be a subclass of FoldingSetNode and implement a Profile /// T must be a subclass of FoldingSetNode and implement a Profile
/// function with signature /// function with signature
/// void Profile(llvm::FoldingSetNodeID &, Ctx); /// void Profile(FoldingSetNodeID &, Ctx);
template <class T, class Ctx> template <class T, class Ctx>
class ContextualFoldingSet final : public FoldingSetImpl { class ContextualFoldingSet final : public FoldingSetImpl {
// Unfortunately, this can't derive from FoldingSet<T> because the // Unfortunately, this can't derive from FoldingSet<T> because the
@ -501,12 +509,14 @@ private:
T *TN = static_cast<T *>(N); T *TN = static_cast<T *>(N);
ContextualFoldingSetTrait<T, Ctx>::Profile(*TN, ID, Context); ContextualFoldingSetTrait<T, Ctx>::Profile(*TN, ID, Context);
} }
bool NodeEquals(FoldingSetImpl::Node *N, const FoldingSetNodeID &ID, bool NodeEquals(FoldingSetImpl::Node *N, const FoldingSetNodeID &ID,
unsigned IDHash, FoldingSetNodeID &TempID) const override { unsigned IDHash, FoldingSetNodeID &TempID) const override {
T *TN = static_cast<T *>(N); T *TN = static_cast<T *>(N);
return ContextualFoldingSetTrait<T, Ctx>::Equals(*TN, ID, IDHash, TempID, return ContextualFoldingSetTrait<T, Ctx>::Equals(*TN, ID, IDHash, TempID,
Context); Context);
} }
unsigned ComputeNodeHash(FoldingSetImpl::Node *N, unsigned ComputeNodeHash(FoldingSetImpl::Node *N,
FoldingSetNodeID &TempID) const override { FoldingSetNodeID &TempID) const override {
T *TN = static_cast<T *>(N); T *TN = static_cast<T *>(N);
@ -623,7 +633,9 @@ public:
class FoldingSetIteratorImpl { class FoldingSetIteratorImpl {
protected: protected:
FoldingSetNode *NodePtr; FoldingSetNode *NodePtr;
FoldingSetIteratorImpl(void **Bucket); FoldingSetIteratorImpl(void **Bucket);
void advance(); void advance();
public: public:
@ -754,11 +766,12 @@ template<typename T> struct FoldingSetTrait<T*> {
template <typename T1, typename T2> template <typename T1, typename T2>
struct FoldingSetTrait<std::pair<T1, T2>> { struct FoldingSetTrait<std::pair<T1, T2>> {
static inline void Profile(const std::pair<T1, T2> &P, static inline void Profile(const std::pair<T1, T2> &P,
llvm::FoldingSetNodeID &ID) { FoldingSetNodeID &ID) {
ID.Add(P.first); ID.Add(P.first);
ID.Add(P.second); ID.Add(P.second);
} }
}; };
} // End of namespace llvm.
#endif } // end namespace llvm
#endif // LLVM_ADT_FOLDINGSET_H

View File

@ -16,12 +16,16 @@
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/iterator.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Allocator.h" #include "llvm/Support/Allocator.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include <cassert> #include <cassert>
#include <functional> #include <functional>
#include <vector> #include <vector>
#include <cstdint>
#include <iterator>
#include <new>
namespace llvm { namespace llvm {
@ -329,11 +333,13 @@ private:
public: public:
void retain() { ++refCount; } void retain() { ++refCount; }
void release() { void release() {
assert(refCount > 0); assert(refCount > 0);
if (--refCount == 0) if (--refCount == 0)
destroy(); destroy();
} }
void destroy() { void destroy() {
if (left) if (left)
left->release(); left->release();
@ -375,7 +381,7 @@ class ImutAVLFactory {
std::vector<TreeTy*> freeNodes; std::vector<TreeTy*> freeNodes;
bool ownsAllocator() const { bool ownsAllocator() const {
return Allocator & 0x1 ? false : true; return (Allocator & 0x1) == 0;
} }
BumpPtrAllocator& getAllocator() const { BumpPtrAllocator& getAllocator() const {
@ -414,7 +420,6 @@ public:
TreeTy* getEmptyTree() const { return nullptr; } TreeTy* getEmptyTree() const { return nullptr; }
protected: protected:
//===--------------------------------------------------===// //===--------------------------------------------------===//
// A bunch of quick helper functions used for reasoning // A bunch of quick helper functions used for reasoning
// about the properties of trees and their children. // about the properties of trees and their children.
@ -649,13 +654,14 @@ class ImutAVLTreeGenericIterator
: public std::iterator<std::bidirectional_iterator_tag, : public std::iterator<std::bidirectional_iterator_tag,
ImutAVLTree<ImutInfo>> { ImutAVLTree<ImutInfo>> {
SmallVector<uintptr_t,20> stack; SmallVector<uintptr_t,20> stack;
public: public:
enum VisitFlag { VisitedNone=0x0, VisitedLeft=0x1, VisitedRight=0x3, enum VisitFlag { VisitedNone=0x0, VisitedLeft=0x1, VisitedRight=0x3,
Flags=0x3 }; Flags=0x3 };
typedef ImutAVLTree<ImutInfo> TreeTy; typedef ImutAVLTree<ImutInfo> TreeTy;
ImutAVLTreeGenericIterator() {} ImutAVLTreeGenericIterator() = default;
ImutAVLTreeGenericIterator(const TreeTy *Root) { ImutAVLTreeGenericIterator(const TreeTy *Root) {
if (Root) stack.push_back(reinterpret_cast<uintptr_t>(Root)); if (Root) stack.push_back(reinterpret_cast<uintptr_t>(Root));
} }
@ -671,7 +677,6 @@ public:
return stack.back() & Flags; return stack.back() & Flags;
} }
bool atEnd() const { return stack.empty(); } bool atEnd() const { return stack.empty(); }
bool atBeginning() const { bool atBeginning() const {
@ -881,7 +886,6 @@ struct ImutProfileInfo<bool> {
} }
}; };
/// Generic profile trait for pointer types. We treat pointers as /// Generic profile trait for pointer types. We treat pointers as
/// references to unique objects. /// references to unique objects.
template <typename T> template <typename T>
@ -901,7 +905,6 @@ struct ImutProfileInfo<T*> {
// for element profiling. // for element profiling.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// ImutContainerInfo - Generic definition of comparison operations for /// ImutContainerInfo - Generic definition of comparison operations for
/// elements of immutable containers that defaults to using /// elements of immutable containers that defaults to using
/// std::equal_to<> and std::less<> to perform comparison of elements. /// std::equal_to<> and std::less<> to perform comparison of elements.
@ -972,9 +975,11 @@ public:
explicit ImmutableSet(TreeTy* R) : Root(R) { explicit ImmutableSet(TreeTy* R) : Root(R) {
if (Root) { Root->retain(); } if (Root) { Root->retain(); }
} }
ImmutableSet(const ImmutableSet &X) : Root(X.Root) { ImmutableSet(const ImmutableSet &X) : Root(X.Root) {
if (Root) { Root->retain(); } if (Root) { Root->retain(); }
} }
ImmutableSet &operator=(const ImmutableSet &X) { ImmutableSet &operator=(const ImmutableSet &X) {
if (Root != X.Root) { if (Root != X.Root) {
if (X.Root) { X.Root->retain(); } if (X.Root) { X.Root->retain(); }
@ -983,6 +988,7 @@ public:
} }
return *this; return *this;
} }
~ImmutableSet() { ~ImmutableSet() {
if (Root) { Root->release(); } if (Root) { Root->release(); }
} }
@ -998,6 +1004,9 @@ public:
Factory(BumpPtrAllocator& Alloc, bool canonicalize = true) Factory(BumpPtrAllocator& Alloc, bool canonicalize = true)
: F(Alloc), Canonicalize(canonicalize) {} : F(Alloc), Canonicalize(canonicalize) {}
Factory(const Factory& RHS) = delete;
void operator=(const Factory& RHS) = delete;
/// getEmptySet - Returns an immutable set that contains no elements. /// getEmptySet - Returns an immutable set that contains no elements.
ImmutableSet getEmptySet() { ImmutableSet getEmptySet() {
return ImmutableSet(F.getEmptyTree()); return ImmutableSet(F.getEmptyTree());
@ -1032,10 +1041,6 @@ public:
typename TreeTy::Factory *getTreeFactory() const { typename TreeTy::Factory *getTreeFactory() const {
return const_cast<typename TreeTy::Factory *>(&F); return const_cast<typename TreeTy::Factory *>(&F);
} }
private:
Factory(const Factory& RHS) = delete;
void operator=(const Factory& RHS) = delete;
}; };
friend class Factory; friend class Factory;
@ -1126,11 +1131,13 @@ public:
Factory(F) { Factory(F) {
if (Root) { Root->retain(); } if (Root) { Root->retain(); }
} }
ImmutableSetRef(const ImmutableSetRef &X) ImmutableSetRef(const ImmutableSetRef &X)
: Root(X.Root), : Root(X.Root),
Factory(X.Factory) { Factory(X.Factory) {
if (Root) { Root->retain(); } if (Root) { Root->retain(); }
} }
ImmutableSetRef &operator=(const ImmutableSetRef &X) { ImmutableSetRef &operator=(const ImmutableSetRef &X) {
if (Root != X.Root) { if (Root != X.Root) {
if (X.Root) { X.Root->retain(); } if (X.Root) { X.Root->retain(); }
@ -1215,4 +1222,4 @@ public:
} // end namespace llvm } // end namespace llvm
#endif #endif // LLVM_ADT_IMMUTABLESET_H

View File

@ -104,11 +104,14 @@
#include "llvm/Support/AlignOf.h" #include "llvm/Support/AlignOf.h"
#include "llvm/Support/Allocator.h" #include "llvm/Support/Allocator.h"
#include "llvm/Support/RecyclingAllocator.h" #include "llvm/Support/RecyclingAllocator.h"
#include <algorithm>
#include <cassert>
#include <iterator> #include <iterator>
#include <new>
#include <utility>
namespace llvm { namespace llvm {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
//--- Key traits ---// //--- Key traits ---//
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -131,7 +134,6 @@ namespace llvm {
template <typename T> template <typename T>
struct IntervalMapInfo { struct IntervalMapInfo {
/// startLess - Return true if x is not in [a;b]. /// 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. /// 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) { 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) { static inline bool nonEmpty(const T &a, const T &b) {
return a <= b; return a <= b;
} }
}; };
template <typename T> template <typename T>
struct IntervalMapHalfOpenInfo { struct IntervalMapHalfOpenInfo {
/// startLess - Return true if x is not in [a;b). /// startLess - Return true if x is not in [a;b).
static inline bool startLess(const T &x, const T &a) { static inline bool startLess(const T &x, const T &a) {
return x < a; return x < a;
@ -180,20 +180,14 @@ struct IntervalMapHalfOpenInfo {
static inline bool nonEmpty(const T &a, const T &b) { static inline bool nonEmpty(const T &a, const T &b) {
return a < b; return a < b;
} }
}; };
/// IntervalMapImpl - Namespace used for IntervalMap implementation details. /// IntervalMapImpl - Namespace used for IntervalMap implementation details.
/// It should be considered private to the implementation. /// It should be considered private to the implementation.
namespace IntervalMapImpl { namespace IntervalMapImpl {
// Forward declarations.
template <typename, typename, unsigned, typename> class LeafNode;
template <typename, typename, unsigned, typename> class BranchNode;
typedef std::pair<unsigned,unsigned> IdxPair; typedef std::pair<unsigned,unsigned> IdxPair;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
//--- IntervalMapImpl::NodeBase ---// //--- IntervalMapImpl::NodeBase ---//
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -417,7 +411,6 @@ IdxPair distribute(unsigned Nodes, unsigned Elements, unsigned Capacity,
const unsigned *CurSize, unsigned NewSize[], const unsigned *CurSize, unsigned NewSize[],
unsigned Position, bool Grow); unsigned Position, bool Grow);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
//--- IntervalMapImpl::NodeSizer ---// //--- IntervalMapImpl::NodeSizer ---//
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -470,10 +463,8 @@ struct NodeSizer {
/// different kinds of maps. /// different kinds of maps.
typedef RecyclingAllocator<BumpPtrAllocator, char, typedef RecyclingAllocator<BumpPtrAllocator, char,
AllocBytes, CacheLineBytes> Allocator; AllocBytes, CacheLineBytes> Allocator;
}; };
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
//--- IntervalMapImpl::NodeRef ---// //--- IntervalMapImpl::NodeRef ---//
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -505,7 +496,7 @@ class NodeRef {
public: public:
/// NodeRef - Create a null ref. /// NodeRef - Create a null ref.
NodeRef() {} NodeRef() = default;
/// operator bool - Detect a null ref. /// operator bool - Detect a null ref.
explicit operator bool() const { return pip.getOpaqueValue(); } 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; return Size + 1;
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
//--- IntervalMapImpl::BranchNode ---// //--- IntervalMapImpl::BranchNode ---//
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -930,8 +920,7 @@ public:
} }
}; };
} // namespace IntervalMapImpl } // end namespace IntervalMapImpl
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
//--- IntervalMap ----// //--- IntervalMap ----//
@ -1006,6 +995,7 @@ private:
assert(!branched() && "Cannot acces leaf data in branched root"); assert(!branched() && "Cannot acces leaf data in branched root");
return dataAs<RootLeaf>(); return dataAs<RootLeaf>();
} }
RootBranchData &rootBranchData() const { RootBranchData &rootBranchData() const {
assert(branched() && "Cannot access branch data in non-branched root"); assert(branched() && "Cannot access branch data in non-branched root");
return dataAs<RootBranchData>(); return dataAs<RootBranchData>();
@ -1014,6 +1004,7 @@ private:
assert(branched() && "Cannot access branch data in non-branched root"); assert(branched() && "Cannot access branch data in non-branched root");
return dataAs<RootBranchData>(); return dataAs<RootBranchData>();
} }
const RootBranch &rootBranch() const { return rootBranchData().node; } const RootBranch &rootBranch() const { return rootBranchData().node; }
RootBranch &rootBranch() { return rootBranchData().node; } RootBranch &rootBranch() { return rootBranchData().node; }
KeyT rootBranchStart() const { return rootBranchData().start; } KeyT rootBranchStart() const { return rootBranchData().start; }
@ -1160,7 +1151,6 @@ treeSafeLookup(KeyT x, ValT NotFound) const {
return NR.get<Leaf>().safeLookup(x, NotFound); return NR.get<Leaf>().safeLookup(x, NotFound);
} }
// branchRoot - Switch from a leaf root to a branched root. // branchRoot - Switch from a leaf root to a branched root.
// Return the new (root offset, node offset) corresponding to Position. // Return the new (root offset, node offset) corresponding to Position.
template <typename KeyT, typename ValT, unsigned N, typename Traits> template <typename KeyT, typename ValT, unsigned N, typename Traits>
@ -1295,6 +1285,7 @@ clear() {
template <typename KeyT, typename ValT, unsigned N, typename Traits> template <typename KeyT, typename ValT, unsigned N, typename Traits>
class IntervalMap<KeyT, ValT, N, Traits>::const_iterator : class IntervalMap<KeyT, ValT, N, Traits>::const_iterator :
public std::iterator<std::bidirectional_iterator_tag, ValT> { public std::iterator<std::bidirectional_iterator_tag, ValT> {
protected: protected:
friend class IntervalMap; friend class IntervalMap;
@ -1447,7 +1438,6 @@ public:
path.leafOffset() = path.leafOffset() =
map->rootLeaf().findFrom(path.leafOffset(), map->rootSize, x); map->rootLeaf().findFrom(path.leafOffset(), map->rootSize, x);
} }
}; };
/// pathFillFind - Complete path by searching for x. /// pathFillFind - Complete path by searching for x.
@ -1534,7 +1524,7 @@ class IntervalMap<KeyT, ValT, N, Traits>::iterator : public const_iterator {
public: public:
/// iterator - Create null iterator. /// iterator - Create null iterator.
iterator() {} iterator() = default;
/// setStart - Move the start of the current interval. /// setStart - Move the start of the current interval.
/// This may cause coalescing with the previous interval. /// This may cause coalescing with the previous interval.
@ -1600,7 +1590,6 @@ public:
operator--(); operator--();
return tmp; return tmp;
} }
}; };
/// canCoalesceLeft - Can the current interval coalesce to the left after /// 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); treeInsert(a, b, y);
} }
template <typename KeyT, typename ValT, unsigned N, typename Traits> template <typename KeyT, typename ValT, unsigned N, typename Traits>
void IntervalMap<KeyT, ValT, N, Traits>:: void IntervalMap<KeyT, ValT, N, Traits>::
iterator::treeInsert(KeyT a, KeyT b, ValT y) { iterator::treeInsert(KeyT a, KeyT b, ValT y) {
@ -2162,6 +2150,6 @@ public:
} }
}; };
} // namespace llvm } // end namespace llvm
#endif #endif // LLVM_ADT_INTERVALMAP_H

View File

@ -27,9 +27,6 @@
namespace llvm { namespace llvm {
template <class T>
class IntrusiveRefCntPtr;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// RefCountedBase - A generic base class for objects that wish to /// RefCountedBase - A generic base class for objects that wish to
/// have their lifetimes managed using reference counts. Classes /// have their lifetimes managed using reference counts. Classes
@ -42,10 +39,10 @@ namespace llvm {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
template <class Derived> template <class Derived>
class RefCountedBase { class RefCountedBase {
mutable unsigned ref_cnt; mutable unsigned ref_cnt = 0;
public: public:
RefCountedBase() : ref_cnt(0) {} RefCountedBase() = default;
RefCountedBase(const RefCountedBase &) : ref_cnt(0) {} RefCountedBase(const RefCountedBase &) : ref_cnt(0) {}
void Retain() const { ++ref_cnt; } void Retain() const { ++ref_cnt; }
@ -64,14 +61,15 @@ namespace llvm {
/// attempting to do this will produce a compile error. /// attempting to do this will produce a compile error.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
class RefCountedBaseVPTR { class RefCountedBaseVPTR {
mutable unsigned ref_cnt; mutable unsigned ref_cnt = 0;
virtual void anchor(); virtual void anchor();
protected: protected:
RefCountedBaseVPTR() : ref_cnt(0) {} RefCountedBaseVPTR() = default;
RefCountedBaseVPTR(const RefCountedBaseVPTR &) : ref_cnt(0) {} RefCountedBaseVPTR(const RefCountedBaseVPTR &) : ref_cnt(0) {}
virtual ~RefCountedBaseVPTR() {} virtual ~RefCountedBaseVPTR() = default;
void Retain() const { ++ref_cnt; } void Retain() const { ++ref_cnt; }
void Release() const { void Release() const {
@ -133,12 +131,12 @@ public:
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
template <typename T> template <typename T>
class IntrusiveRefCntPtr { class IntrusiveRefCntPtr {
T* Obj; T* Obj = nullptr;
public: public:
typedef T element_type; typedef T element_type;
explicit IntrusiveRefCntPtr() : Obj(nullptr) {} explicit IntrusiveRefCntPtr() = default;
IntrusiveRefCntPtr(T* obj) : Obj(obj) { IntrusiveRefCntPtr(T* obj) : Obj(obj) {
retain(); retain();

View File

@ -17,7 +17,10 @@
#include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/PointerLikeTypeTraits.h"
#include <cassert>
#include <cstdint>
#include <cstddef>
namespace llvm { namespace llvm {
@ -57,6 +60,7 @@ template <typename PT1, typename PT2> class PointerUnionUIntTraits {
public: public:
static inline void *getAsVoidPointer(void *P) { return P; } static inline void *getAsVoidPointer(void *P) { return P; }
static inline void *getFromVoidPointer(void *P) { return P; } static inline void *getFromVoidPointer(void *P) { return P; }
enum { enum {
PT1BitsAv = (int)(PointerLikeTypeTraits<PT1>::NumLowBitsAvailable), PT1BitsAv = (int)(PointerLikeTypeTraits<PT1>::NumLowBitsAvailable),
PT2BitsAv = (int)(PointerLikeTypeTraits<PT2>::NumLowBitsAvailable), PT2BitsAv = (int)(PointerLikeTypeTraits<PT2>::NumLowBitsAvailable),
@ -97,7 +101,7 @@ private:
template <typename T> struct UNION_DOESNT_CONTAIN_TYPE {}; template <typename T> struct UNION_DOESNT_CONTAIN_TYPE {};
public: public:
PointerUnion() {} PointerUnion() = default;
PointerUnion(PT1 V) PointerUnion(PT1 V)
: Val(const_cast<void *>( : Val(const_cast<void *>(
@ -208,6 +212,7 @@ public:
static inline void *getAsVoidPointer(const PointerUnion<PT1, PT2> &P) { static inline void *getAsVoidPointer(const PointerUnion<PT1, PT2> &P) {
return P.getOpaqueValue(); return P.getOpaqueValue();
} }
static inline PointerUnion<PT1, PT2> getFromVoidPointer(void *P) { static inline PointerUnion<PT1, PT2> getFromVoidPointer(void *P) {
return PointerUnion<PT1, PT2>::getFromOpaqueValue(P); return PointerUnion<PT1, PT2>::getFromOpaqueValue(P);
} }
@ -249,7 +254,7 @@ private:
}; };
public: public:
PointerUnion3() {} PointerUnion3() = default;
PointerUnion3(PT1 V) { Val = InnerUnion(V); } PointerUnion3(PT1 V) { Val = InnerUnion(V); }
PointerUnion3(PT2 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) { static inline void *getAsVoidPointer(const PointerUnion3<PT1, PT2, PT3> &P) {
return P.getOpaqueValue(); return P.getOpaqueValue();
} }
static inline PointerUnion3<PT1, PT2, PT3> getFromVoidPointer(void *P) { static inline PointerUnion3<PT1, PT2, PT3> getFromVoidPointer(void *P) {
return PointerUnion3<PT1, PT2, PT3>::getFromOpaqueValue(P); return PointerUnion3<PT1, PT2, PT3>::getFromOpaqueValue(P);
} }
@ -352,7 +358,7 @@ private:
ValTy Val; ValTy Val;
public: public:
PointerUnion4() {} PointerUnion4() = default;
PointerUnion4(PT1 V) { Val = InnerUnion1(V); } PointerUnion4(PT1 V) { Val = InnerUnion1(V); }
PointerUnion4(PT2 V) { Val = InnerUnion1(V); } PointerUnion4(PT2 V) { Val = InnerUnion1(V); }
@ -435,6 +441,7 @@ public:
getAsVoidPointer(const PointerUnion4<PT1, PT2, PT3, PT4> &P) { getAsVoidPointer(const PointerUnion4<PT1, PT2, PT3, PT4> &P) {
return P.getOpaqueValue(); return P.getOpaqueValue();
} }
static inline PointerUnion4<PT1, PT2, PT3, PT4> getFromVoidPointer(void *P) { static inline PointerUnion4<PT1, PT2, PT3, PT4> getFromVoidPointer(void *P) {
return PointerUnion4<PT1, PT2, PT3, PT4>::getFromOpaqueValue(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

View File

@ -16,6 +16,7 @@
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include <cstddef>
namespace llvm { namespace llvm {
@ -25,7 +26,7 @@ template<unsigned InternalLen>
class SmallString : public SmallVector<char, InternalLen> { class SmallString : public SmallVector<char, InternalLen> {
public: public:
/// Default ctor - Initialize to empty. /// Default ctor - Initialize to empty.
SmallString() {} SmallString() = default;
/// Initialize from a StringRef. /// Initialize from a StringRef.
SmallString(StringRef S) : SmallVector<char, InternalLen>(S.begin(), S.end()) {} SmallString(StringRef S) : SmallVector<char, InternalLen>(S.begin(), S.end()) {}
@ -79,7 +80,6 @@ public:
SmallVectorImpl<char>::append(NumInputs, Elt); SmallVectorImpl<char>::append(NumInputs, Elt);
} }
/// Append from a StringRef. /// Append from a StringRef.
void append(StringRef RHS) { void append(StringRef RHS) {
SmallVectorImpl<char>::append(RHS.begin(), RHS.end()); SmallVectorImpl<char>::append(RHS.begin(), RHS.end());
@ -292,6 +292,6 @@ public:
} }
}; };
} } // end namespace llvm
#endif #endif // LLVM_ADT_SMALLSTRING_H

View File

@ -17,10 +17,17 @@
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/Support/Allocator.h" #include "llvm/Support/Allocator.h"
#include "llvm/Support/PointerLikeTypeTraits.h" #include "llvm/Support/PointerLikeTypeTraits.h"
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <cstring> #include <cstring>
#include <utility> #include <utility>
#include <initializer_list>
#include <new>
#include <utility>
namespace llvm { namespace llvm {
template<typename ValueT> template<typename ValueT>
class StringMapConstIterator; class StringMapConstIterator;
template<typename ValueT> template<typename ValueT>
@ -119,8 +126,6 @@ public:
/// and data. /// and data.
template<typename ValueTy> template<typename ValueTy>
class StringMapEntry : public StringMapEntryBase { class StringMapEntry : public StringMapEntryBase {
StringMapEntry(StringMapEntry &E) = delete;
public: public:
ValueTy second; ValueTy second;
@ -129,6 +134,7 @@ public:
template <typename... InitTy> template <typename... InitTy>
StringMapEntry(unsigned strLen, InitTy &&... InitVals) StringMapEntry(unsigned strLen, InitTy &&... InitVals)
: StringMapEntryBase(strLen), second(std::forward<InitTy>(InitVals)...) {} : StringMapEntryBase(strLen), second(std::forward<InitTy>(InitVals)...) {}
StringMapEntry(StringMapEntry &E) = delete;
StringRef getKey() const { StringRef getKey() const {
return StringRef(getKeyData(), getKeyLength()); return StringRef(getKeyData(), getKeyLength());
@ -440,12 +446,12 @@ public:
template <typename ValueTy> class StringMapConstIterator { template <typename ValueTy> class StringMapConstIterator {
protected: protected:
StringMapEntryBase **Ptr; StringMapEntryBase **Ptr = nullptr;
public: public:
typedef StringMapEntry<ValueTy> value_type; typedef StringMapEntry<ValueTy> value_type;
StringMapConstIterator() : Ptr(nullptr) { } StringMapConstIterator() = default;
explicit StringMapConstIterator(StringMapEntryBase **Bucket, explicit StringMapConstIterator(StringMapEntryBase **Bucket,
bool NoAdvance = false) bool NoAdvance = false)
@ -486,11 +492,13 @@ private:
template<typename ValueTy> template<typename ValueTy>
class StringMapIterator : public StringMapConstIterator<ValueTy> { class StringMapIterator : public StringMapConstIterator<ValueTy> {
public: public:
StringMapIterator() {} StringMapIterator() = default;
explicit StringMapIterator(StringMapEntryBase **Bucket, explicit StringMapIterator(StringMapEntryBase **Bucket,
bool NoAdvance = false) bool NoAdvance = false)
: StringMapConstIterator<ValueTy>(Bucket, NoAdvance) { : StringMapConstIterator<ValueTy>(Bucket, NoAdvance) {
} }
StringMapEntry<ValueTy> &operator*() const { StringMapEntry<ValueTy> &operator*() const {
return *static_cast<StringMapEntry<ValueTy>*>(*this->Ptr); return *static_cast<StringMapEntry<ValueTy>*>(*this->Ptr);
} }
@ -498,6 +506,7 @@ public:
return static_cast<StringMapEntry<ValueTy>*>(*this->Ptr); return static_cast<StringMapEntry<ValueTy>*>(*this->Ptr);
} }
}; };
}
#endif } // end namespace llvm
#endif // LLVM_ADT_STRINGMAP_H

View File

@ -12,6 +12,7 @@
#include <cstddef> #include <cstddef>
#include <iterator> #include <iterator>
#include <type_traits>
namespace llvm { namespace llvm {
@ -264,7 +265,7 @@ class pointer_iterator
mutable T Ptr; mutable T Ptr;
public: public:
pointer_iterator() {} pointer_iterator() = default;
explicit pointer_iterator(WrappedIteratorT u) explicit pointer_iterator(WrappedIteratorT u)
: pointer_iterator::iterator_adaptor_base(std::move(u)) {} : pointer_iterator::iterator_adaptor_base(std::move(u)) {}
@ -273,6 +274,6 @@ public:
const T &operator*() const { return Ptr = &*this->I; } const T &operator*() const { return Ptr = &*this->I; }
}; };
} // namespace llvm } // end namespace llvm
#endif #endif // LLVM_ADT_ITERATOR_H