[PATCH] D64789: [clangd] Handle windows line endings in QueryDriver
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 16 02:56:43 PDT 2019
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.
fixes second case of https://github.com/clangd/clangd/issues/93
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64789
Files:
clang-tools-extra/clangd/QueryDriverDatabase.cpp
clang-tools-extra/clangd/test/system-include-extractor.test
Index: clang-tools-extra/clangd/test/system-include-extractor.test
===================================================================
--- clang-tools-extra/clangd/test/system-include-extractor.test
+++ clang-tools-extra/clangd/test/system-include-extractor.test
@@ -5,7 +5,7 @@
# RUN: echo '#!/bin/bash' >> %t.dir/my_driver.sh
# RUN: echo '[ "$0" = "%t.dir/my_driver.sh" ] || exit' >> %t.dir/my_driver.sh
# RUN: echo 'echo line to ignore >&2' >> %t.dir/my_driver.sh
-# RUN: echo 'echo \#include \<...\> search starts here: >&2' >> %t.dir/my_driver.sh
+# RUN: echo 'echo -e "#include <...> search starts here:\r" >&2' >> %t.dir/my_driver.sh
# RUN: echo 'echo %t.dir/my/dir/ >&2' >> %t.dir/my_driver.sh
# RUN: echo 'echo %t.dir/my/dir2/ >&2' >> %t.dir/my_driver.sh
# RUN: echo 'echo End of search list. >&2' >> %t.dir/my_driver.sh
Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===================================================================
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -63,7 +63,9 @@
llvm::SmallVector<llvm::StringRef, 8> Lines;
Output.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
- auto StartIt = std::find(Lines.begin(), Lines.end(), SIS);
+ auto StartIt =
+ std::find_if(Lines.begin(), Lines.end(),
+ [](llvm::StringRef Line) { return Line.trim() == SIS; });
if (StartIt == Lines.end()) {
elog("System include extraction: start marker not found: {0}", Output);
return {};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64789.210054.patch
Type: text/x-patch
Size: 1534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190716/bf58c42e/attachment.bin>
More information about the cfe-commits
mailing list