[clang-tools-extra] r303993 - [clangd] Attempt to fix tests failing on Windows
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Fri May 26 07:34:34 PDT 2017
Author: ibiryukov
Date: Fri May 26 09:34:34 2017
New Revision: 303993
URL: http://llvm.org/viewvc/llvm-project?rev=303993&view=rev
Log:
[clangd] Attempt to fix tests failing on Windows
Modified:
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=303993&r1=303992&r2=303993&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Fri May 26 09:34:34 2017
@@ -184,21 +184,27 @@ public:
};
/// Replaces all patterns of the form 0x123abc with spaces
-void replacePtrsInDump(std::string &Dump) {
+std::string replacePtrsInDump(std::string const &Dump) {
llvm::Regex RE("0x[0-9a-fA-F]+");
llvm::SmallVector<StringRef, 1> Matches;
- while (RE.match(Dump, &Matches)) {
+ llvm::StringRef Pending = Dump;
+
+ std::string Result;
+ while (RE.match(Pending, &Matches)) {
assert(Matches.size() == 1 && "Exactly one match expected");
- auto MatchPos = Matches[0].data() - Dump.data();
- std::fill(Dump.begin() + MatchPos,
- Dump.begin() + MatchPos + Matches[0].size(), ' ');
+ auto MatchPos = Matches[0].data() - Pending.data();
+
+ Result += Pending.take_front(MatchPos);
+ Pending = Pending.drop_front(MatchPos + Matches[0].size());
}
+ Result += Pending;
+
+ return Result;
}
std::string dumpASTWithoutMemoryLocs(ClangdServer &Server, PathRef File) {
- auto Dump = Server.dumpAST(File);
- replacePtrsInDump(Dump);
- return Dump;
+ auto DumpWithMemLocs = Server.dumpAST(File);
+ return replacePtrsInDump(DumpWithMemLocs);
}
template <class T>
More information about the cfe-commits
mailing list