[clangd] Attempt to fix tests failing on Windows

llvm-svn: 303993
This commit is contained in:
Ilya Biryukov 2017-05-26 14:34:34 +00:00
parent 0e62a125bd
commit 90fecdb47c
1 changed files with 14 additions and 8 deletions

View File

@ -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>