llvm.org GIT mirror llvm / 43d1fd4
For PR1338: rename include/llvm/ADT/ilist and friends to end with ".h" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51687 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 11 years ago
31 changed file(s) with 1003 addition(s) and 1003 deletion(s). Raw diff Collapse all Expand all
7676 dist-hook::
7777 $(Echo) Eliminating files constructed by configure
7878 $(Verb) $(RM) -f \
79 $(TopDistDir)/include/llvm/ADT/hash_map \
80 $(TopDistDir)/include/llvm/ADT/hash_set \
81 $(TopDistDir)/include/llvm/ADT/iterator \
79 $(TopDistDir)/include/llvm/ADT/hash_map.h \
80 $(TopDistDir)/include/llvm/ADT/hash_set.h \
81 $(TopDistDir)/include/llvm/ADT/iterator.h \
8282 $(TopDistDir)/include/llvm/Config/config.h \
8383 $(TopDistDir)/include/llvm/Support/DataTypes.h \
8484 $(TopDistDir)/include/llvm/Support/ThreadSupport.h
9494 FilesToConfig := \
9595 include/llvm/Config/config.h \
9696 include/llvm/Support/DataTypes.h \
97 include/llvm/ADT/hash_map \
98 include/llvm/ADT/hash_set \
99 include/llvm/ADT/iterator
97 include/llvm/ADT/hash_map.h \
98 include/llvm/ADT/hash_set.h \
99 include/llvm/ADT/iterator.h
100100 FilesToConfigPATH := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
101101
102102 all-local:: $(FilesToConfigPATH)
980980 dnl files can be updated automatically when their *.in sources change.
981981 AC_CONFIG_HEADERS([include/llvm/Config/config.h])
982982 AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h])
983 AC_CONFIG_HEADERS([include/llvm/ADT/hash_map])
984 AC_CONFIG_HEADERS([include/llvm/ADT/hash_set])
985 AC_CONFIG_HEADERS([include/llvm/ADT/iterator])
983 AC_CONFIG_HEADERS([include/llvm/ADT/hash_map.h])
984 AC_CONFIG_HEADERS([include/llvm/ADT/hash_set.h])
985 AC_CONFIG_HEADERS([include/llvm/ADT/iterator.h])
986986
987987 dnl Configure the makefile's configuration data
988988 AC_CONFIG_FILES([Makefile.config])
3333 #define LLVM_ADT_DEPTHFIRSTITERATOR_H
3434
3535 #include "llvm/ADT/GraphTraits.h"
36 #include "llvm/ADT/iterator"
36 #include "llvm/ADT/iterator.h"
3737 #include "llvm/ADT/SmallPtrSet.h"
3838 #include
3939 #include
1414 #ifndef LLVM_ADT_EQUIVALENCECLASSES_H
1515 #define LLVM_ADT_EQUIVALENCECLASSES_H
1616
17 #include "llvm/ADT/iterator"
17 #include "llvm/ADT/iterator.h"
1818 #include "llvm/Support/DataTypes.h"
1919 #include
2020
1616 #ifndef LLVM_ADT_HASHEXTRAS_H
1717 #define LLVM_ADT_HASHEXTRAS_H
1818
19 #include "llvm/ADT/hash_map"
19 #include "llvm/ADT/hash_map.h"
2020 #include
2121
2222 // Cannot specialize hash template from outside of the std namespace.
1616 #define LLVM_ADT_POSTORDERITERATOR_H
1717
1818 #include "llvm/ADT/GraphTraits.h"
19 #include "llvm/ADT/iterator"
19 #include "llvm/ADT/iterator.h"
2020 #include
2121 #include
2222 #include
2121 #define LLVM_ADT_SCCITERATOR_H
2222
2323 #include "llvm/ADT/GraphTraits.h"
24 #include "llvm/ADT/iterator"
24 #include "llvm/ADT/iterator.h"
2525 #include
2626 #include
2727
1919 #include
2020 #include // for std::pair
2121 #include // for std::size_t
22 #include "llvm/ADT/iterator"
22 #include "llvm/ADT/iterator.h"
2323
2424 namespace llvm {
2525
1313 #ifndef LLVM_ADT_SMALLVECTOR_H
1414 #define LLVM_ADT_SMALLVECTOR_H
1515
16 #include "llvm/ADT/iterator"
16 #include "llvm/ADT/iterator.h"
1717 #include
1818 #include
1919
2020 #include "llvm/Support/DataTypes.h"
2121 #include "llvm/ADT/STLExtras.h"
2222 #include "llvm/Support/MathExtras.h"
23 #include "llvm/ADT/ilist"
23 #include "llvm/ADT/ilist.h"
2424 namespace llvm {
2525
2626 /// SparseBitVector is an implementation of a bitvector that is sparse by only
0 //==-- llvm/ADT/hash_map.h - "Portable" wrapper around hash_map --*- C++ -*-==//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides a wrapper around the mysterious header file
10 // that seems to move around between GCC releases into and out of namespaces at
11 // will. #including this header will cause hash_map to be available in the
12 // global namespace.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_ADT_HASH_MAP
17 #define LLVM_ADT_HASH_MAP
18
19 // Compiler Support Matrix
20 //
21 // Version Namespace Header File
22 // 2.95.x :: hash_map
23 // 3.0.4 std ext/hash_map
24 // 3.1 __gnu_cxx ext/hash_map
25 // HP aCC6 std stdex/rw/hashm*ap.h
26 // MS VC++ stdext hash_map
27
28 #undef HAVE_GNU_EXT_HASH_MAP
29 #undef HAVE_STD_EXT_HASH_MAP
30 #undef HAVE_GLOBAL_HASH_MAP
31 #undef HAVE_RW_STDEX_HASH_MAP_H
32
33 #if HAVE_GNU_EXT_HASH_MAP
34 // This is for GCC-3.1+ which puts hash in ext/hash_map
35 # include
36 # ifndef HASH_NAMESPACE
37 # define HASH_NAMESPACE __gnu_cxx
38 # endif
39
40 // GCC 3.0.x puts hash_map in and in the std namespace.
41 #elif HAVE_STD_EXT_HASH_MAP
42 # include
43 # ifndef HASH_NAMESPACE
44 # define HASH_NAMESPACE std
45 # endif
46
47 // Older compilers such as GCC before version 3.0 do not keep
48 // extensions in the `ext' directory, and ignore the `std' namespace.
49 #elif HAVE_GLOBAL_HASH_MAP
50 # include
51 # ifndef HASH_NAMESPACE
52 # define HASH_NAMESPACE std
53 # endif
54
55 // HP aCC doesn't include an SGI-like hash_map. For this platform (or
56 // any others using Rogue Wave Software's Tools.h++ library), we wrap
57 // around them in std::
58 #elif HAVE_RW_STDEX_HASH_MAP_H
59 # include
60 # include
61 # ifndef HASH_NAMESPACE
62 # define HASH_NAMESPACE std
63 # endif
64
65 // Support Microsoft VC++.
66 #elif defined(_MSC_VER)
67 # include
68 # ifndef HASH_NAMESPACE
69 # define HASH_NAMESPACE stdext
70 using std::_Distance;
71 # endif
72
73 // Give a warning if we couldn't find it, instead of (or in addition to)
74 // randomly doing something dumb.
75 #else
76 # warning "Autoconfiguration failed to find the hash_map header file."
77 #endif
78
79 // we wrap Rogue Wave Tools.h++ rw_hashmap into something SGI-looking, here:
80 #ifdef HAVE_RW_STDEX_HASH_MAP_H
81 namespace HASH_NAMESPACE {
82
83 template struct hash {
84 unsigned int operator()(const unsigned int& x) const {
85 return x;
86 }
87 };
88
89 template
90 typename ValueType,
91 class _HashFcn = hash,
92 class _EqualKey = equal_to,
93 class _A = allocator >
94 class hash_map : public rw_hashmap
95 class _EqualKey, class _A> {
96 };
97
98 template
99 typename ValueType,
100 class _HashFcn = hash,
101 class _EqualKey = equal_to,
102 class _A = allocator >
103 class hash_multimap : public rw_hashmultimap
104 class _EqualKey, class _A> {
105 };
106
107 } // end HASH_NAMESPACE;
108 #endif
109
110 // Include vector because ext/hash_map includes stl_vector.h and leaves
111 // out specializations like stl_bvector.h, causing link conflicts.
112 #include
113
114 #ifdef _MSC_VER
115
116 // GCC and VC++ have differing ways of implementing hash_maps. As it's not
117 // standardized, that's to be expected. This adapter class allows VC++
118 // hash_map to use GCC's hash classes.
119 namespace stdext {
120 template struct hash;
121
122 // Provide a hash function for unsigned ints...
123 template<> struct hash {
124 inline size_t operator()(unsigned int Val) const {
125 return Val;
126 }
127 };
128
129 template class hash_compare > {
130 std::less comp;
131 public:
132 enum { bucket_size = 4 };
133 enum { min_buckets = 8 };
134 hash_compare() {}
135 hash_compare(std::less pred) : comp(pred) {}
136 size_t operator()(const Key& key) const { return hash()(key); }
137 bool operator()(const Key& k1, const Key& k2) const { return comp(k1, k2); }
138 };
139 }
140
141 #endif
142
143 using HASH_NAMESPACE::hash_map;
144 using HASH_NAMESPACE::hash_multimap;
145 using HASH_NAMESPACE::hash;
146
147 #include "llvm/ADT/HashExtras.h"
148
149 #endif
+0
-150
include/llvm/ADT/hash_map.in less more
None //===-- llvm/ADT/hash_map - "Portable" wrapper around hash_map --*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides a wrapper around the mysterious header file
10 // that seems to move around between GCC releases into and out of namespaces at
11 // will. #including this header will cause hash_map to be available in the
12 // global namespace.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_ADT_HASH_MAP
17 #define LLVM_ADT_HASH_MAP
18
19 // Compiler Support Matrix
20 //
21 // Version Namespace Header File
22 // 2.95.x :: hash_map
23 // 3.0.4 std ext/hash_map
24 // 3.1 __gnu_cxx ext/hash_map
25 // HP aCC6 std stdex/rw/hashm*ap.h
26 // MS VC++ stdext hash_map
27
28 #undef HAVE_GNU_EXT_HASH_MAP
29 #undef HAVE_STD_EXT_HASH_MAP
30 #undef HAVE_GLOBAL_HASH_MAP
31 #undef HAVE_RW_STDEX_HASH_MAP_H
32
33 #if HAVE_GNU_EXT_HASH_MAP
34 // This is for GCC-3.1+ which puts hash in ext/hash_map
35 # include
36 # ifndef HASH_NAMESPACE
37 # define HASH_NAMESPACE __gnu_cxx
38 # endif
39
40 // GCC 3.0.x puts hash_map in and in the std namespace.
41 #elif HAVE_STD_EXT_HASH_MAP
42 # include
43 # ifndef HASH_NAMESPACE
44 # define HASH_NAMESPACE std
45 # endif
46
47 // Older compilers such as GCC before version 3.0 do not keep
48 // extensions in the `ext' directory, and ignore the `std' namespace.
49 #elif HAVE_GLOBAL_HASH_MAP
50 # include
51 # ifndef HASH_NAMESPACE
52 # define HASH_NAMESPACE std
53 # endif
54
55 // HP aCC doesn't include an SGI-like hash_map. For this platform (or
56 // any others using Rogue Wave Software's Tools.h++ library), we wrap
57 // around them in std::
58 #elif HAVE_RW_STDEX_HASH_MAP_H
59 # include
60 # include
61 # ifndef HASH_NAMESPACE
62 # define HASH_NAMESPACE std
63 # endif
64
65 // Support Microsoft VC++.
66 #elif defined(_MSC_VER)
67 # include
68 # ifndef HASH_NAMESPACE
69 # define HASH_NAMESPACE stdext
70 using std::_Distance;
71 # endif
72
73 // Give a warning if we couldn't find it, instead of (or in addition to)
74 // randomly doing something dumb.
75 #else
76 # warning "Autoconfiguration failed to find the hash_map header file."
77 #endif
78
79 // we wrap Rogue Wave Tools.h++ rw_hashmap into something SGI-looking, here:
80 #ifdef HAVE_RW_STDEX_HASH_MAP_H
81 namespace HASH_NAMESPACE {
82
83 template struct hash {
84 unsigned int operator()(const unsigned int& x) const {
85 return x;
86 }
87 };
88
89 template
90 typename ValueType,
91 class _HashFcn = hash,
92 class _EqualKey = equal_to,
93 class _A = allocator >
94 class hash_map : public rw_hashmap
95 class _EqualKey, class _A> {
96 };
97
98 template
99 typename ValueType,
100 class _HashFcn = hash,
101 class _EqualKey = equal_to,
102 class _A = allocator >
103 class hash_multimap : public rw_hashmultimap
104 class _EqualKey, class _A> {
105 };
106
107 } // end HASH_NAMESPACE;
108 #endif
109
110 // Include vector because ext/hash_map includes stl_vector.h and leaves
111 // out specializations like stl_bvector.h, causing link conflicts.
112 #include
113
114 #ifdef _MSC_VER
115
116 // GCC and VC++ have differing ways of implementing hash_maps. As it's not
117 // standardized, that's to be expected. This adapter class allows VC++
118 // hash_map to use GCC's hash classes.
119 namespace stdext {
120 template struct hash;
121
122 // Provide a hash function for unsigned ints...
123 template<> struct hash {
124 inline size_t operator()(unsigned int Val) const {
125 return Val;
126 }
127 };
128
129 template class hash_compare > {
130 std::less comp;
131 public:
132 enum { bucket_size = 4 };
133 enum { min_buckets = 8 };
134 hash_compare() {}
135 hash_compare(std::less pred) : comp(pred) {}
136 size_t operator()(const Key& key) const { return hash()(key); }
137 bool operator()(const Key& k1, const Key& k2) const { return comp(k1, k2); }
138 };
139 }
140
141 #endif
142
143 using HASH_NAMESPACE::hash_map;
144 using HASH_NAMESPACE::hash_multimap;
145 using HASH_NAMESPACE::hash;
146
147 #include "llvm/ADT/HashExtras.h"
148
149 #endif
0 //==-- llvm/ADT/hash_set.h - "Portable" wrapper around hash_set --*- C++ -*-==//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 // vim:ft=cpp
9 //
10 // This file provides a wrapper around the mysterious header file
11 // that seems to move around between GCC releases into and out of namespaces at
12 // will. #including this header will cause hash_set to be available in the
13 // global namespace.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_ADT_HASH_SET
18 #define LLVM_ADT_HASH_SET
19
20 // Compiler Support Matrix
21 //
22 // Version Namespace Header File
23 // 2.95.x :: hash_set
24 // 3.0.4 std ext/hash_set
25 // 3.1 __gnu_cxx ext/hash_set
26 // HP aCC6 std stdex/rw/hashset.h
27 // MS VC++ stdext hash_set
28
29 #undef HAVE_GNU_EXT_HASH_SET
30 #undef HAVE_STD_EXT_HASH_SET
31 #undef HAVE_GLOBAL_HASH_SET
32 #undef HAVE_RW_STDEX_HASH_SET_H
33
34 // GCC versions 3.1 and later put hash_set in and in
35 // the __gnu_cxx namespace.
36 #if HAVE_GNU_EXT_HASH_SET
37 # include
38 # ifndef HASH_NAMESPACE
39 # define HASH_NAMESPACE __gnu_cxx
40 # endif
41
42 // GCC 3.0.x puts hash_set in and in the std namespace.
43 #elif HAVE_STD_EXT_HASH_SET
44 # include
45 # ifndef HASH_NAMESPACE
46 # define HASH_NAMESPACE std
47 # endif
48
49 // Older compilers such as GCC before version 3.0 do not keep
50 // extensions in the `ext' directory, and ignore the `std' namespace.
51 #elif HAVE_GLOBAL_HASH_SET
52 # include
53 # ifndef HASH_NAMESPACE
54 # define HASH_NAMESPACE std
55 # endif
56
57 // HP aCC doesn't include an SGI-like hash_set. For this platform (or
58 // any others using Rogue Wave Software's Tools.h++ library), we wrap
59 // around them in std::
60 #elif HAVE_RW_STDEX_HASH_SET_H
61 # include
62 # ifndef HASH_NAMESPACE
63 # define HASH_NAMESPACE std
64 # endif
65
66 // Support Microsoft VC++.
67 #elif defined(_MSC_VER)
68 # include
69 # ifndef HASH_NAMESPACE
70 # define HASH_NAMESPACE stdext
71 # endif
72
73 // Give a warning if we couldn't find it, instead of (or in addition to)
74 // randomly doing something dumb.
75 #else
76 # warning "Autoconfiguration failed to find the hash_set header file."
77 #endif
78
79 // we wrap Rogue Wave Tools.h++ rw_hashset into something SGI-looking, here:
80 #ifdef HAVE_RW_STDEX_HASH_SET_H
81 namespace HASH_NAMESPACE {
82
83 /*
84 template struct hash {
85 unsigned int operator()(const unsigned int& x) const {
86 return x;
87 }
88 };
89 */
90
91 template
92 class _HashFcn = hash,
93 class _EqualKey = equal_to,
94 class _A = allocator >
95 class hash_set :
96 public rw_hashset {
97 };
98
99 } // end HASH_NAMESPACE;
100 #endif
101
102 using HASH_NAMESPACE::hash_set;
103
104 // Include vector because ext/hash_set includes stl_vector.h and leaves
105 // out specializations like stl_bvector.h, causing link conflicts.
106 #include
107
108 #include "llvm/ADT/HashExtras.h"
109
110 #endif
+0
-111
include/llvm/ADT/hash_set.in less more
None //===-- llvm/ADT/hash_set - "Portable" wrapper around hash_set --*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 // vim:ft=cpp
9 //
10 // This file provides a wrapper around the mysterious header file
11 // that seems to move around between GCC releases into and out of namespaces at
12 // will. #including this header will cause hash_set to be available in the
13 // global namespace.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_ADT_HASH_SET
18 #define LLVM_ADT_HASH_SET
19
20 // Compiler Support Matrix
21 //
22 // Version Namespace Header File
23 // 2.95.x :: hash_set
24 // 3.0.4 std ext/hash_set
25 // 3.1 __gnu_cxx ext/hash_set
26 // HP aCC6 std stdex/rw/hashset.h
27 // MS VC++ stdext hash_set
28
29 #undef HAVE_GNU_EXT_HASH_SET
30 #undef HAVE_STD_EXT_HASH_SET
31 #undef HAVE_GLOBAL_HASH_SET
32 #undef HAVE_RW_STDEX_HASH_SET_H
33
34 // GCC versions 3.1 and later put hash_set in and in
35 // the __gnu_cxx namespace.
36 #if HAVE_GNU_EXT_HASH_SET
37 # include
38 # ifndef HASH_NAMESPACE
39 # define HASH_NAMESPACE __gnu_cxx
40 # endif
41
42 // GCC 3.0.x puts hash_set in and in the std namespace.
43 #elif HAVE_STD_EXT_HASH_SET
44 # include
45 # ifndef HASH_NAMESPACE
46 # define HASH_NAMESPACE std
47 # endif
48
49 // Older compilers such as GCC before version 3.0 do not keep
50 // extensions in the `ext' directory, and ignore the `std' namespace.
51 #elif HAVE_GLOBAL_HASH_SET
52 # include
53 # ifndef HASH_NAMESPACE
54 # define HASH_NAMESPACE std
55 # endif
56
57 // HP aCC doesn't include an SGI-like hash_set. For this platform (or
58 // any others using Rogue Wave Software's Tools.h++ library), we wrap
59 // around them in std::
60 #elif HAVE_RW_STDEX_HASH_SET_H
61 # include
62 # ifndef HASH_NAMESPACE
63 # define HASH_NAMESPACE std
64 # endif
65
66 // Support Microsoft VC++.
67 #elif defined(_MSC_VER)
68 # include
69 # ifndef HASH_NAMESPACE
70 # define HASH_NAMESPACE stdext
71 # endif
72
73 // Give a warning if we couldn't find it, instead of (or in addition to)
74 // randomly doing something dumb.
75 #else
76 # warning "Autoconfiguration failed to find the hash_set header file."
77 #endif
78
79 // we wrap Rogue Wave Tools.h++ rw_hashset into something SGI-looking, here:
80 #ifdef HAVE_RW_STDEX_HASH_SET_H
81 namespace HASH_NAMESPACE {
82
83 /*
84 template struct hash {
85 unsigned int operator()(const unsigned int& x) const {
86 return x;
87 }
88 };
89 */
90
91 template
92 class _HashFcn = hash,
93 class _EqualKey = equal_to,
94 class _A = allocator >
95 class hash_set :
96 public rw_hashset {
97 };
98
99 } // end HASH_NAMESPACE;
100 #endif
101
102 using HASH_NAMESPACE::hash_set;
103
104 // Include vector because ext/hash_set includes stl_vector.h and leaves
105 // out specializations like stl_bvector.h, causing link conflicts.
106 #include
107
108 #include "llvm/ADT/HashExtras.h"
109
110 #endif
+0
-634
include/llvm/ADT/ilist less more
None //===-- llvm/ADT/ilist - Intrusive Linked List Template ---------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines classes to implement an intrusive doubly linked list class
10 // (i.e. each node of the list must contain a next and previous field for the
11 // list.
12 //
13 // The ilist_traits trait class is used to gain access to the next and previous
14 // fields of the node type that the list is instantiated with. If it is not
15 // specialized, the list defaults to using the getPrev(), getNext() method calls
16 // to get the next and previous pointers.
17 //
18 // The ilist class itself, should be a plug in replacement for list, assuming
19 // that the nodes contain next/prev pointers. This list replacement does not
20 // provide a constant time size() method, so be careful to use empty() when you
21 // really want to know if it's empty.
22 //
23 // The ilist class is implemented by allocating a 'tail' node when the list is
24 // created (using ilist_traits<>::createSentinel()). This tail node is
25 // absolutely required because the user must be able to compute end()-1. Because
26 // of this, users of the direct next/prev links will see an extra link on the
27 // end of the list, which should be ignored.
28 //
29 // Requirements for a user of this list:
30 //
31 // 1. The user must provide {g|s}et{Next|Prev} methods, or specialize
32 // ilist_traits to provide an alternate way of getting and setting next and
33 // prev links.
34 //
35 //===----------------------------------------------------------------------===//
36
37 #ifndef LLVM_ADT_ILIST
38 #define LLVM_ADT_ILIST
39
40 #include "llvm/ADT/iterator"
41 #include
42 #include
43
44 namespace llvm {
45
46 template class iplist;
47 template class ilist_iterator;
48
49 // Template traits for intrusive list. By specializing this template class, you
50 // can change what next/prev fields are used to store the links...
51 template
52 struct ilist_traits {
53 static NodeTy *getPrev(NodeTy *N) { return N->getPrev(); }
54 static NodeTy *getNext(NodeTy *N) { return N->getNext(); }
55 static const NodeTy *getPrev(const NodeTy *N) { return N->getPrev(); }
56 static const NodeTy *getNext(const NodeTy *N) { return N->getNext(); }
57
58 static void setPrev(NodeTy *N, NodeTy *Prev) { N->setPrev(Prev); }
59 static void setNext(NodeTy *N, NodeTy *Next) { N->setNext(Next); }
60
61 static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); }
62
63 static NodeTy *createSentinel() { return new NodeTy(); }
64 static void destroySentinel(NodeTy *N) { delete N; }
65
66 void addNodeToList(NodeTy *NTy) {}
67 void removeNodeFromList(NodeTy *NTy) {}
68 void transferNodesFromList(iplist &L2,
69 ilist_iterator first,
70 ilist_iterator last) {}
71 };
72
73 // Const traits are the same as nonconst traits...
74 template
75 struct ilist_traits : public ilist_traits {};
76
77
78 //===----------------------------------------------------------------------===//
79 // ilist_iterator - Iterator for intrusive list.
80 //
81 template
82 class ilist_iterator
83 : public bidirectional_iterator {
84 typedef ilist_traits Traits;
85 typedef bidirectional_iterator super;
86
87 public:
88 typedef size_t size_type;
89 typedef typename super::pointer pointer;
90 typedef typename super::reference reference;
91 private:
92 pointer NodePtr;
93 public:
94
95 ilist_iterator(pointer NP) : NodePtr(NP) {}
96 ilist_iterator(reference NR) : NodePtr(&NR) {}
97 ilist_iterator() : NodePtr(0) {}
98
99 // This is templated so that we can allow constructing a const iterator from
100 // a nonconst iterator...
101 template
102 ilist_iterator(const ilist_iterator &RHS)
103 : NodePtr(RHS.getNodePtrUnchecked()) {}
104
105 // This is templated so that we can allow assigning to a const iterator from
106 // a nonconst iterator...
107 template
108 const ilist_iterator &operator=(const ilist_iterator &RHS) {
109 NodePtr = RHS.getNodePtrUnchecked();
110 return *this;
111 }
112
113 // Accessors...
114 operator pointer() const {
115 assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
116 return NodePtr;
117 }
118
119 reference operator*() const {
120 assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
121 return *NodePtr;
122 }
123 pointer operator->() { return &operator*(); }
124 const pointer operator->() const { return &operator*(); }
125
126 // Comparison operators
127 bool operator==(const ilist_iterator &RHS) const {
128 return NodePtr == RHS.NodePtr;
129 }
130 bool operator!=(const ilist_iterator &RHS) const {
131 return NodePtr != RHS.NodePtr;
132 }
133
134 // Increment and decrement operators...
135 ilist_iterator &operator--() { // predecrement - Back up
136 NodePtr = Traits::getPrev(NodePtr);
137 assert(Traits::getNext(NodePtr) && "--'d off the beginning of an ilist!");
138 return *this;
139 }
140 ilist_iterator &operator++() { // preincrement - Advance
141 NodePtr = Traits::getNext(NodePtr);
142 assert(NodePtr && "++'d off the end of an ilist!");
143 return *this;
144 }
145 ilist_iterator operator--(int) { // postdecrement operators...
146 ilist_iterator tmp = *this;
147 --*this;
148 return tmp;
149 }
150 ilist_iterator operator++(int) { // postincrement operators...
151 ilist_iterator tmp = *this;
152 ++*this;
153 return tmp;
154 }
155
156 // Internal interface, do not use...
157 pointer getNodePtrUnchecked() const { return NodePtr; }
158 };
159
160 // do not implement. this is to catch errors when people try to use
161 // them as random access iterators
162 template
163 void operator-(int, ilist_iterator);
164 template
165 void operator-(ilist_iterator,int);
166
167 template
168 void operator+(int, ilist_iterator);
169 template
170 void operator+(ilist_iterator,int);
171
172 // operator!=/operator== - Allow mixed comparisons without dereferencing
173 // the iterator, which could very likely be pointing to end().
174 template
175 bool operator!=(const T* LHS, const ilist_iterator &RHS) {
176 return LHS != RHS.getNodePtrUnchecked();
177 }
178 template
179 bool operator==(const T* LHS, const ilist_iterator &RHS) {
180 return LHS == RHS.getNodePtrUnchecked();
181 }
182 template
183 bool operator!=(T* LHS, const ilist_iterator &RHS) {
184 return LHS != RHS.getNodePtrUnchecked();
185 }
186 template
187 bool operator==(T* LHS, const ilist_iterator &RHS) {
188 return LHS == RHS.getNodePtrUnchecked();
189 }
190
191
192 // Allow ilist_iterators to convert into pointers to a node automatically when
193 // used by the dyn_cast, cast, isa mechanisms...
194
195 template struct simplify_type;
196
197 template struct simplify_type > {
198 typedef NodeTy* SimpleType;
199
200 static SimpleType getSimplifiedValue(const ilist_iterator &Node) {
201 return &*Node;
202 }
203 };
204 template struct simplify_type > {
205 typedef NodeTy* SimpleType;
206
207 static SimpleType getSimplifiedValue(const ilist_iterator &Node) {
208 return &*Node;
209 }
210 };
211
212
213 //===----------------------------------------------------------------------===//
214 //
215 /// iplist - The subset of list functionality that can safely be used on nodes
216 /// of polymorphic types, i.e. a heterogenous list with a common base class that
217 /// holds the next/prev pointers. The only state of the list itself is a single
218 /// pointer to the head of the list.
219 ///
220 /// This list can be in one of three interesting states:
221 /// 1. The list may be completely unconstructed. In this case, the head
222 /// pointer is null. When in this form, any query for an iterator (e.g.
223 /// begin() or end()) causes the list to transparently change to state #2.
224 /// 2. The list may be empty, but contain a sentinal for the end iterator. This
225 /// sentinal is created by the Traits::createSentinel method and is a link
226 /// in the list. When the list is empty, the pointer in the iplist points
227 /// to the sentinal. Once the sentinal is constructed, it
228 /// is not destroyed until the list is.
229 /// 3. The list may contain actual objects in it, which are stored as a doubly
230 /// linked list of nodes. One invariant of the list is that the predecessor
231 /// of the first node in the list always points to the last node in the list,
232 /// and the successor pointer for the sentinal (which always stays at the
233 /// end of the list) is always null.
234 ///
235 template >
236 class iplist : public Traits {
237 mutable NodeTy *Head;
238
239 // Use the prev node pointer of 'head' as the tail pointer. This is really a
240 // circularly linked list where we snip the 'next' link from the sentinel node
241 // back to the first node in the list (to preserve assertions about going off
242 // the end of the list).
243 NodeTy *getTail() { return getPrev(Head); }
244 const NodeTy *getTail() const { return getPrev(Head); }
245 void setTail(NodeTy *N) const { setPrev(Head, N); }
246
247 /// CreateLazySentinal - This method verifies whether the sentinal for the
248 /// list has been created and lazily makes it if not.
249 void CreateLazySentinal() const {
250 if (Head != 0) return;
251 Head = Traits::createSentinel();
252 setNext(Head, 0);
253 setTail(Head);
254 }
255
256 static bool op_less(NodeTy &L, NodeTy &R) { return L < R; }
257 static bool op_equal(NodeTy &L, NodeTy &R) { return L == R; }
258 public:
259 typedef NodeTy *pointer;
260 typedef const NodeTy *const_pointer;
261 typedef NodeTy &reference;
262 typedef const NodeTy &const_reference;
263 typedef NodeTy value_type;
264 typedef ilist_iterator iterator;
265 typedef ilist_iterator const_iterator;
266 typedef size_t size_type;
267 typedef ptrdiff_t difference_type;
268 typedef std::reverse_iterator const_reverse_iterator;
269 typedef std::reverse_iterator reverse_iterator;
270
271 iplist() : Head(0) {}
272 ~iplist() {
273 if (!Head) return;
274 clear();
275 Traits::destroySentinel(getTail());
276 }
277
278 // Iterator creation methods.
279 iterator begin() {
280 CreateLazySentinal();
281 return iterator(Head);
282 }
283 const_iterator begin() const {
284 CreateLazySentinal();
285 return const_iterator(Head);
286 }
287 iterator end() {
288 CreateLazySentinal();
289 return iterator(getTail());
290 }
291 const_iterator end() const {
292 CreateLazySentinal();
293 return const_iterator(getTail());
294 }
295
296 // reverse iterator creation methods.
297 reverse_iterator rbegin() { return reverse_iterator(end()); }
298 const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
299 reverse_iterator rend() { return reverse_iterator(begin()); }
300 const_reverse_iterator rend() const { return const_reverse_iterator(begin());}
301
302
303 // Miscellaneous inspection routines.
304 size_type max_size() const { return size_type(-1); }
305 bool empty() const { return Head == 0 || Head == getTail(); }
306
307 // Front and back accessor functions...
308 reference front() {
309 assert(!empty() && "Called front() on empty list!");
310 return *Head;
311 }
312 const_reference front() const {
313 assert(!empty() && "Called front() on empty list!");
314 return *Head;
315 }
316 reference back() {
317 assert(!empty() && "Called back() on empty list!");
318 return *getPrev(getTail());
319 }
320 const_reference back() const {
321 assert(!empty() && "Called back() on empty list!");
322 return *getPrev(getTail());
323 }
324
325 void swap(iplist &RHS) {
326 abort(); // Swap does not use list traits callback correctly yet!
327 std::swap(Head, RHS.Head);
328 }
329
330 iterator insert(iterator where, NodeTy *New) {
331 NodeTy *CurNode = where.getNodePtrUnchecked(), *PrevNode = getPrev(CurNode);
332 setNext(New, CurNode);
333 setPrev(New, PrevNode);
334
335 if (CurNode != Head) // Is PrevNode off the beginning of the list?
336 setNext(PrevNode, New);
337 else
338 Head = New;
339 setPrev(CurNode, New);
340
341 addNodeToList(New); // Notify traits that we added a node...
342 return New;
343 }
344
345 NodeTy *remove(iterator &IT) {
346 assert(IT != end() && "Cannot remove end of list!");
347 NodeTy *Node = &*IT;
348 NodeTy *NextNode = getNext(Node);
349 NodeTy *PrevNode = getPrev(Node);
350
351 if (Node != Head) // Is PrevNode off the beginning of the list?
352 setNext(PrevNode, NextNode);
353 else
354 Head = NextNode;
355 setPrev(NextNode, PrevNode);
356 IT = NextNode;
357 removeNodeFromList(Node); // Notify traits that we removed a node...
358
359 // Set the next/prev pointers of the current node to null. This isn't
360 // strictly required, but this catches errors where a node is removed from
361 // an ilist (and potentially deleted) with iterators still pointing at it.
362 // When those iterators are incremented or decremented, they will assert on
363 // the null next/prev pointer instead of "usually working".
364 setNext(Node, 0);
365 setPrev(Node, 0);
366 return Node;
367 }
368
369 NodeTy *remove(const iterator &IT) {
370 iterator MutIt = IT;
371 return remove(MutIt);
372 }
373
374 // erase - remove a node from the controlled sequence... and delete it.
375 iterator erase(iterator where) {
376 delete remove(where);
377 return where;
378 }
379
380
381 private:
382 // transfer - The heart of the splice function. Move linked list nodes from
383 // [first, last) into position.
384 //
385 void transfer(iterator position, iplist &L2, iterator first, iterator last) {
386 assert(first != last && "Should be checked by callers");
387
388 if (position != last) {
389 // Note: we have to be careful about the case when we move the first node
390 // in the list. This node is the list sentinel node and we can't move it.
391 NodeTy *ThisSentinel = getTail();
392 setTail(0);
393 NodeTy *L2Sentinel = L2.getTail();
394 L2.setTail(0);
395
396 // Remove [first, last) from its old position.
397 NodeTy *First = &*first, *Prev = getPrev(First);
398 NodeTy *Next = last.getNodePtrUnchecked(), *Last = getPrev(Next);
399 if (Prev)
400 setNext(Prev, Next);
401 else
402 L2.Head = Next;
403 setPrev(Next, Prev);
404
405 // Splice [first, last) into its new position.
406 NodeTy *PosNext = position.getNodePtrUnchecked();
407 NodeTy *PosPrev = getPrev(PosNext);
408
409 // Fix head of list...
410 if (PosPrev)
411 setNext(PosPrev, First);
412 else
413 Head = First;
414 setPrev(First, PosPrev);
415
416 // Fix end of list...
417 setNext(Last, PosNext);
418 setPrev(PosNext, Last);
419
420 transferNodesFromList(L2, First, PosNext);
421
422 // Now that everything is set, restore the pointers to the list sentinals.
423 L2.setTail(L2Sentinel);
424 setTail(ThisSentinel);
425 }
426 }
427
428 public:
429
430 //===----------------------------------------------------------------------===
431 // Functionality derived from other functions defined above...
432 //
433
434 size_type size() const {
435 if (Head == 0) return 0; // Don't require construction of sentinal if empty.
436 #if __GNUC__ == 2
437 // GCC 2.95 has a broken std::distance
438 size_type Result = 0;
439 std::distance(begin(), end(), Result);
440 return Result;
441 #else
442 return std::distance(begin(), end());
443 #endif
444 }
445
446 iterator erase(iterator first, iterator last) {
447 while (first != last)
448 first = erase(first);
449 return last;
450 }
451
452 void clear() { if (Head) erase(begin(), end()); }
453
454 // Front and back inserters...
455 void push_front(NodeTy *val) { insert(begin(), val); }
456 void push_back(NodeTy *val) { insert(end(), val); }
457 void pop_front() {
458 assert(!empty() && "pop_front() on empty list!");
459 erase(begin());
460 }
461 void pop_back() {
462 assert(!empty() && "pop_back() on empty list!");
463 iterator t = end(); erase(--t);
464 }
465
466 // Special forms of insert...
467 template void insert(iterator where, InIt first, InIt last) {
468 for (; first != last; ++first) insert(where, *first);
469 }
470
471 // Splice members - defined in terms of transfer...
472 void splice(iterator where, iplist &L2) {
473 if (!L2.empty())
474 transfer(where, L2, L2.begin(), L2.end());
475 }
476 void splice(iterator where, iplist &L2, iterator first) {
477 iterator last = first; ++last;
478 if (where == first || where == last) return; // No change
479 transfer(where, L2, first, last);
480 }
481 void splice(iterator where, iplist &L2, iterator first, iterator last) {
482 if (first != last) transfer(where, L2, first, last);
483 }
484
485
486
487 //===----------------------------------------------------------------------===
488 // High-Level Functionality that shouldn't really be here, but is part of list
489 //
490
491 // These two functions are actually called remove/remove_if in list<>, but
492 // they actually do the job of erase, rename them accordingly.
493 //
494 void erase(const NodeTy &val) {
495 for (iterator I = begin(), E = end(); I != E; ) {
496 iterator next = I; ++next;
497 if (*I == val) erase(I);
498 I = next;
499 }
500 }
501 template void erase_if(Pr1 pred) {
502 for (iterator I = begin(), E = end(); I != E; ) {
503 iterator next = I; ++next;
504 if (pred(*I)) erase(I);
505 I = next;
506 }
507 }
508
509 template void unique(Pr2 pred) {
510 if (empty()) return;
511 for (iterator I = begin(), E = end(), Next = begin(); ++Next != E;) {
512 if (pred(*I))
513 erase(Next);
514 else
515 I = Next;
516 Next = I;
517 }
518 }
519 void unique() { unique(op_equal); }
520
521 template void merge(iplist &right, Pr3 pred) {
522 iterator first1 = begin(), last1 = end();
523 iterator first2 = right.begin(), last2 = right.end();
524 while (first1 != last1 && first2 != last2)
525 if (pred(*first2, *first1)) {
526 iterator next = first2;
527 transfer(first1, right, first2, ++next);
528 first2 = next;
529 } else {
530 ++first1;
531 }
532 if (first2 != last2) transfer(last1, right, first2, last2);
533 }
534 void merge(iplist &right) { return merge(right, op_less); }
535
536 template void sort(Pr3 pred);
537 void sort() { sort(op_less); }
538 void reverse();
539 };
540
541
542 template
543 struct ilist : public iplist {
544 typedef typename iplist::size_type size_type;
545 typedef typename iplist::iterator iterator;
546
547 ilist() {}
548 ilist(const ilist &right) {
549 insert(this->begin(), right.begin(), right.end());
550 }
551 explicit ilist(size_type count) {
552 insert(this->begin(), count, NodeTy());
553 }
554 ilist(size_type count, const NodeTy &val) {
555 insert(this->begin(), count, val);
556 }
557 template ilist(InIt first, InIt last) {
558 insert(this->begin(), first, last);
559 }
560
561
562 // Forwarding functions: A workaround for GCC 2.95 which does not correctly
563 // support 'using' declarations to bring a hidden member into scope.
564 //
565 iterator insert(iterator a, NodeTy *b){ return iplist::insert(a, b); }
566 void push_front(NodeTy *a) { iplist::push_front(a); }
567 void push_back(NodeTy *a) { iplist::push_back(a); }
568
569
570 // Main implementation here - Insert for a node passed by value...
571 iterator insert(iterator where, const NodeTy &val) {
572 return insert(where, createNode(val));
573 }
574
575
576 // Front and back inserters...
577 void push_front(const NodeTy &val) { insert(this->begin(), val); }
578 void push_back(const NodeTy &val) { insert(this->end(), val); }
579
580 // Special forms of insert...
581 template void insert(iterator where, InIt first, InIt last) {
582 for (; first != last; ++first) insert(where, *first);
583 }
584 void insert(iterator where, size_type count, const NodeTy &val) {
585 for (; count != 0; --count) insert(where, val);
586 }
587
588 // Assign special forms...
589 void assign(size_type count, const NodeTy &val) {
590 iterator I = this->begin();
591 for (; I != this->end() && count != 0; ++I, --count)
592 *I = val;
593 if (count != 0)
594 insert(this->end(), val, val);
595 else
596 erase(I, this->end());
597 }
598 template void assign(InIt first1, InIt last1) {
599 iterator first2 = this->begin(), last2 = this->end();
600 for ( ; first1 != last1 && first2 != last2; ++first1, ++first2)
601 *first1 = *first2;
602 if (first2 == last2)
603 erase(first1, last1);
604 else
605 insert(last1, first2, last2);
606 }
607
608
609 // Resize members...
610 void resize(size_type newsize, NodeTy val) {
611 iterator i = this->begin();
612 size_type len = 0;
613 for ( ; i != this->end() && len < newsize; ++i, ++len) /* empty*/ ;
614
615 if (len == newsize)
616 erase(i, this->end());
617 else // i == end()
618 insert(this->end(), newsize - len, val);
619 }
620 void resize(size_type newsize) { resize(newsize, NodeTy()); }
621 };
622
623 } // End llvm namespace
624
625 namespace std {
626 // Ensure that swap uses the fast list swap...
627 template
628 void swap(llvm::iplist &Left, llvm::iplist &Right) {
629 Left.swap(Right);
630 }
631 } // End 'std' extensions...
632
633 #endif
0 //==-- llvm/ADT/ilist.h - Intrusive Linked List Template ---------*- C++ -*-==//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines classes to implement an intrusive doubly linked list class
10 // (i.e. each node of the list must contain a next and previous field for the
11 // list.
12 //
13 // The ilist_traits trait class is used to gain access to the next and previous
14 // fields of the node type that the list is instantiated with. If it is not
15 // specialized, the list defaults to using the getPrev(), getNext() method calls
16 // to get the next and previous pointers.
17 //
18 // The ilist class itself, should be a plug in replacement for list, assuming
19 // that the nodes contain next/prev pointers. This list replacement does not
20 // provide a constant time size() method, so be careful to use empty() when you
21 // really want to know if it's empty.
22 //
23 // The ilist class is implemented by allocating a 'tail' node when the list is
24 // created (using ilist_traits<>::createSentinel()). This tail node is
25 // absolutely required because the user must be able to compute end()-1. Because
26 // of this, users of the direct next/prev links will see an extra link on the
27 // end of the list, which should be ignored.
28 //
29 // Requirements for a user of this list:
30 //
31 // 1. The user must provide {g|s}et{Next|Prev} methods, or specialize
32 // ilist_traits to provide an alternate way of getting and setting next and
33 // prev links.
34 //
35 //===----------------------------------------------------------------------===//
36
37 #ifndef LLVM_ADT_ILIST
38 #define LLVM_ADT_ILIST
39
40 #include "llvm/ADT/iterator.h"
41 #include
42 #include
43
44 namespace llvm {
45
46 template class iplist;
47 template class ilist_iterator;
48
49 // Template traits for intrusive list. By specializing this template class, you
50 // can change what next/prev fields are used to store the links...
51 template
52 struct ilist_traits {
53 static NodeTy *getPrev(NodeTy *N) { return N->getPrev(); }
54 static NodeTy *getNext(NodeTy *N) { return N->getNext(); }
55 static const NodeTy *getPrev(const NodeTy *N) { return N->getPrev(); }
56 static const NodeTy *getNext(const NodeTy *N) { return N->getNext(); }
57
58 static void setPrev(NodeTy *N, NodeTy *Prev) { N->setPrev(Prev); }
59 static void setNext(NodeTy *N, NodeTy *Next) { N->setNext(Next); }
60
61 static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); }
62
63 static NodeTy *createSentinel() { return new NodeTy(); }
64 static void destroySentinel(NodeTy *N) { delete N; }
65
66 void addNodeToList(NodeTy *NTy) {}
67 void removeNodeFromList(NodeTy *NTy) {}
68 void transferNodesFromList(iplist &L2,
69 ilist_iterator first,
70 ilist_iterator last) {}
71 };
72
73 // Const traits are the same as nonconst traits...
74 template
75 struct ilist_traits : public ilist_traits {};
76
77
78 //===----------------------------------------------------------------------===//
79 // ilist_iterator - Iterator for intrusive list.
80 //
81 template
82 class ilist_iterator
83 : public bidirectional_iterator {
84 typedef ilist_traits Traits;
85 typedef bidirectional_iterator super;
86
87 public:
88 typedef size_t size_type;
89 typedef typename super::pointer pointer;
90 typedef typename super::reference reference;
91 private:
92 pointer NodePtr;
93 public:
94
95 ilist_iterator(pointer NP) : NodePtr(NP) {}
96 ilist_iterator(reference NR) : NodePtr(&NR) {}
97 ilist_iterator() : NodePtr(0) {}
98
99 // This is templated so that we can allow constructing a const iterator from
100 // a nonconst iterator...
101 template
102 ilist_iterator(const ilist_iterator &RHS)
103 : NodePtr(RHS.getNodePtrUnchecked()) {}
104
105 // This is templated so that we can allow assigning to a const iterator from
106 // a nonconst iterator...
107 template
108 const ilist_iterator &operator=(const ilist_iterator &RHS) {
109 NodePtr = RHS.getNodePtrUnchecked();
110 return *this;
111 }
112
113 // Accessors...
114 operator pointer() const {
115 assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
116 return NodePtr;
117 }
118
119 reference operator*() const {
120 assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!");
121 return *NodePtr;
122 }
123 pointer operator->() { return &operator*(); }
124 const pointer operator->() const { return &operator*(); }
125
126 // Comparison operators
127 bool operator==(const ilist_iterator &RHS) const {
128 return NodePtr == RHS.NodePtr;
129 }
130 bool operator!=(const ilist_iterator &RHS) const {
131 return NodePtr != RHS.NodePtr;
132 }
133
134 // Increment and decrement operators...
135 ilist_iterator &operator--() { // predecrement - Back up
136 NodePtr = Traits::getPrev(NodePtr);
137 assert(Traits::getNext(NodePtr) && "--'d off the beginning of an ilist!");
138 return *this;
139 }
140 ilist_iterator &operator++() { // preincrement - Advance
141 NodePtr = Traits::getNext(NodePtr);
142 assert(NodePtr && "++'d off the end of an ilist!");
143 return *this;
144 }
145 ilist_iterator operator--(int) { // postdecrement operators...
146 ilist_iterator tmp = *this;
147 --*this;
148 return tmp;
149 }
150 ilist_iterator operator++(int) { // postincrement operators...
151 ilist_iterator tmp = *this;
152 ++*this;
153 return tmp;
154 }
155
156 // Internal interface, do not use...
157 pointer getNodePtrUnchecked() const { return NodePtr; }
158 };
159
160 // do not implement. this is to catch errors when people try to use
161 // them as random access iterators
162 template
163 void operator-(int, ilist_iterator);
164 template
165 void operator-(ilist_iterator,int);
166
167 template
168 void operator+(int, ilist_iterator);
169 template
170 void operator+(ilist_iterator,int);
171
172 // operator!=/operator== - Allow mixed comparisons without dereferencing
173 // the iterator, which could very likely be pointing to end().
174 template
175 bool operator!=(const T* LHS, const ilist_iterator &RHS) {
176 return LHS != RHS.getNodePtrUnchecked();
177 }
178 template
179 bool operator==(const T* LHS, const ilist_iterator &RHS) {
180 return LHS == RHS.getNodePtrUnchecked();
181 }
182 template
183 bool operator!=(T* LHS, const ilist_iterator &RHS) {
184 return LHS != RHS.getNodePtrUnchecked();
185 }
186 template
187 bool operator==(T* LHS, const ilist_iterator &RHS) {
188 return LHS == RHS.getNodePtrUnchecked();
189 }
190
191
192 // Allow ilist_iterators to convert into pointers to a node automatically when
193 // used by the dyn_cast, cast, isa mechanisms...
194
195 template struct simplify_type;
196
197 template struct simplify_type > {
198 typedef NodeTy* SimpleType;
199
200 static SimpleType getSimplifiedValue(const ilist_iterator &Node) {
201 return &*Node;
202 }
203 };
204 template struct simplify_type > {
205 typedef NodeTy* SimpleType;
206
207 static SimpleType getSimplifiedValue(const ilist_iterator &Node) {
208 return &*Node;
209 }
210 };
211
212
213 //===----------------------------------------------------------------------===//
214 //
215 /// iplist - The subset of list functionality that can safely be used on nodes
216 /// of polymorphic types, i.e. a heterogenous list with a common base class that
217 /// holds the next/prev pointers. The only state of the list itself is a single
218 /// pointer to the head of the list.
219 ///
220 /// This list can be in one of three interesting states:
221 /// 1. The list may be completely unconstructed. In this case, the head
222 /// pointer is null. When in this form, any query for an iterator (e.g.
223 /// begin() or end()) causes the list to transparently change to state #2.
224 /// 2. The list may be empty, but contain a sentinal for the end iterator. This
225 /// sentinal is created by the Traits::createSentinel method and is a link
226 /// in the list. When the list is empty, the pointer in the iplist points
227 /// to the sentinal. Once the sentinal is constructed, it
228 /// is not destroyed until the list is.
229 /// 3. The list may contain actual objects in it, which are stored as a doubly
230 /// linked list of nodes. One invariant of the list is that the predecessor
231 /// of the first node in the list always points to the last node in the list,
232 /// and the successor pointer for the sentinal (which always stays at the
233 /// end of the list) is always null.
234 ///
235 template >
236 class iplist : public Traits {
237 mutable NodeTy *Head;
238
239 // Use the prev node pointer of 'head' as the tail pointer. This is really a
240 // circularly linked list where we snip the 'next' link from the sentinel node
241 // back to the first node in the list (to preserve assertions about going off
242 // the end of the list).
243 NodeTy *getTail() { return getPrev(Head); }
244 const NodeTy *getTail() const { return getPrev(Head); }
245 void setTail(NodeTy *N) const { setPrev(Head, N); }
246
247 /// CreateLazySentinal - This method verifies whether the sentinal for the
248 /// list has been created and lazily makes it if not.
249 void CreateLazySentinal() const {
250 if (Head != 0) return;
251 Head = Traits::createSentinel();
252 setNext(Head, 0);
253 setTail(Head);
254 }
255
256 static bool op_less(NodeTy &L, NodeTy &R) { return L < R; }
257 static bool op_equal(NodeTy &L, NodeTy &R) { return L == R; }
258 public:
259 typedef NodeTy *pointer;
260 typedef const NodeTy *const_pointer;
261 typedef NodeTy &reference;
262 typedef const NodeTy &const_reference;
263 typedef NodeTy value_type;
264 typedef ilist_iterator iterator;
265 typedef ilist_iterator const_iterator;
266 typedef size_t size_type;
267 typedef ptrdiff_t difference_type;
268 typedef std::reverse_iterator const_reverse_iterator;
269 typedef std::reverse_iterator reverse_iterator;
270
271 iplist() : Head(0) {}
272 ~iplist() {
273 if (!Head) return;
274 clear();
275 Traits::destroySentinel(getTail());
276 }
277
278 // Iterator creation methods.
279 iterator begin() {
280 CreateLazySentinal();
281 return iterator(Head);
282 }
283 const_iterator begin() const {
284 CreateLazySentinal();
285 return const_iterator(Head);
286 }
287 iterator end() {
288 CreateLazySentinal();
289 return iterator(getTail());
290 }
291 const_iterator end() const {
292 CreateLazySentinal();
293 return const_iterator(getTail());
294 }
295
296 // reverse iterator creation methods.
297 reverse_iterator rbegin() { return reverse_iterator(end()); }
298 const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
299 reverse_iterator rend() { return reverse_iterator(begin()); }
300 const_reverse_iterator rend() const { return const_reverse_iterator(begin());}
301
302
303 // Miscellaneous inspection routines.
304 size_type max_size() const { return size_type(-1); }
305 bool empty() const { return Head == 0 || Head == getTail(); }
306
307 // Front and back accessor functions...
308 reference front() {
309 assert(!empty() && "Called front() on empty list!");
310 return *Head;
311 }
312 const_reference front() const {
313 assert(!empty() && "Called front() on empty list!");
314 return *Head;
315 }
316 reference back() {
317 assert(!empty() && "Called back() on empty list!");
318 return *getPrev(getTail());
319 }
320 const_reference back() const {
321 assert(!empty() && "Called back() on empty list!");
322 return *getPrev(getTail());
323 }
324
325 void swap(iplist &RHS) {
326 abort(); // Swap does not use list traits callback correctly yet!
327 std::swap(Head, RHS.Head);
328 }
329
330 iterator insert(iterator where, NodeTy *New) {
331 NodeTy *CurNode = where.getNodePtrUnchecked(), *PrevNode = getPrev(CurNode);
332 setNext(New, CurNode);
333 setPrev(New, PrevNode);
334
335 if (CurNode != Head) // Is PrevNode off the beginning of the list?
336 setNext(PrevNode, New);
337 else
338 Head = New;
339 setPrev(CurNode, New);
340
341 addNodeToList(New); // Notify traits that we added a node...
342 return New;
343 }
344
345 NodeTy *remove(iterator &IT) {
346 assert(IT != end() && "Cannot remove end of list!");
347 NodeTy *Node = &*IT;
348 NodeTy *NextNode = getNext(Node);
349 NodeTy *PrevNode = getPrev(Node);
350
351 if (Node != Head) // Is PrevNode off the beginning of the list?
352 setNext(PrevNode, NextNode);
353 else
354 Head = NextNode;
355 setPrev(NextNode, PrevNode);
356 IT = NextNode;
357 removeNodeFromList(Node); // Notify traits that we removed a node...
358
359 // Set the next/prev pointers of the current node to null. This isn't
360 // strictly required, but this catches errors where a node is removed from
361 // an ilist (and potentially deleted) with iterators still pointing at it.
362 // When those iterators are incremented or decremented, they will assert on
363 // the null next/prev pointer instead of "usually working".
364 setNext(Node, 0);
365 setPrev(Node, 0);
366 return Node;
367 }
368
369 NodeTy *remove(const iterator &IT) {
370 iterator MutIt = IT;
371 return remove(MutIt);
372 }
373
374 // erase - remove a node from the controlled sequence... and delete it.
375 iterator erase(iterator where) {
376 delete remove(where);
377 return where;
378 }
379
380
381 private:
382 // transfer - The heart of the splice function. Move linked list nodes from
383 // [first, last) into position.
384 //
385 void transfer(iterator position, iplist &L2, iterator first, iterator last) {
386 assert(first != last && "Should be checked by callers");
387
388 if (position != last) {
389 // Note: we have to be careful about the case when we move the first node
390 // in the list. This node is the list sentinel node and we can't move it.
391 NodeTy *ThisSentinel = getTail();
392 setTail(0);
393 NodeTy *L2Sentinel = L2.getTail();
394 L2.setTail(0);
395
396 // Remove [first, last) from its old position.
397 NodeTy *First = &*first, *Prev = getPrev(First);
398 NodeTy *Next = last.getNodePtrUnchecked(), *Last = getPrev(Next);
399 if (Prev)
400 setNext(Prev, Next);
401 else
402 L2.Head = Next;
403 setPrev(Next, Prev);
404
405 // Splice [first, last) into its new position.
406 NodeTy *PosNext = position.getNodePtrUnchecked();
407 NodeTy *PosPrev = getPrev(PosNext);
408
409 // Fix head of list...
410 if (PosPrev)
411 setNext(PosPrev, First);
412 else
413 Head = First;
414 setPrev(First, PosPrev);
415
416 // Fix end of list...
417 setNext(Last, PosNext);
418 setPrev(PosNext, Last);
419
420 transferNodesFromList(L2, First, PosNext);
421
422 // Now that everything is set, restore the pointers to the list sentinals.
423 L2.setTail(L2Sentinel);
424 setTail(ThisSentinel);
425 }
426 }
427
428 public:
429
430 //===----------------------------------------------------------------------===
431 // Functionality derived from other functions defined above...
432 //
433
434 size_type size() const {
435 if (Head == 0) return 0; // Don't require construction of sentinal if empty.
436 #if __GNUC__ == 2
437 // GCC 2.95 has a broken std::distance
438 size_type Result = 0;
439 std::distance(begin(), end(), Result);
440 return Result;
441 #else
442 return std::distance(begin(), end());
443 #endif
444 }
445
446 iterator erase(iterator first, iterator last) {
447 while (first != last)
448 first = erase(first);
449 return last;
450 }
451
452 void clear() { if (Head) erase(begin(), end()); }
453
454 // Front and back inserters...
455 void push_front(NodeTy *val) { insert(begin(), val); }
456 void push_back(NodeTy *val) { insert(end(), val); }
457 void pop_front() {
458 assert(!empty() && "pop_front() on empty list!");
459 erase(begin());
460 }
461 void pop_back() {
462 assert(!empty() && "pop_back() on empty list!");
463 iterator t = end(); erase(--t);
464 }
465
466 // Special forms of insert...
467 template void insert(iterator where, InIt first, InIt last) {
468 for (; first != last; ++first) insert(where, *first);
469 }
470
471 // Splice members - defined in terms of transfer...
472 void splice(iterator where, iplist &L2) {
473 if (!L2.empty())
474 transfer(where, L2, L2.begin(), L2.end());
475 }
476 void splice(iterator where, iplist &L2, iterator first) {
477 iterator last = first; ++last;
478 if (where == first || where == last) return; // No change
479 transfer(where, L2, first, last);
480 }
481 void splice(iterator where, iplist &L2, iterator first, iterator last) {
482 if (first != last) transfer(where, L2, first, last);
483 }
484
485
486
487 //===----------------------------------------------------------------------===
488 // High-Level Functionality that shouldn't really be here, but is part of list
489 //
490
491 // These two functions are actually called remove/remove_if in list<>, but
492 // they actually do the job of erase, rename them accordingly.
493 //
494 void erase(const NodeTy &val) {
495 for (iterator I = begin(), E = end(); I != E; ) {
496 iterator next = I; ++next;
497 if (*I == val) erase(I);
498 I = next;
499 }
500 }
501 template void erase_if(Pr1 pred) {
502 for (iterator I = begin(), E = end(); I != E; ) {
503 iterator next = I; ++next;
504 if (pred(*I)) erase(I);
505 I = next;
506 }
507 }
508
509 template void unique(Pr2 pred) {
510 if (empty()) return;
511 for (iterator I = begin(), E = end(), Next = begin(); ++Next != E;) {
512 if (pred(*I))
513 erase(Next);
514 else
515 I = Next;
516 Next = I;
517 }
518 }
519 void unique() { unique(op_equal); }
520
521 template void merge(iplist &right, Pr3 pred) {
522 iterator first1 = begin(), last1 = end();
523 iterator first2 = right.begin(), last2 = right.end();
524 while (first1 != last1 && first2 != last2)
525 if (pred(*first2, *first1)) {
526 iterator next = first2;
527 transfer(first1, right, first2, ++next);
528 first2 = next;
529 } else {
530 ++first1;
531 }
532 if (first2 != last2) transfer(last1, right, first2, last2);
533 }
534 void merge(iplist &right) { return merge(right, op_less); }
535
536 template void sort(Pr3 pred);
537 void sort() { sort(op_less); }
538 void reverse();
539 };
540
541
542 template
543 struct ilist : public iplist {
544 typedef typename iplist::size_type size_type;
545 typedef typename iplist::iterator iterator;
546
547 ilist() {}
548 ilist(const ilist &right) {
549 insert(this->begin(), right.begin(), right.end());
550 }
551 explicit ilist(size_type count) {
552 insert(this->begin(), count, NodeTy());
553 }
554 ilist(size_type count, const NodeTy &val) {
555 insert(this->begin(), count, val);
556 }
557 template ilist(InIt first, InIt last) {
558 insert(this->begin(), first, last);
559 }
560
561
562 // Forwarding functions: A workaround for GCC 2.95 which does not correctly
563 // support 'using' declarations to bring a hidden member into scope.
564 //
565 iterator insert(iterator a, NodeTy *b){ return iplist::insert(a, b); }
566 void push_front(NodeTy *a) { iplist::push_front(a); }
567 void push_back(NodeTy *a) { iplist::push_back(a); }
568
569
570 // Main implementation here - Insert for a node passed by value...
571 iterator insert(iterator where, const NodeTy &val) {
572 return insert(where, createNode(val));
573 }
574
575
576 // Front and back inserters...
577 void push_front(const NodeTy &val) { insert(this->begin(), val); }
578 void push_back(const NodeTy &val) { insert(this->end(), val); }
579
580 // Special forms of insert...
581 template void insert(iterator where, InIt first, InIt last) {
582 for (; first != last; ++first) insert(where, *first);
583 }
584 void insert(iterator where, size_type count, const NodeTy &val) {
585 for (; count != 0; --count) insert(where, val);
586 }
587
588 // Assign special forms...
589 void assign(size_type count, const NodeTy &val) {
590 iterator I = this->begin();
591 for (; I != this->end() && count != 0; ++I, --count)
592 *I = val;
593 if (count != 0)
594 insert(this->end(), val, val);
595 else
596 erase(I, this->end());
597 }
598 template void assign(InIt first1, InIt last1) {
599 iterator first2 = this->begin(), last2 = this->end();
600 for ( ; first1 != last1 && first2 != last2; ++first1, ++first2)
601 *first1 = *first2;
602 if (first2 == last2)
603 erase(first1, last1);
604 else
605 insert(last1, first2, last2);
606 }
607
608
609 // Resize members...
610 void resize(size_type newsize, NodeTy val) {
611 iterator i = this->begin();
612 size_type len = 0;
613 for ( ; i != this->end() && len < newsize; ++i, ++len) /* empty*/ ;
614
615 if (len == newsize)
616 erase(i, this->end());
617 else // i == end()
618 insert(this->end(), newsize - len, val);
619 }
620 void resize(size_type newsize) { resize(newsize, NodeTy()); }
621 };
622
623 } // End llvm namespace
624
625 namespace std {
626 // Ensure that swap uses the fast list swap...
627 template
628 void swap(llvm::iplist &Left, llvm::iplist &Right) {
629 Left.swap(Right);
630 }
631 } // End 'std' extensions...
632
633 #endif
0 //==-- llvm/ADT/iterator.h - Portable wrapper around --*- C++ -*-==//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides a wrapper around the mysterious header file.
10 // In GCC 2.95.3, the file defines a bidirectional_iterator class (and other
11 // friends), instead of the standard iterator class. In GCC 3.1, the
12 // bidirectional_iterator class got moved out and the new, standards compliant,
13 // iterator<> class was added. Because there is nothing that we can do to get
14 // correct behavior on both compilers, we have this header with #ifdef's. Gross
15 // huh?
16 //
17 // By #includ'ing this file, you get the contents of plus the
18 // following classes in the global namespace:
19 //
20 // 1. bidirectional_iterator
21 // 2. forward_iterator
22 //
23 // The #if directives' expressions are filled in by Autoconf.
24 //
25 //===----------------------------------------------------------------------===//
26
27 #ifndef LLVM_ADT_ITERATOR
28 #define LLVM_ADT_ITERATOR
29
30 #include
31
32 #undef HAVE_BI_ITERATOR
33 #undef HAVE_STD_ITERATOR
34 #undef HAVE_FWD_ITERATOR
35
36 #ifdef _MSC_VER
37 # define HAVE_BI_ITERATOR 0
38 # define HAVE_STD_ITERATOR 1
39 # define HAVE_FWD_ITERATOR 0
40 #endif
41
42 #if !HAVE_BI_ITERATOR
43 # if HAVE_STD_ITERATOR
44 /// If the bidirectional iterator is not defined, we attempt to define it in
45 /// terms of the C++ standard iterator. Otherwise, we import it with a "using"
46 /// statement.
47 ///
48 template
49 struct bidirectional_iterator
50 : public std::iterator {
51 };
52 # else
53 # error "Need to have standard iterator to define bidirectional iterator!"
54 # endif
55 #else
56 using std::bidirectional_iterator;
57 #endif
58
59 #if !HAVE_FWD_ITERATOR
60 # if HAVE_STD_ITERATOR
61 /// If the forward iterator is not defined, attempt to define it in terms of
62 /// the C++ standard iterator. Otherwise, we import it with a "using" statement.
63 ///
64 template
65 struct forward_iterator
66 : public std::iterator {
67 };
68 # else
69 # error "Need to have standard iterator to define forward iterator!"
70 # endif
71 #else
72 using std::forward_iterator;
73 #endif
74
75 #endif
+0
-76
include/llvm/ADT/iterator.in less more
None //===-- llvm/ADT/iterator - Portable wrapper around --*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides a wrapper around the mysterious header file.
10 // In GCC 2.95.3, the file defines a bidirectional_iterator class (and other
11 // friends), instead of the standard iterator class. In GCC 3.1, the
12 // bidirectional_iterator class got moved out and the new, standards compliant,
13 // iterator<> class was added. Because there is nothing that we can do to get
14 // correct behavior on both compilers, we have this header with #ifdef's. Gross
15 // huh?
16 //
17 // By #includ'ing this file, you get the contents of plus the
18 // following classes in the global namespace:
19 //
20 // 1. bidirectional_iterator
21 // 2. forward_iterator
22 //
23 // The #if directives' expressions are filled in by Autoconf.
24 //
25 //===----------------------------------------------------------------------===//
26
27 #ifndef LLVM_ADT_ITERATOR
28 #define LLVM_ADT_ITERATOR
29
30 #include
31
32 #undef HAVE_BI_ITERATOR
33 #undef HAVE_STD_ITERATOR
34 #undef HAVE_FWD_ITERATOR
35
36 #ifdef _MSC_VER
37 # define HAVE_BI_ITERATOR 0
38 # define HAVE_STD_ITERATOR 1
39 # define HAVE_FWD_ITERATOR 0
40 #endif
41
42 #if !HAVE_BI_ITERATOR
43 # if HAVE_STD_ITERATOR
44 /// If the bidirectional iterator is not defined, we attempt to define it in
45 /// terms of the C++ standard iterator. Otherwise, we import it with a "using"
46 /// statement.
47 ///
48 template
49 struct bidirectional_iterator
50 : public std::iterator {
51 };
52 # else
53 # error "Need to have standard iterator to define bidirectional iterator!"
54 # endif
55 #else
56 using std::bidirectional_iterator;
57 #endif
58
59 #if !HAVE_FWD_ITERATOR
60 # if HAVE_STD_ITERATOR
61 /// If the forward iterator is not defined, attempt to define it in terms of
62 /// the C++ standard iterator. Otherwise, we import it with a "using" statement.
63 ///
64 template
65 struct forward_iterator
66 : public std::iterator {
67 };
68 # else
69 # error "Need to have standard iterator to define forward iterator!"
70 # endif
71 #else
72 using std::forward_iterator;
73 #endif
74
75 #endif
1818
1919 #include "llvm/Support/CallSite.h"
2020 #include "llvm/Support/Streams.h"
21 #include "llvm/ADT/iterator"
22 #include "llvm/ADT/hash_map"
23 #include "llvm/ADT/ilist"
21 #include "llvm/ADT/iterator.h"
22 #include "llvm/ADT/hash_map.h"
23 #include "llvm/ADT/ilist.h"
2424
2525 namespace llvm {
2626
1717
1818 #include "llvm/Support/InstIterator.h"
1919 #include "llvm/Instruction.h"
20 #include "llvm/ADT/iterator"
20 #include "llvm/ADT/iterator.h"
2121
2222 namespace llvm {
2323
1515
1616 #include "llvm/Instruction.h"
1717 #include "llvm/SymbolTableListTraits.h"
18 #include "llvm/ADT/ilist"
18 #include "llvm/ADT/ilist.h"
1919 #include "llvm/Support/DataTypes.h"
2020
2121 namespace llvm {
1616 #ifndef LLVM_BITCODE_ARCHIVE_H
1717 #define LLVM_BITCODE_ARCHIVE_H
1818
19 #include "llvm/ADT/ilist"
19 #include "llvm/ADT/ilist.h"
2020 #include "llvm/System/Path.h"
2121 #include
2222 #include
1515
1616 #include "llvm/CodeGen/MachineInstr.h"
1717 #include "llvm/ADT/GraphTraits.h"
18 #include "llvm/ADT/ilist"
18 #include "llvm/ADT/ilist.h"
1919 #include "llvm/Support/Streams.h"
2020
2121 namespace llvm {
1515
1616 #include "llvm/Target/TargetRegisterInfo.h"
1717 #include "llvm/ADT/BitVector.h"
18 #include "llvm/ADT/iterator"
18 #include "llvm/ADT/iterator.h"
1919 #include
2020
2121 namespace llvm {
1515 #define LLVM_CODEGEN_SCHEDGRAPHCOMMON_H
1616
1717 #include "llvm/Value.h"
18 #include "llvm/ADT/iterator"
18 #include "llvm/ADT/iterator.h"
1919 #include "llvm/Support/Streams.h"
2020 #include
2121
1515 #define LLVM_CODEGEN_SELECTIONDAG_H
1616
1717 #include "llvm/ADT/FoldingSet.h"
18 #include "llvm/ADT/ilist"
18 #include "llvm/ADT/ilist.h"
1919 #include "llvm/CodeGen/SelectionDAGNodes.h"
2020
2121 #include
2121 #include "llvm/Value.h"
2222 #include "llvm/ADT/FoldingSet.h"
2323 #include "llvm/ADT/GraphTraits.h"
24 #include "llvm/ADT/iterator"
24 #include "llvm/ADT/iterator.h"
2525 #include "llvm/ADT/APFloat.h"
2626 #include "llvm/ADT/APInt.h"
2727 #include "llvm/CodeGen/ValueTypes.h"
1717 #include "llvm/ADT/GraphTraits.h"
1818 #include "llvm/Function.h"
1919 #include "llvm/InstrTypes.h"
20 #include "llvm/ADT/iterator"
20 #include "llvm/ADT/iterator.h"
2121
2222 namespace llvm {
2323
1515 #include "llvm/Support/DataTypes.h"
1616 #include "llvm/Support/Streams.h"
1717 #include "llvm/ADT/GraphTraits.h"
18 #include "llvm/ADT/iterator"
18 #include "llvm/ADT/iterator.h"
1919 #include
2020 #include
2121
1616 #define LLVM_USE_H
1717
1818 #include "llvm/Support/Casting.h"
19 #include "llvm/ADT/iterator"
19 #include "llvm/ADT/iterator.h"
2020
2121 namespace llvm {
2222
1818
1919 #include "llvm/ADT/GraphTraits.h"
2020 #include "llvm/ADT/IntrusiveRefCntPtr.h"
21 #include "llvm/ADT/iterator"
21 #include "llvm/ADT/iterator.h"
2222 #include "llvm/ADT/SmallVector.h"
2323 #include "llvm/ADT/StringMap.h"
2424 #include "llvm/System/Path.h"