diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-11-13 16:46:11 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-13 16:46:11 +0000 |
commit | e675049aa302bf07472ae6e76ff66e6f5427eff9 (patch) | |
tree | 989456228883b43e35b357f9f8e0ab329d677ecb /lib/Frontend/PCHReader.cpp | |
parent | a9204831639e31474b927681b97c46781b758a1a (diff) |
Remove local splitLines reimplementation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88661 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReader.cpp')
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 780890de2a..ca7aa3260c 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -132,29 +132,6 @@ bool PCHValidator::ReadTargetTriple(llvm::StringRef Triple) { return true; } -/// \brief Split the given string into a vector of lines, eliminating -/// any empty lines in the process. -/// -/// \param Str the string to split. -/// \param Len the length of Str. -/// \param KeepEmptyLines true if empty lines should be included -/// \returns a vector of lines, with the line endings removed -static std::vector<llvm::StringRef> splitLines(llvm::StringRef Str, - bool KeepEmptyLines = false) { - std::vector<llvm::StringRef> Lines; - - while (!Str.empty()) { - std::pair<llvm::StringRef, llvm::StringRef> split = Str.split('\n'); - - if (KeepEmptyLines || !split.first.empty()) - Lines.push_back(split.first); - - Str = split.second; - } - - return Lines; -} - bool PCHValidator::ReadPredefinesBuffer(llvm::StringRef PCHPredef, FileID PCHBufferID, llvm::StringRef OriginalFileName, @@ -181,11 +158,12 @@ bool PCHValidator::ReadPredefinesBuffer(llvm::StringRef PCHPredef, // The predefines buffers are different. Determine what the differences are, // and whether they require us to reject the PCH file. - std::vector<llvm::StringRef> PCHLines = splitLines(PCHPredef); - std::vector<llvm::StringRef> CmdLineLines = splitLines(Left); - std::vector<llvm::StringRef> CmdLineLinesRight = splitLines(Right); - CmdLineLines.insert(CmdLineLines.end(), - CmdLineLinesRight.begin(), CmdLineLinesRight.end()); + llvm::SmallVector<llvm::StringRef, 8> PCHLines; + PCHPredef.split(PCHLines, "\n", /*MaxSplit=*/-1, /*KeepEmpty=*/false); + + llvm::SmallVector<llvm::StringRef, 8> CmdLineLines; + Left.split(CmdLineLines, "\n", /*MaxSplit=*/-1, /*KeepEmpty=*/false); + Right.split(CmdLineLines, "\n", /*MaxSplit=*/-1, /*KeepEmpty=*/false); // Sort both sets of predefined buffer lines, since we allow some extra // definitions and they may appear at any point in the output. @@ -221,7 +199,7 @@ bool PCHValidator::ReadPredefinesBuffer(llvm::StringRef PCHPredef, // command line. std::string MacroDefStart = "#define " + MacroName.str(); std::string::size_type MacroDefLen = MacroDefStart.size(); - std::vector<llvm::StringRef>::iterator ConflictPos + llvm::SmallVector<llvm::StringRef, 8>::iterator ConflictPos = std::lower_bound(CmdLineLines.begin(), CmdLineLines.end(), MacroDefStart); for (; ConflictPos != CmdLineLines.end(); ++ConflictPos) { |