llvm.org GIT mirror llvm / 085ee02
Reformat headers in ADT and Support partially. Note, I didn't reformat entirely, but partially where I touched in previous commits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244432 91177308-0d34-0410-b5e6-96231b3b80d8 NAKAMURA Takumi 4 years ago
16 changed file(s) with 87 addition(s) and 97 deletion(s). Raw diff Collapse all Expand all
246246 return this->operator|(RHS);
247247 }
248248
249 APSInt operator^(const APSInt& RHS) const {
249 APSInt operator^(const APSInt &RHS) const {
250250 assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!");
251251 return APSInt(static_cast(*this) ^ RHS, IsUnsigned);
252252 }
7474 // VisitStack - Used to maintain the ordering. Top = current block
7575 // First element is node pointer, second is the 'next child' to visit
7676 // if the int in PointerIntTy is 0, the 'next child' to visit is invalid
77 std::vector > VisitStack;
77 std::vector> VisitStack;
7878
7979 private:
8080 inline df_iterator(NodeType *Node) {
8181 this->Visited.insert(Node);
82 VisitStack.push_back(std::make_pair(PointerIntTy(Node, 0),
83 GT::child_begin(Node)));
82 VisitStack.push_back(
83 std::make_pair(PointerIntTy(Node, 0), GT::child_begin(Node)));
8484 }
8585 inline df_iterator() {
8686 // End is when stack is empty
8888 inline df_iterator(NodeType *Node, SetType &S)
8989 : df_iterator_storage(S) {
9090 if (!S.count(Node)) {
91 VisitStack.push_back(std::make_pair(PointerIntTy(Node, 0),
92 GT::child_begin(Node)));
91 VisitStack.push_back(
92 std::make_pair(PointerIntTy(Node, 0), GT::child_begin(Node)));
9393 this->Visited.insert(Node);
9494 }
9595 }
114114 // Has our next sibling been visited?
115115 if (Next && this->Visited.insert(Next).second) {
116116 // No, do it now.
117 VisitStack.push_back(std::make_pair(PointerIntTy(Next, 0),
118 GT::child_begin(Next)));
117 VisitStack.push_back(
118 std::make_pair(PointerIntTy(Next, 0), GT::child_begin(Next)));
119119 return;
120120 }
121121 }
610610 }
611611 };
612612
613 template
614 class FoldingSetIterator : public FoldingSetIteratorImpl {
613 template class FoldingSetIterator : public FoldingSetIteratorImpl {
615614 public:
616615 explicit FoldingSetIterator(void **Bucket) : FoldingSetIteratorImpl(Bucket) {}
617616
661660 }
662661 };
663662
664 template
663 template
665664 class FoldingSetBucketIterator : public FoldingSetBucketIteratorImpl {
666665 public:
667666 explicit FoldingSetBucketIterator(void **Bucket) :
716715 explicit FastFoldingSetNode(const FoldingSetNodeID &ID) : FastID(ID) {}
717716
718717 public:
719 void Profile(FoldingSetNodeID &ID) const {
720 ID.AddNodeID(FastID);
721 }
718 void Profile(FoldingSetNodeID &ID) const { ID.AddNodeID(FastID); }
722719 };
723720
724721 //===----------------------------------------------------------------------===//
9797 const bool Canonicalize;
9898
9999 public:
100 Factory(bool canonicalize = true)
101 : Canonicalize(canonicalize) {}
102
103 Factory(BumpPtrAllocator& Alloc, bool canonicalize = true)
104 : F(Alloc), Canonicalize(canonicalize) {}
100 Factory(bool canonicalize = true) : Canonicalize(canonicalize) {}
101
102 Factory(BumpPtrAllocator &Alloc, bool canonicalize = true)
103 : F(Alloc), Canonicalize(canonicalize) {}
105104
106105 ImmutableMap getEmptyMap() { return ImmutableMap(F.getEmptyTree()); }
107106
141140 return Root;
142141 }
143142
144 TreeTy *getRootWithoutRetain() const {
145 return Root;
146 }
143 TreeTy *getRootWithoutRetain() const { return Root; }
147144
148145 void manualRetain() {
149146 if (Root) Root->retain();
268265 /// should use a Factory object to create maps instead of directly
269266 /// invoking the constructor, but there are cases where make this
270267 /// constructor public is useful.
271 explicit ImmutableMapRef(const TreeTy* R, FactoryTy *F)
272 : Root(const_cast(R)),
273 Factory(F) {
274 if (Root) { Root->retain(); }
268 explicit ImmutableMapRef(const TreeTy *R, FactoryTy *F)
269 : Root(const_cast(R)), Factory(F) {
270 if (Root) {
271 Root->retain();
272 }
275273 }
276274
277275 explicit ImmutableMapRef(const ImmutableMap &X,
281279 if (Root) { Root->retain(); }
282280 }
283281
284 ImmutableMapRef(const ImmutableMapRef &X)
285 : Root(X.Root),
286 Factory(X.Factory) {
287 if (Root) { Root->retain(); }
282 ImmutableMapRef(const ImmutableMapRef &X) : Root(X.Root), Factory(X.Factory) {
283 if (Root) {
284 Root->retain();
285 }
288286 }
289287
290288 ImmutableMapRef &operator=(const ImmutableMapRef &X) {
350348 // For testing.
351349 //===--------------------------------------------------===//
352350
353 void verify() const { if (Root) Root->verify(); }
351 void verify() const {
352 if (Root)
353 Root->verify();
354 }
354355
355356 //===--------------------------------------------------===//
356357 // Iterators.
369370 iterator begin() const { return iterator(Root); }
370371 iterator end() const { return iterator(); }
371372
372 data_type* lookup(key_type_ref K) const {
373 data_type *lookup(key_type_ref K) const {
373374 if (Root) {
374375 TreeTy* T = Root->find(K);
375376 if (T) return &T->getValue().second;
391392
392393 unsigned getHeight() const { return Root ? Root->getHeight() : 0; }
393394
394 static inline void Profile(FoldingSetNodeID& ID, const ImmutableMapRef &M) {
395 static inline void Profile(FoldingSetNodeID &ID, const ImmutableMapRef &M) {
395396 ID.AddPointer(M.Root);
396397 }
397398
398 inline void Profile(FoldingSetNodeID& ID) const {
399 return Profile(ID, *this);
400 }
399 inline void Profile(FoldingSetNodeID &ID) const { return Profile(ID, *this); }
401400 };
402401
403402 } // end namespace llvm
8282 PackedVector &Vec;
8383 const unsigned Idx;
8484
85 reference(); // Undefined
85 reference(); // Undefined
8686 public:
87 reference(PackedVector &vec, unsigned idx) : Vec(vec), Idx(idx) { }
87 reference(PackedVector &vec, unsigned idx) : Vec(vec), Idx(idx) {}
8888
8989 reference &operator=(T val) {
9090 Vec.setValue(Vec.Bits, Idx, val);
100100
101101 bool empty() const { return Bits.empty(); }
102102
103 unsigned size() const { return Bits.size() >> (BitNum-1); }
103 unsigned size() const { return Bits.size() >> (BitNum - 1); }
104104
105105 void clear() { Bits.clear(); }
106106
107 void resize(unsigned N) { Bits.resize(N << (BitNum-1)); }
107 void resize(unsigned N) { Bits.resize(N << (BitNum - 1)); }
108108
109109 void reserve(unsigned N) { Bits.reserve(N << (BitNum-1)); }
110110
150150 };
151151
152152 // Leave BitNum=0 undefined.
153 template
154 class PackedVector;
153 template class PackedVector;
155154
156155 } // end llvm namespace
157156
5353
5454 /// IntShift - The number of low bits that we reserve for other uses, and
5555 /// keep zero.
56 IntShift = (uintptr_t)PtrTraits::NumLowBitsAvailable-IntBits,
56 IntShift = (uintptr_t)PtrTraits::NumLowBitsAvailable - IntBits,
5757
5858 /// IntMask - This is the unshifted mask for valid bits of the int type.
59 IntMask = (uintptr_t)(((intptr_t)1 << IntBits)-1),
59 IntMask = (uintptr_t)(((intptr_t)1 << IntBits) - 1),
6060
6161 // ShiftedIntMask - This is the bits for the integer shifted in place.
6262 ShiftedIntMask = (uintptr_t)(IntMask << IntShift)
132132 void setFromOpaqueValue(void *Val) { Value = reinterpret_cast(Val);}
133133
134134 static PointerIntPair getFromOpaqueValue(void *V) {
135 PointerIntPair P; P.setFromOpaqueValue(V); return P;
135 PointerIntPair P;
136 P.setFromOpaqueValue(V);
137 return P;
136138 }
137139
138140 // Allow PointerIntPairs to be created from const void * if and only if the
6969 return New;
7070 }
7171
72 template
73 void Destroy(AllocatorTy &Allocator) {
72 template void Destroy(AllocatorTy &Allocator) {
7473 // Free memory referenced by the item.
7574 this->~ScopedHashTableVal();
7675 Allocator.Deallocate(this);
8988 /// LastValInScope - This is the last value that was inserted for this scope
9089 /// or null if none have been inserted yet.
9190 ScopedHashTableVal *LastValInScope;
92 void operator=(ScopedHashTableScope&) = delete;
93 ScopedHashTableScope(ScopedHashTableScope&) = delete;
91 void operator=(ScopedHashTableScope &) = delete;
92 ScopedHashTableScope(ScopedHashTableScope &) = delete;
9493
9594 public:
9695 ScopedHashTableScope(ScopedHashTable &HT);
109108 }
110109 };
111110
112 template >
111 template >
113112 class ScopedHashTableIterator {
114113 ScopedHashTableVal *Node;
115114
156155
157156 AllocatorTy Allocator;
158157
159 ScopedHashTable(const ScopedHashTable&); // NOT YET IMPLEMENTED
160 void operator=(const ScopedHashTable&); // NOT YET IMPLEMENTED
158 ScopedHashTable(const ScopedHashTable &); // NOT YET IMPLEMENTED
159 void operator=(const ScopedHashTable &); // NOT YET IMPLEMENTED
161160 friend class ScopedHashTableScope;
162161
163162 public:
243243 class SmallPtrSetImpl : public SmallPtrSetImplBase {
244244 typedef PointerLikeTypeTraits PtrTraits;
245245
246 SmallPtrSetImpl(const SmallPtrSetImpl&) = delete;
246 SmallPtrSetImpl(const SmallPtrSetImpl &) = delete;
247247
248248 protected:
249249 // Constructors that forward to the base.
390390 }
391391 };
392392
393 template
394 class StringMapConstIterator {
393 template class StringMapConstIterator {
395394 protected:
396395 StringMapEntryBase **Ptr;
397396
106106 protected:
107107 CrashRecoveryContext *context;
108108 CrashRecoveryContextCleanup(CrashRecoveryContext *context)
109 : context(context), cleanupFired(false) {}
109 : context(context), cleanupFired(false) {}
110110
111111 public:
112112 bool cleanupFired;
127127 class CrashRecoveryContextCleanupBase : public CrashRecoveryContextCleanup {
128128 protected:
129129 T *resource;
130 CrashRecoveryContextCleanupBase(CrashRecoveryContext *context, T* resource)
131 : CrashRecoveryContextCleanup(context), resource(resource) {}
130 CrashRecoveryContextCleanupBase(CrashRecoveryContext *context, T *resource)
131 : CrashRecoveryContextCleanup(context), resource(resource) {}
132132
133133 public:
134134 static DERIVED *create(T *x) {
146146 public:
147147 CrashRecoveryContextDestructorCleanup(CrashRecoveryContext *context,
148148 T *resource)
149 : CrashRecoveryContextCleanupBase<
150 CrashRecoveryContextDestructorCleanup, T>(context, resource) {}
149 : CrashRecoveryContextCleanupBase<
150 CrashRecoveryContextDestructorCleanup, T>(context, resource) {}
151151
152152 virtual void recoverResources() {
153153 this->resource->~T();
189189 cleanup->getContext()->registerCleanup(cleanup);
190190 }
191191
192 ~CrashRecoveryContextCleanupRegistrar() {
193 unregister();
194 }
192 ~CrashRecoveryContextCleanupRegistrar() { unregister(); }
195193
196194 void unregister() {
197195 if (cleanup && !cleanup->cleanupFired)
6060 ~ScopedFatalErrorHandler() { remove_fatal_error_handler(); }
6161 };
6262
63 /// Reports a serious error, calling any installed error handler. These
64 /// functions are intended to be used for error conditions which are outside
65 /// the control of the compiler (I/O errors, invalid user input, etc.)
66 ///
67 /// If no error handler is installed the default is to print the message to
68 /// standard error, followed by a newline.
69 /// After the error handler is called this function will call exit(1), it
70 /// does not return.
71 LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason,
72 bool gen_crash_diag = true);
73 LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const std::string &reason,
74 bool gen_crash_diag = true);
75 LLVM_ATTRIBUTE_NORETURN void report_fatal_error(StringRef reason,
76 bool gen_crash_diag = true);
77 LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const Twine &reason,
78 bool gen_crash_diag = true);
63 /// Reports a serious error, calling any installed error handler. These
64 /// functions are intended to be used for error conditions which are outside
65 /// the control of the compiler (I/O errors, invalid user input, etc.)
66 ///
67 /// If no error handler is installed the default is to print the message to
68 /// standard error, followed by a newline.
69 /// After the error handler is called this function will call exit(1), it
70 /// does not return.
71 LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason,
72 bool gen_crash_diag = true);
73 LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const std::string &reason,
74 bool gen_crash_diag = true);
75 LLVM_ATTRIBUTE_NORETURN void report_fatal_error(StringRef reason,
76 bool gen_crash_diag = true);
77 LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const Twine &reason,
78 bool gen_crash_diag = true);
7979
8080 /// This function calls abort(), and prints the optional message to stderr.
8181 /// Use the llvm_unreachable macro (that adds location info), instead of
9494 };
9595
9696 // Helper functions so that you can use & and | to manipulate perms bits:
97 inline perms operator|(perms l , perms r) {
98 return static_cast(
99 static_cast(l) | static_cast(r));
100 }
101 inline perms operator&(perms l , perms r) {
102 return static_cast(
103 static_cast(l) & static_cast(r));
97 inline perms operator|(perms l, perms r) {
98 return static_cast(static_cast(l) |
99 static_cast(r));
100 }
101 inline perms operator&(perms l, perms r) {
102 return static_cast(static_cast(l) &
103 static_cast(r));
104104 }
105105 inline perms &operator|=(perms &l, perms r) {
106106 l = l | r;
101101 return N;
102102 }
103103
104 template
105 typename GraphT::NodeType*
106 Eval(DominatorTreeBase& DT,
104 template
105 typename GraphT::NodeType *
106 Eval(DominatorTreeBase &DT,
107107 typename GraphT::NodeType *VIn, unsigned LastLinked) {
108108 typename DominatorTreeBase::InfoRec &VInInfo =
109109 DT.Info[VIn];
3232 template
3333 class PointerLikeTypeTraits {
3434 public:
35 static inline void *getAsVoidPointer(T* P) { return P; }
36 static inline T *getFromVoidPointer(void *P) {
37 return static_cast(P);
38 }
35 static inline void *getAsVoidPointer(T *P) { return P; }
36 static inline T *getFromVoidPointer(void *P) { return static_cast(P); }
3937
4038 /// Note, we assume here that malloc returns objects at least 4-byte aligned.
4139 /// However, this may be wrong, or pointers may be from something other than
3636 /// significant and shouldn't be counted as part of a duration.
3737 static TimeRecord getCurrentTime(bool Start = true);
3838
39 double getProcessTime() const { return UserTime+SystemTime; }
39 double getProcessTime() const { return UserTime + SystemTime; }
4040 double getUserTime() const { return UserTime; }
4141 double getSystemTime() const { return SystemTime; }
4242 double getWallTime() const { return WallTime; }
156156 class TimerGroup {
157157 std::string Name;
158158 Timer *FirstTimer; // First timer in the group.
159 std::vector > TimersToPrint;
159 std::vector> TimersToPrint;
160160
161161 TimerGroup **Prev, *Next; // Doubly linked list of TimerGroup's.
162162 TimerGroup(const TimerGroup &TG) = delete;
1616
1717 #include "llvm/Support/raw_ostream.h"
1818
19 namespace llvm
20 {
19 namespace llvm {
2120 /// circular_raw_ostream - A raw_ostream which *can* save its data
2221 /// to a circular buffer, or can pass it through directly to an
2322 /// underlying stream if specified with a buffer of zero.