Import llvm::SmallString and dependencies.

Update StringRef and StringExtras with SmallVector functions.
This commit is contained in:
Peter Johnson
2015-07-22 22:29:46 -07:00
parent 593bc28446
commit 79f732f239
11 changed files with 1800 additions and 11 deletions

View File

@@ -18,6 +18,8 @@
#include <utility>
namespace llvm {
template <typename T>
class SmallVectorImpl;
class StringRef;
/// Helper functions for StringRef::getAsInteger.
@@ -434,6 +436,24 @@ namespace llvm {
return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
}
/// Split into substrings around the occurrences of a separator string.
///
/// Each substring is stored in \p A. If \p MaxSplit is >= 0, at most
/// \p MaxSplit splits are done and consequently <= \p MaxSplit
/// elements are added to A.
/// If \p KeepEmpty is false, empty strings are not added to \p A. They
/// still count when considering \p 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.
/// \param KeepEmpty - True if empty substring should be added.
void split(SmallVectorImpl<StringRef> &A,
StringRef Separator, int MaxSplit = -1,
bool KeepEmpty = true) const;
/// Split into two substrings around the last occurrence of a separator
/// character.
///