summaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r--include/llvm/ADT/DenseMap.h75
-rw-r--r--include/llvm/ADT/GraphTraits.h2
-rw-r--r--include/llvm/ADT/ImmutableMap.h4
-rw-r--r--include/llvm/ADT/ImmutableSet.h4
-rw-r--r--include/llvm/ADT/PointerUnion.h19
-rw-r--r--include/llvm/ADT/PriorityQueue.h1
-rw-r--r--include/llvm/ADT/SCCIterator.h18
-rw-r--r--include/llvm/ADT/STLExtras.h8
-rw-r--r--include/llvm/ADT/StringMap.h22
-rw-r--r--include/llvm/ADT/StringRef.h104
-rw-r--r--include/llvm/ADT/StringSwitch.h27
-rw-r--r--include/llvm/ADT/Trie.h1
-rw-r--r--include/llvm/ADT/Triple.h21
13 files changed, 207 insertions, 99 deletions
diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h
index 52354b7..8329947 100644
--- a/include/llvm/ADT/DenseMap.h
+++ b/include/llvm/ADT/DenseMap.h
@@ -14,8 +14,9 @@
#ifndef LLVM_ADT_DENSEMAP_H
#define LLVM_ADT_DENSEMAP_H
-#include "llvm/Support/PointerLikeTypeTraits.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/PointerLikeTypeTraits.h"
+#include "llvm/Support/type_traits.h"
#include "llvm/ADT/DenseMapInfo.h"
#include <iterator>
#include <new>
@@ -27,12 +28,8 @@ namespace llvm {
template<typename KeyT, typename ValueT,
typename KeyInfoT = DenseMapInfo<KeyT>,
- typename ValueInfoT = DenseMapInfo<ValueT> >
+ typename ValueInfoT = DenseMapInfo<ValueT>, bool IsConst = false>
class DenseMapIterator;
-template<typename KeyT, typename ValueT,
- typename KeyInfoT = DenseMapInfo<KeyT>,
- typename ValueInfoT = DenseMapInfo<ValueT> >
-class DenseMapConstIterator;
template<typename KeyT, typename ValueT,
typename KeyInfoT = DenseMapInfo<KeyT>,
@@ -73,7 +70,8 @@ public:
}
typedef DenseMapIterator<KeyT, ValueT, KeyInfoT> iterator;
- typedef DenseMapConstIterator<KeyT, ValueT, KeyInfoT> const_iterator;
+ typedef DenseMapIterator<KeyT, ValueT,
+ KeyInfoT, ValueInfoT, true> const_iterator;
inline iterator begin() {
return iterator(Buckets, Buckets+NumBuckets);
}
@@ -426,32 +424,47 @@ private:
}
};
-template<typename KeyT, typename ValueT, typename KeyInfoT, typename ValueInfoT>
-class DenseMapIterator :
- public std::iterator<std::forward_iterator_tag, std::pair<KeyT, ValueT>,
- ptrdiff_t> {
- typedef std::pair<KeyT, ValueT> BucketT;
-protected:
- const BucketT *Ptr, *End;
+template<typename KeyT, typename ValueT,
+ typename KeyInfoT, typename ValueInfoT, bool IsConst>
+class DenseMapIterator {
+ typedef std::pair<KeyT, ValueT> Bucket;
+ typedef DenseMapIterator<KeyT, ValueT,
+ KeyInfoT, ValueInfoT, true> ConstIterator;
+ friend class DenseMapIterator<KeyT, ValueT, KeyInfoT, ValueInfoT, true>;
+public:
+ typedef ptrdiff_t difference_type;
+ typedef typename conditional<IsConst, const Bucket, Bucket>::type value_type;
+ typedef value_type *pointer;
+ typedef value_type &reference;
+ typedef std::forward_iterator_tag iterator_category;
+private:
+ pointer Ptr, End;
public:
DenseMapIterator() : Ptr(0), End(0) {}
- DenseMapIterator(const BucketT *Pos, const BucketT *E) : Ptr(Pos), End(E) {
+ DenseMapIterator(pointer Pos, pointer E) : Ptr(Pos), End(E) {
AdvancePastEmptyBuckets();
}
- std::pair<KeyT, ValueT> &operator*() const {
- return *const_cast<BucketT*>(Ptr);
+ // If IsConst is true this is a converting constructor from iterator to
+ // const_iterator and the default copy constructor is used.
+ // Otherwise this is a copy constructor for iterator.
+ DenseMapIterator(const DenseMapIterator<KeyT, ValueT,
+ KeyInfoT, ValueInfoT, false>& I)
+ : Ptr(I.Ptr), End(I.End) {}
+
+ reference operator*() const {
+ return *Ptr;
}
- std::pair<KeyT, ValueT> *operator->() const {
- return const_cast<BucketT*>(Ptr);
+ pointer operator->() const {
+ return Ptr;
}
- bool operator==(const DenseMapIterator &RHS) const {
- return Ptr == RHS.Ptr;
+ bool operator==(const ConstIterator &RHS) const {
+ return Ptr == RHS.operator->();
}
- bool operator!=(const DenseMapIterator &RHS) const {
- return Ptr != RHS.Ptr;
+ bool operator!=(const ConstIterator &RHS) const {
+ return Ptr != RHS.operator->();
}
inline DenseMapIterator& operator++() { // Preincrement
@@ -475,22 +488,6 @@ private:
}
};
-template<typename KeyT, typename ValueT, typename KeyInfoT, typename ValueInfoT>
-class DenseMapConstIterator : public DenseMapIterator<KeyT, ValueT, KeyInfoT> {
-public:
- DenseMapConstIterator() : DenseMapIterator<KeyT, ValueT, KeyInfoT>() {}
- DenseMapConstIterator(const std::pair<KeyT, ValueT> *Pos,
- const std::pair<KeyT, ValueT> *E)
- : DenseMapIterator<KeyT, ValueT, KeyInfoT>(Pos, E) {
- }
- const std::pair<KeyT, ValueT> &operator*() const {
- return *this->Ptr;
- }
- const std::pair<KeyT, ValueT> *operator->() const {
- return this->Ptr;
- }
-};
-
} // end namespace llvm
#endif
diff --git a/include/llvm/ADT/GraphTraits.h b/include/llvm/ADT/GraphTraits.h
index 2d103cf..0fd1f50 100644
--- a/include/llvm/ADT/GraphTraits.h
+++ b/include/llvm/ADT/GraphTraits.h
@@ -30,7 +30,7 @@ struct GraphTraits {
// typedef NodeType - Type of Node in the graph
// typedef ChildIteratorType - Type used to iterate over children in graph
- // static NodeType *getEntryNode(GraphType *)
+ // static NodeType *getEntryNode(const GraphType &)
// Return the entry node of the graph
// static ChildIteratorType child_begin(NodeType *)
diff --git a/include/llvm/ADT/ImmutableMap.h b/include/llvm/ADT/ImmutableMap.h
index 742e232..fc9fe8b 100644
--- a/include/llvm/ADT/ImmutableMap.h
+++ b/include/llvm/ADT/ImmutableMap.h
@@ -102,8 +102,8 @@ public:
}
private:
- Factory(const Factory& RHS) {};
- void operator=(const Factory& RHS) {};
+ Factory(const Factory& RHS); // DO NOT IMPLEMENT
+ void operator=(const Factory& RHS); // DO NOT IMPLEMENT
};
friend class Factory;
diff --git a/include/llvm/ADT/ImmutableSet.h b/include/llvm/ADT/ImmutableSet.h
index 16b4403..676a198 100644
--- a/include/llvm/ADT/ImmutableSet.h
+++ b/include/llvm/ADT/ImmutableSet.h
@@ -988,8 +988,8 @@ public:
BumpPtrAllocator& getAllocator() { return F.getAllocator(); }
private:
- Factory(const Factory& RHS) {}
- void operator=(const Factory& RHS) {}
+ Factory(const Factory& RHS); // DO NOT IMPLEMENT
+ void operator=(const Factory& RHS); // DO NOT IMPLEMENT
};
friend class Factory;
diff --git a/include/llvm/ADT/PointerUnion.h b/include/llvm/ADT/PointerUnion.h
index 33f2fcb..49c8940 100644
--- a/include/llvm/ADT/PointerUnion.h
+++ b/include/llvm/ADT/PointerUnion.h
@@ -186,8 +186,9 @@ namespace llvm {
int is() const {
// Is it PT1/PT2?
if (::llvm::getPointerUnionTypeNum<PT1, PT2>((T*)0) != -1)
- return Val.is<InnerUnion>() && Val.get<InnerUnion>().is<T>();
- return Val.is<T>();
+ return Val.template is<InnerUnion>() &&
+ Val.template get<InnerUnion>().template is<T>();
+ return Val.template is<T>();
}
/// get<T>() - Return the value of the specified pointer type. If the
@@ -197,9 +198,9 @@ namespace llvm {
assert(is<T>() && "Invalid accessor called");
// Is it PT1/PT2?
if (::llvm::getPointerUnionTypeNum<PT1, PT2>((T*)0) != -1)
- return Val.get<InnerUnion>().get<T>();
+ return Val.template get<InnerUnion>().template get<T>();
- return Val.get<T>();
+ return Val.template get<T>();
}
/// dyn_cast<T>() - If the current value is of the specified pointer type,
@@ -291,8 +292,10 @@ namespace llvm {
int is() const {
// Is it PT1/PT2?
if (::llvm::getPointerUnionTypeNum<PT1, PT2>((T*)0) != -1)
- return Val.is<InnerUnion1>() && Val.get<InnerUnion1>().is<T>();
- return Val.is<InnerUnion2>() && Val.get<InnerUnion2>().is<T>();
+ return Val.template is<InnerUnion1>() &&
+ Val.template get<InnerUnion1>().template is<T>();
+ return Val.template is<InnerUnion2>() &&
+ Val.template get<InnerUnion2>().template is<T>();
}
/// get<T>() - Return the value of the specified pointer type. If the
@@ -302,9 +305,9 @@ namespace llvm {
assert(is<T>() && "Invalid accessor called");
// Is it PT1/PT2?
if (::llvm::getPointerUnionTypeNum<PT1, PT2>((T*)0) != -1)
- return Val.get<InnerUnion1>().get<T>();
+ return Val.template get<InnerUnion1>().template get<T>();
- return Val.get<InnerUnion2>().get<T>();
+ return Val.template get<InnerUnion2>().template get<T>();
}
/// dyn_cast<T>() - If the current value is of the specified pointer type,
diff --git a/include/llvm/ADT/PriorityQueue.h b/include/llvm/ADT/PriorityQueue.h
index a8809dc..bf8a687 100644
--- a/include/llvm/ADT/PriorityQueue.h
+++ b/include/llvm/ADT/PriorityQueue.h
@@ -14,6 +14,7 @@
#ifndef LLVM_ADT_PRIORITY_QUEUE_H
#define LLVM_ADT_PRIORITY_QUEUE_H
+#include <algorithm>
#include <queue>
namespace llvm {
diff --git a/include/llvm/ADT/SCCIterator.h b/include/llvm/ADT/SCCIterator.h
index db985b5..3afcabd 100644
--- a/include/llvm/ADT/SCCIterator.h
+++ b/include/llvm/ADT/SCCIterator.h
@@ -136,8 +136,8 @@ public:
typedef scc_iterator<GraphT, GT> _Self;
// Provide static "constructors"...
- static inline _Self begin(GraphT& G) { return _Self(GT::getEntryNode(G)); }
- static inline _Self end (GraphT& G) { return _Self(); }
+ static inline _Self begin(const GraphT& G) { return _Self(GT::getEntryNode(G)); }
+ static inline _Self end (const GraphT& G) { return _Self(); }
// Direct loop termination test (I.fini() is more efficient than I == end())
inline bool fini() const {
@@ -186,15 +186,25 @@ public:
// Global constructor for the SCC iterator.
template <class T>
-scc_iterator<T> scc_begin(T G) {
+scc_iterator<T> scc_begin(const T& G) {
return scc_iterator<T>::begin(G);
}
template <class T>
-scc_iterator<T> scc_end(T G) {
+scc_iterator<T> scc_end(const T& G) {
return scc_iterator<T>::end(G);
}
+template <class T>
+scc_iterator<Inverse<T> > scc_begin(const Inverse<T>& G) {
+ return scc_iterator<Inverse<T> >::begin(G);
+}
+
+template <class T>
+scc_iterator<Inverse<T> > scc_end(const Inverse<T>& G) {
+ return scc_iterator<Inverse<T> >::end(G);
+}
+
} // End llvm namespace
#endif
diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h
index 6f47692..a8b6133 100644
--- a/include/llvm/ADT/STLExtras.h
+++ b/include/llvm/ADT/STLExtras.h
@@ -270,6 +270,14 @@ static inline void array_pod_sort(IteratorTy Start, IteratorTy End) {
get_array_pad_sort_comparator(*Start));
}
+template<class IteratorTy>
+static inline void array_pod_sort(IteratorTy Start, IteratorTy End,
+ int (*Compare)(const void*, const void*)) {
+ // Don't dereference start iterator of empty sequence.
+ if (Start == End) return;
+ qsort(&*Start, End-Start, sizeof(*Start), Compare);
+}
+
} // End llvm namespace
#endif
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h
index 73fd635..86e8546 100644
--- a/include/llvm/ADT/StringMap.h
+++ b/include/llvm/ADT/StringMap.h
@@ -96,12 +96,12 @@ protected:
/// specified bucket will be non-null. Otherwise, it will be null. In either
/// case, the FullHashValue field of the bucket will be set to the hash value
/// of the string.
- unsigned LookupBucketFor(const StringRef &Key);
+ unsigned LookupBucketFor(StringRef Key);
/// FindKey - Look up the bucket that contains the specified key. If it exists
/// in the map, return the bucket number of the key. Otherwise return -1.
/// This does not modify the map.
- int FindKey(const StringRef &Key) const;
+ int FindKey(StringRef Key) const;
/// RemoveKey - Remove the specified StringMapEntry from the table, but do not
/// delete it. This aborts if the value isn't in the table.
@@ -109,7 +109,7 @@ protected:
/// RemoveKey - Remove the StringMapEntry for the specified key from the
/// table, returning it. If the key is not in the table, this returns null.
- StringMapEntryBase *RemoveKey(const StringRef &Key);
+ StringMapEntryBase *RemoveKey(StringRef Key);
private:
void init(unsigned Size);
public:
@@ -282,13 +282,13 @@ public:
return const_iterator(TheTable+NumBuckets, true);
}
- iterator find(const StringRef &Key) {
+ iterator find(StringRef Key) {
int Bucket = FindKey(Key);
if (Bucket == -1) return end();
return iterator(TheTable+Bucket);
}
- const_iterator find(const StringRef &Key) const {
+ const_iterator find(StringRef Key) const {
int Bucket = FindKey(Key);
if (Bucket == -1) return end();
return const_iterator(TheTable+Bucket);
@@ -296,18 +296,18 @@ public:
/// lookup - Return the entry for the specified key, or a default
/// constructed value if no such entry exists.
- ValueTy lookup(const StringRef &Key) const {
+ ValueTy lookup(StringRef Key) const {
const_iterator it = find(Key);
if (it != end())
return it->second;
return ValueTy();
}
- ValueTy& operator[](const StringRef &Key) {
+ ValueTy& operator[](StringRef Key) {
return GetOrCreateValue(Key).getValue();
}
- size_type count(const StringRef &Key) const {
+ size_type count(StringRef Key) const {
return find(Key) == end() ? 0 : 1;
}
@@ -350,7 +350,7 @@ public:
/// exists, return it. Otherwise, default construct a value, insert it, and
/// return.
template <typename InitTy>
- StringMapEntry<ValueTy> &GetOrCreateValue(const StringRef &Key,
+ StringMapEntry<ValueTy> &GetOrCreateValue(StringRef Key,
InitTy Val) {
unsigned BucketNo = LookupBucketFor(Key);
ItemBucket &Bucket = TheTable[BucketNo];
@@ -373,7 +373,7 @@ public:
return *NewItem;
}
- StringMapEntry<ValueTy> &GetOrCreateValue(const StringRef &Key) {
+ StringMapEntry<ValueTy> &GetOrCreateValue(StringRef Key) {
return GetOrCreateValue(Key, ValueTy());
}
@@ -401,7 +401,7 @@ public:
V.Destroy(Allocator);
}
- bool erase(const StringRef &Key) {
+ bool erase(StringRef Key) {
iterator I = find(Key);
if (I == end()) return false;
erase(I);
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h
index 2fa5c66..ed651bf 100644
--- a/include/llvm/ADT/StringRef.h
+++ b/include/llvm/ADT/StringRef.h
@@ -16,6 +16,8 @@
#include <string>
namespace llvm {
+ template<typename T>
+ class SmallVectorImpl;
/// StringRef - Represent a constant reference to a string, i.e. a character
/// array and a length, which need not be null terminated.
@@ -46,7 +48,7 @@ namespace llvm {
/// Construct a string ref from a cstring.
/*implicit*/ StringRef(const char *Str)
- : Data(Str) { if (Str) Length = ::strlen(Str); else Length = 0; }
+ : Data(Str), Length(::strlen(Str)) {}
/// Construct a string ref from a pointer and length.
/*implicit*/ StringRef(const char *data, size_t length)
@@ -54,7 +56,7 @@ namespace llvm {
/// Construct a string ref from an std::string.
/*implicit*/ StringRef(const std::string &Str)
- : Data(Str.c_str()), Length(Str.length()) {}
+ : Data(Str.data()), Length(Str.length()) {}
/// @}
/// @name Iterators
@@ -92,14 +94,19 @@ namespace llvm {
/// equals - Check for string equality, this is more efficient than
/// compare() when the relative ordering of inequal strings isn't needed.
- bool equals(const StringRef &RHS) const {
+ bool equals(StringRef RHS) const {
return (Length == RHS.Length &&
memcmp(Data, RHS.Data, RHS.Length) == 0);
}
+ /// equals_lower - Check for string equality, ignoring case.
+ bool equals_lower(StringRef RHS) const {
+ return Length == RHS.Length && compare_lower(RHS) == 0;
+ }
+
/// compare - Compare two strings; the result is -1, 0, or 1 if this string
/// is lexicographically less than, equal to, or greater than the \arg RHS.
- int compare(const StringRef &RHS) const {
+ int compare(StringRef RHS) const {
// Check the prefix for a mismatch.
if (int Res = memcmp(Data, RHS.Data, std::min(Length, RHS.Length)))
return Res < 0 ? -1 : 1;
@@ -110,6 +117,9 @@ namespace llvm {
return Length < RHS.Length ? -1 : 1;
}
+ /// compare_lower - Compare two strings, ignoring case.
+ int compare_lower(StringRef RHS) const;
+
/// str - Get the contents as an std::string.
std::string str() const { return std::string(Data, Length); }
@@ -135,12 +145,12 @@ namespace llvm {
/// @{
/// startswith - Check if this string starts with the given \arg Prefix.
- bool startswith(const StringRef &Prefix) const {
+ bool startswith(StringRef Prefix) const {
return substr(0, Prefix.Length).equals(Prefix);
}
/// endswith - Check if this string ends with the given \arg Suffix.
- bool endswith(const StringRef &Suffix) const {
+ bool endswith(StringRef Suffix) const {
return slice(size() - Suffix.Length, size()).equals(Suffix);
}
@@ -152,8 +162,8 @@ namespace llvm {
///
/// \return - The index of the first occurence of \arg C, or npos if not
/// found.
- size_t find(char C) const {
- for (size_t i = 0, e = Length; i != e; ++i)
+ size_t find(char C, size_t From = 0) const {
+ for (size_t i = std::min(From, Length), e = Length; i != e; ++i)
if (Data[i] == C)
return i;
return npos;
@@ -163,7 +173,7 @@ namespace llvm {
///
/// \return - The index of the first occurence of \arg Str, or npos if not
/// found.
- size_t find(const StringRef &Str) const;
+ size_t find(StringRef Str, size_t From = 0) const;
/// rfind - Search for the last character \arg C in the string.
///
@@ -184,19 +194,27 @@ namespace llvm {
///
/// \return - The index of the last occurence of \arg Str, or npos if not
/// found.
- size_t rfind(const StringRef &Str) const;
+ size_t rfind(StringRef Str) const;
+
+ /// find_first_of - Find the first character in the string that is \arg C,
+ /// or npos if not found. Same as find.
+ size_type find_first_of(char C, size_t = 0) const { return find(C); }
- /// find_first_of - Find the first instance of the specified character or
- /// return npos if not in string. Same as find.
- size_type find_first_of(char C) const { return find(C); }
+ /// find_first_of - Find the first character in the string that is in \arg
+ /// Chars, or npos if not found.
+ ///
+ /// Note: O(size() * Chars.size())
+ size_type find_first_of(StringRef Chars, size_t From = 0) const;
- /// find_first_of - Find the first character from the string 'Chars' in the
- /// current string or return npos if not in string.
- size_type find_first_of(StringRef Chars) const;
+ /// find_first_not_of - Find the first character in the string that is not
+ /// \arg C or npos if not found.
+ size_type find_first_not_of(char C, size_t From = 0) const;
/// find_first_not_of - Find the first character in the string that is not
- /// in the string 'Chars' or return npos if all are in string. Same as find.
- size_type find_first_not_of(StringRef Chars) const;
+ /// in the string \arg Chars, or npos if not found.
+ ///
+ /// Note: O(size() * Chars.size())
+ size_type find_first_not_of(StringRef Chars, size_t From = 0) const;
/// @}
/// @name Helpful Algorithms
@@ -213,7 +231,7 @@ namespace llvm {
/// count - Return the number of non-overlapped occurrences of \arg Str in
/// the string.
- size_t count(const StringRef &Str) const;
+ size_t count(StringRef Str) const;
/// getAsInteger - Parse the current string as an integer of the specified
/// radix. If Radix is specified as zero, this does radix autosensing using
@@ -281,6 +299,42 @@ namespace llvm {
return std::make_pair(slice(0, Idx), slice(Idx+1, npos));
}
+ /// split - Split into two substrings around the first occurence of a
+ /// separator string.
+ ///
+ /// If \arg Separator is in the string, then the result is a pair (LHS, RHS)
+ /// such that (*this == LHS + Separator + RHS) is true and RHS is
+ /// maximal. If \arg Separator is not in the string, then the result is a
+ /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
+ ///
+ /// \param Separator - The string to split on.
+ /// \return - The split substrings.
+ std::pair<StringRef, StringRef> split(StringRef Separator) const {
+ size_t Idx = find(Separator);
+ if (Idx == npos)
+ return std::make_pair(*this, StringRef());
+ return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
+ }
+
+ /// split - Split into substrings around the occurences of a separator
+ /// string.
+ ///
+ /// Each substring is stored in \arg A. If \arg MaxSplit is >= 0, at most
+ /// \arg MaxSplit splits are done and consequently <= \arg MaxSplit
+ /// elements are added to A.
+ /// If \arg KeepEmpty is false, empty strings are not added to \arg A. They
+ /// still count when considering \arg MaxSplit
+ /// An useful invariant is that
+ /// Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true
+ ///
+ /// \param A - Where to put the substrings.
+ /// \param Separator - The string to split on.
+ /// \param MaxSplit - The maximum number of times the string is split.
+ /// \parm KeepEmpty - True if empty substring should be added.
+ void split(SmallVectorImpl<StringRef> &A,
+ StringRef Separator, int MaxSplit = -1,
+ bool KeepEmpty = true) const;
+
/// rsplit - Split into two substrings around the last occurence of a
/// separator character.
///
@@ -304,27 +358,27 @@ namespace llvm {
/// @name StringRef Comparison Operators
/// @{
- inline bool operator==(const StringRef &LHS, const StringRef &RHS) {
+ inline bool operator==(StringRef LHS, StringRef RHS) {
return LHS.equals(RHS);
}
- inline bool operator!=(const StringRef &LHS, const StringRef &RHS) {
+ inline bool operator!=(StringRef LHS, StringRef RHS) {
return !(LHS == RHS);
}
- inline bool operator<(const StringRef &LHS, const StringRef &RHS) {
+ inline bool operator<(StringRef LHS, StringRef RHS) {
return LHS.compare(RHS) == -1;
}
- inline bool operator<=(const StringRef &LHS, const StringRef &RHS) {
+ inline bool operator<=(StringRef LHS, StringRef RHS) {
return LHS.compare(RHS) != 1;
}
- inline bool operator>(const StringRef &LHS, const StringRef &RHS) {
+ inline bool operator>(StringRef LHS, StringRef RHS) {
return LHS.compare(RHS) == 1;
}
- inline bool operator>=(const StringRef &LHS, const StringRef &RHS) {
+ inline bool operator>=(StringRef LHS, StringRef RHS) {
return LHS.compare(RHS) != -1;
}
diff --git a/include/llvm/ADT/StringSwitch.h b/include/llvm/ADT/StringSwitch.h
index 48a52de..6562d57 100644
--- a/include/llvm/ADT/StringSwitch.h
+++ b/include/llvm/ADT/StringSwitch.h
@@ -65,6 +65,33 @@ public:
return *this;
}
+ template<unsigned N0, unsigned N1>
+ StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1],
+ const T& Value) {
+ return Case(S0, Value).Case(S1, Value);
+ }
+
+ template<unsigned N0, unsigned N1, unsigned N2>
+ StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1],
+ const char (&S2)[N2], const T& Value) {
+ return Case(S0, Value).Case(S1, Value).Case(S2, Value);
+ }
+
+ template<unsigned N0, unsigned N1, unsigned N2, unsigned N3>
+ StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1],
+ const char (&S2)[N2], const char (&S3)[N3],
+ const T& Value) {
+ return Case(S0, Value).Case(S1, Value).Case(S2, Value).Case(S3, Value);
+ }
+
+ template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4>
+ StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1],
+ const char (&S2)[N2], const char (&S3)[N3],
+ const char (&S4)[N4], const T& Value) {
+ return Case(S0, Value).Case(S1, Value).Case(S2, Value).Case(S3, Value)
+ .Case(S4, Value);
+ }
+
T Default(const T& Value) {
if (ResultKnown)
return Result;
diff --git a/include/llvm/ADT/Trie.h b/include/llvm/ADT/Trie.h
index cf92862..b415990 100644
--- a/include/llvm/ADT/Trie.h
+++ b/include/llvm/ADT/Trie.h
@@ -18,6 +18,7 @@
#include "llvm/ADT/GraphTraits.h"
#include "llvm/Support/DOTGraphTraits.h"
+#include <cassert>
#include <vector>
namespace llvm {
diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
index 7fb0014..a9e3e53 100644
--- a/include/llvm/ADT/Triple.h
+++ b/include/llvm/ADT/Triple.h
@@ -94,6 +94,7 @@ public:
MinGW64,
NetBSD,
OpenBSD,
+ Psp,
Solaris,
Win32,
Haiku
@@ -160,6 +161,8 @@ public:
/// @name Direct Component Access
/// @{
+ const std::string &str() const { return Data; }
+
const std::string &getTriple() const { return Data; }
/// getArchName - Get the architecture (first) component of the
@@ -218,23 +221,27 @@ public:
/// setArchName - Set the architecture (first) component of the
/// triple by name.
- void setArchName(const StringRef &Str);
+ void setArchName(StringRef Str);
/// setVendorName - Set the vendor (second) component of the triple
/// by name.
- void setVendorName(const StringRef &Str);
+ void setVendorName(StringRef Str);
/// setOSName - Set the operating system (third) component of the
/// triple by name.
- void setOSName(const StringRef &Str);
+ void setOSName(StringRef Str);
/// setEnvironmentName - Set the optional environment (fourth)
/// component of the triple by name.
- void setEnvironmentName(const StringRef &Str);
+ void setEnvironmentName(StringRef Str);
/// setOSAndEnvironmentName - Set the operating system and optional
/// environment components with a single string.
- void setOSAndEnvironmentName(const StringRef &Str);
+ void setOSAndEnvironmentName(StringRef Str);
+
+ /// getArchNameForAssembler - Get an architecture name that is understood by the
+ /// target assembler.
+ const char *getArchNameForAssembler();
/// @}
/// @name Static helpers for IDs.
@@ -265,12 +272,12 @@ public:
/// getArchTypeForLLVMName - The canonical type for the given LLVM
/// architecture name (e.g., "x86").
- static ArchType getArchTypeForLLVMName(const StringRef &Str);
+ static ArchType getArchTypeForLLVMName(StringRef Str);
/// getArchTypeForDarwinArchName - Get the architecture type for a "Darwin"
/// architecture name, for example as accepted by "gcc -arch" (see also
/// arch(3)).
- static ArchType getArchTypeForDarwinArchName(const StringRef &Str);
+ static ArchType getArchTypeForDarwinArchName(StringRef Str);
/// @}
};
OpenPOWER on IntegriCloud