- // Create the return token.
- std::string Result = std::string(Source.begin()+Start, Source.begin()+End);
-
- // Erase the token that we read in.
- Source.erase(Source.begin(), Source.begin()+End);
-
- return Result;
+/// SplitString - Split up the specified string according to the specified
+/// delimiters, appending the result fragments to the output list.
+void llvm::SplitString(StringRef Source,
+ SmallVectorImpl<StringRef> &OutFragments,
+ StringRef Delimiters) {
+ std::pair<StringRef, StringRef> S = getToken(Source, Delimiters);
+ while (!S.first.empty()) {
+ OutFragments.push_back(S.first);
+ S = getToken(S.second, Delimiters);
+ }