From 90fecdb47cd87c63c62a41e47a969823ef1518d3 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 26 May 2017 14:34:34 +0000 Subject: [PATCH] [clangd] Attempt to fix tests failing on Windows llvm-svn: 303993 --- clang-tools-extra/unittests/clangd/ClangdTests.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/clang-tools-extra/unittests/clangd/ClangdTests.cpp b/clang-tools-extra/unittests/clangd/ClangdTests.cpp index abd72bd..55235f2 100644 --- a/clang-tools-extra/unittests/clangd/ClangdTests.cpp +++ b/clang-tools-extra/unittests/clangd/ClangdTests.cpp @@ -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 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 -- 2.7.4