<div dir="ltr">Hi Stefan,<div><br></div><div>I've sent out <a href="https://reviews.llvm.org/D62965" class="cremed">https://reviews.llvm.org/D62965</a> let me know if it works for you.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 4, 2019 at 7:16 PM Ilya Biryukov <<a href="mailto:ibiryukov@google.com">ibiryukov@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks, I'll try to repro and get back to you with the results of my investigation.<div>Hacking JSONCompilationDatabase also looks like an overkill if it's just clangd that is affected. However, if it turns out more tools break because of this, might actually be the right fix.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 4, 2019 at 7:03 PM Stefan Lietzau <<a href="mailto:s.lietzau@tesis.de" target="_blank">s.lietzau@tesis.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="DE"><div class="gmail-m_-8432750812191701955gmail-m_1209841820732159825WordSection1"><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I think a simple CMake project with one source file and header should work. Maybe it’s required that the header directory is a relative path containing ..\ <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I’m not sure if CMake always generates forward slashes for the directory part of a compile command but that’s very important to reproduce the issue.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Locally I was able to “fix” the issue by hacking the JSONCompilationDatabase to return the directory of the compile command as a native path instead of returning the unprocessed JSON string.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">However I’m not sure if that’s the solution one would want to go for as that change would affect a lot of other parts of the codebase.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">Von:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> Ilya Biryukov [mailto:<a href="mailto:ibiryukov@google.com" target="_blank">ibiryukov@google.com</a>] <br><b>Gesendet:</b> Dienstag, 4. Juni 2019 17:50<br><b>An:</b> Stefan Lietzau<br><b>Cc:</b> Kadir Çetinkaya; via clangd-dev<br><b>Betreff:</b> Re: [clangd-dev] Automatically adding includes always inserts the full path on windows<u></u><u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">Ok, that means we'll have to take a closer look.<u></u><u></u></p><div><p class="MsoNormal">I can try reproducing on Windows, any guidance on how to get a minimal repro? E.g. would it work on a simple hello-world example, e.g. for including standard library symbols?<u></u><u></u></p></div></div><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal">On Tue, Jun 4, 2019 at 4:47 PM Stefan Lietzau <<a href="mailto:s.lietzau@tesis.de" target="_blank">s.lietzau@tesis.de</a>> wrote:<u></u><u></u></p></div><blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm"><div><div><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I just tested the issue again and the problem is not fixed with a master version of today(commit 2e49e8196dab68481857ec243f091fbb4ad7af43).</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Sorry for the confusion, I just checked and I’m already using <a href="https://github.com/llvm/llvm-project.git" target="_blank">https://github.com/llvm/llvm-project.git</a> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Regards,</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Stefan Lietzau</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p><p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">Von:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> Ilya Biryukov [mailto:<a href="mailto:ibiryukov@google.com" target="_blank">ibiryukov@google.com</a>] <br><b>Gesendet:</b> Dienstag, 4. Juni 2019 15:15<br><b>An:</b> Stefan Lietzau<br><b>Cc:</b> Kadir Çetinkaya; via clangd-dev<br><b>Betreff:</b> Re: [clangd-dev] Automatically adding includes always inserts the full path on windows</span><u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">Ok, so Kadir's patch will very likely fix the problem. Please let us know if the issue persists.<u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Offtopic question: any reason (other than historical) why you're using the mirror instead of the official monorepo(<a href="https://github.com/llvm/llvm-project" target="_blank">https://github.com/llvm/llvm-project</a>)?<u></u><u></u></p></div></div><p class="MsoNormal"> <u></u><u></u></p><div><div><p class="MsoNormal">On Tue, Jun 4, 2019 at 2:15 PM Stefan Lietzau <<a href="mailto:s.lietzau@tesis.de" target="_blank">s.lietzau@tesis.de</a>> wrote:<u></u><u></u></p></div><blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt"><div><div><p class="MsoNormal"><span lang="EN-US">Hey Ilya,</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US">I was using commit ed4dbe63260f5a0a3410995b85b32f0ec34b0076 from the github llvm-mirror, dated 14 May 2019.</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US">During my debugging I noticed that this function (<a href="https://github.com/llvm-mirror/clang/blob/b84e04d4c031c8ff9a1a6875381f4a34b923cad7/lib/Lex/HeaderSearch.cpp#L1677" target="_blank"><span style="font-size:11pt;font-family:Calibri,sans-serif">https://github.com/llvm-mirror/clang/blob/b84e04d4c031c8ff9a1a6875381f4a34b923cad7/lib/Lex/HeaderSearch.cpp#L1677</span></a> ) tried to compare paths similar to these:</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US">C:\foo/bar/baz with C:/foo/bar/baz. As these are compared as strings, they don’t match. I traced the problem back until I found that the compilation database entry contains only forward slashes while the suggested header contained backslashes. I’m not sure what the policy for path handling is for clang tooling and clangd in general. Without such information it’s difficult to fix this bug the right way.</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p><p class="MsoNormal"><a href="mailto:kadircet@google.com" target="_blank"><span lang="EN-US">@Kadir Çetinkaya</span></a><span lang="EN-US">, to me it looks like your change should solve the issue, I’ll test it and report my findings later. Comparing the date from the commit I used to build locally with the date of your change, suggests to me that my build should have included your fix.</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="color:rgb(31,73,125)">Kind regards,</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US" style="color:rgb(31,73,125)"> </span><u></u><u></u></p><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">Stefan Lietzau</span></b><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p><p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">Von:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> Ilya Biryukov [mailto:<a href="mailto:ibiryukov@google.com" target="_blank">ibiryukov@google.com</a>] <br><b>Gesendet:</b> Dienstag, 4. Juni 2019 09:29<br><b>An:</b> Stefan Lietzau; Kadir Çetinkaya<br><b>Cc:</b> via clangd-dev<br><b>Betreff:</b> Re: [clangd-dev] Automatically adding includes always inserts the full path on windows</span><u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">Hi Stefan,<u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Thanks for reporting this. I don't think any of the active clangd developers run on Windows, so bugs like this can easily go unnoticed.<u></u><u></u></p></div><div><p class="MsoNormal">To add to what Kadir was requesting, could you point to a particular point in code that does the string comparison? If some of the strings come from user input (e.g. flags to the compiler), we should definitely normalize them before comparisons. <u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal"><a href="mailto:kadircet@google.com" id="gmail-m_-8432750812191701955gmail-m_1209841820732159825gmail-m_974067595855783935gmail-m_462318865939660136plusReplyChip-3" target="_blank">@Kadir Çetinkaya</a>, does your change also cover non-diagnostic use-cases? The function name looks very diagnostic-specific<u></u><u></u></p></div></div><p class="MsoNormal"> <u></u><u></u></p><div><div><p class="MsoNormal">On Mon, Jun 3, 2019 at 8:20 PM Stefan Lietzau via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p></div><blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt"><div><div><p class="MsoNormal">Hi there,<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal"><span lang="EN-US">I’m using clangd with vscode on windows with the option to add includes when autocompleting symbols. However the inserted include is always absolute, even if the file is present in the include path (compile-commands.json generated by CMake). I tracked the problem down to a path comparison where one path coming from the compilation database contains forward slashes and the other path (header where the symbol definition was found) contains backslashes. Since this is a simple string comparison it fails and determines the header is not part of the include directories.</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US">I don’t think the best fix would be to convert the paths before comparison or use a better comparison. Instead I think this is something that needs to be fixed deep inside clang tooling. That means I think the paths returned by the compilation database should be in a predictable format.</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US">What do you guys think?</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US">Kind regards</span><u></u><u></u></p><p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10pt;font-family:Arial,sans-serif">Stefan</span></b><u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p></div></div><p class="MsoNormal">_______________________________________________<br>clangd-dev mailing list<br><a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a><br><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><u></u><u></u></p></blockquote></div><p class="MsoNormal"><br clear="all"><u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p></div><p class="MsoNormal">-- <u></u><u></u></p><div><div><div><div><div><p class="MsoNormal">Regards,<u></u><u></u></p></div><div><p class="MsoNormal">Ilya Biryukov<u></u><u></u></p></div></div></div></div></div></div></div></blockquote></div><p class="MsoNormal"><br clear="all"><u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p></div><p class="MsoNormal">-- <u></u><u></u></p><div><div><div><div><div><p class="MsoNormal">Regards,<u></u><u></u></p></div><div><p class="MsoNormal">Ilya Biryukov<u></u><u></u></p></div></div></div></div></div></div></div></blockquote></div><p class="MsoNormal"><br clear="all"><u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal">-- <u></u><u></u></p><div><div><div><div><div><p class="MsoNormal">Regards,<u></u><u></u></p></div><div><p class="MsoNormal">Ilya Biryukov<u></u><u></u></p></div></div></div></div></div></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-8432750812191701955gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Regards,</div><div>Ilya Biryukov</div></div></div></div></div>
</blockquote></div>