Skip to content

Commit f3ae501

Browse files
committed
[clangd] Handle windows line endings in QueryDriver
Summary: The previous patch did not fix the end mark. D64789 fixes second case of clangd/clangd#93 Patch by @lh123 ! Reviewers: sammccall, kadircet Reviewed By: kadircet Subscribers: MaskRay, ilya-biryukov, jkorous, arphaman, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D64970 llvm-svn: 366545
1 parent 2711e16 commit f3ae501

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

clang-tools-extra/clangd/QueryDriverDatabase.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace {
5959
std::vector<std::string> parseDriverOutput(llvm::StringRef Output) {
6060
std::vector<std::string> SystemIncludes;
6161
const char SIS[] = "#include <...> search starts here:";
62-
constexpr char const *SIE = "End of search list.";
62+
const char SIE[] = "End of search list.";
6363
llvm::SmallVector<llvm::StringRef, 8> Lines;
6464
Output.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
6565

@@ -70,7 +70,9 @@ std::vector<std::string> parseDriverOutput(llvm::StringRef Output) {
7070
return {};
7171
}
7272
++StartIt;
73-
const auto EndIt = std::find(StartIt, Lines.end(), SIE);
73+
const auto EndIt =
74+
llvm::find_if(llvm::make_range(StartIt, Lines.end()),
75+
[SIE](llvm::StringRef Line) { return Line.trim() == SIE; });
7476
if (EndIt == Lines.end()) {
7577
elog("System include extraction: end marker missing: {0}", Output);
7678
return {};

clang-tools-extra/clangd/test/system-include-extractor.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# RUN: echo 'echo -e "#include <...> search starts here:\r" >&2' >> %t.dir/my_driver.sh
99
# RUN: echo 'echo %t.dir/my/dir/ >&2' >> %t.dir/my_driver.sh
1010
# RUN: echo 'echo %t.dir/my/dir2/ >&2' >> %t.dir/my_driver.sh
11-
# RUN: echo 'echo End of search list. >&2' >> %t.dir/my_driver.sh
11+
# RUN: echo 'echo -e "End of search list.\r" >&2' >> %t.dir/my_driver.sh
1212
# RUN: chmod +x %t.dir/my_driver.sh
1313

1414
# Create header files my/dir/a.h and my/dir2/b.h

0 commit comments

Comments
 (0)