<div dir="ltr">How do you do that? Generating the compilation database could be extremely difficult, since you often will have mixed forward and back slashes in the system used to generate it.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 3, 2015 at 4:12 PM, Mehmet Erol Sanliturk <span dir="ltr"><<a href="mailto:m.e.sanliturk@gmail.com" target="_blank">m.e.sanliturk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Fri, Apr 3, 2015 at 3:57 PM, Daniel Dilts <span dir="ltr"><<a href="mailto:diltsman@gmail.com" target="_blank">diltsman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr">Unfortunately this approach can be a significant burden on Windows, since it isn't always obvious from programmatic inspection what is and isn't a file path.</div><div class="gmail_extra"><br></div></blockquote><div><br><br></div></span><div>Therefore , enforcing forward slashes in file names in every environment is more suitable .<br><br><br></div><div><div class="h5"><div>Mehmet Erol Sanliturk<br><br><br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 3, 2015 at 3:32 PM, Mehmet Erol Sanliturk <span dir="ltr"><<a href="mailto:m.e.sanliturk@gmail.com" target="_blank">m.e.sanliturk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Fri, Apr 3, 2015 at 3:07 PM, Daniel Dilts <span dir="ltr"><<a href="mailto:diltsman@gmail.com" target="_blank">diltsman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div>You are correct. Forward slashes can be substituted for backslashes in many cases, but many compilation databases will be generated with backslashes. Either we mandate that only forward slashes can be used, or CommandLineArgumentParser must be fixed.</div><div><br></div><div>I am willing and able to make the fixes, but I don't know how to test for the platform so that the correct set of escapes are used.</div></div><div class="gmail_extra"><br></div></blockquote><div><br><br><br></div></span><div>In Unix world , back slash is used for escape character .<br></div><div>In Windows , in file names , back and forward slashes are usable .<br></div><div>Their intersection is forward slash .<br><br></div><div>My opinion is that enforcing forward slashes in file names is more suitable .<br></div><div>Otherwise , always will be necessary to use escape back slash for Windows file names which is not a convenient form ( In Windows always will be necessary to clear additional back slashes before submitting it to operating system routines ) .<br><br></div><div>Fixing CommandLineArgumentParser also may be a very convenient action : For file names , forward and backward slashes may be treated equivalent without using escape back slash .<br></div><div>For back slash used file names , when they are used in Unix environments , they may be directly converted to forward slashes .<br><br><br></div><div>Lazarus and Free Pascal is using this form since , I think , their starting time . When this form is used ( forward or back slashes ) , conversion of them in Unix by the compiler is the most convenient way ( in Windows there is no any need to such a conversion in sources ) .<br><br></div><div>I did not use Visual Studio , but , I am compiling sources in Unix ( FreeBSD , Linux ) compilable in Visual Studio without any trouble for forward slashes ( means Visual Studio is able to accept these , but please test this for exact decision ) .<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div><br><br><br></div><div>Mehmet Erol Sanliturk<br><br></div></font></span><div><div><div><br><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 3, 2015 at 2:43 PM, Mehmet Erol Sanliturk <span dir="ltr"><<a href="mailto:m.e.sanliturk@gmail.com" target="_blank">m.e.sanliturk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Apr 3, 2015 at 1:54 PM, Daniel Dilts <span dir="ltr"><<a href="mailto:diltsman@gmail.com" target="_blank">diltsman@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div><div dir="ltr"><div>I finally had the opportunity to look into this.</div><div><br></div><div>CommandLineArgumentParser in JSONCompilationDatabase.cpp deals with escapes by discarding all backslash characters. I imagine that this works pretty well on Linux, not perfectly, but well enough.</div><div><br></div><div>Windows uses backslash as a separator in file paths, so this breaks most file paths on Windows.</div><div><br></div><div>How would one go about fixing this so it works on both Windows and Linux? Obviously the different escape sequences need to be implemented. What I really mean is, how do you make it so that it uses the correct set of escapes depending on platform?</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 17, 2015 at 12:57 PM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr">I haven't had time to look.<br></div><div><div><br><div class="gmail_quote">On Tue, Mar 17, 2015 at 6:06 PM Daniel Dilts <<a href="mailto:diltsman@gmail.com" target="_blank">diltsman@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr">What appears to be the exact problem? Are relative paths just not properly implemented, or is the problem more specific than that?</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 17, 2015 at 4:07 AM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr">I think this is a known problem. Patches very welcome :)<br></div><br><div class="gmail_quote"><div><div>On Tue, Mar 17, 2015 at 1:14 AM Daniel Dilts <<a href="mailto:diltsman@gmail.com" target="_blank">diltsman@gmail.com</a>> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div><div dir="ltr"><div>I am calling runClangTidy using a JSONCompilationDatabase that I generate from a string. Everything works perfectly until I have a relative path.</div><div><br></div><div>With the following database I use "D:\\CMakeTest\\bld\\..\\src\\main.cpp" as the file to open:</div><div>[<br> {<br> "directory": "D:\\CMakeTest\\bld\\",<br> "command" : "D:/llvm/build/Debug/bin/clang.exe -I\"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\include\" -I\"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\atlmfc\\include\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\um\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\shared\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\winrt\" -I\"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\include\" -I\"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\atlmfc\\include\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\um\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\shared\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\winrt\" -DWIN32 -D_WINDOWS -D_DEBUG -DCMAKE_INTDIR=\"Debug\" ..\\src\\main.cpp",<br> "file" : "..\\src\\main.cpp"<br> },<br>]</div><div><br></div><div>This gives me an output of "Error while processing D:\\CMakeTest\\bld\\..\\src\\main.cpp."</div><div><br></div><div>When I use the following database with "D:\\CMakeTest\\src\\main.cpp" as the file to open, everything works.</div><div><br></div><div>[<br> {<br> "directory": "D:\\CMakeTest\\src\\",<br> "command" : "D:/llvm/build/Debug/bin/clang.exe -I\"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\include\" -I\"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\atlmfc\\include\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\um\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\shared\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\winrt\" -I\"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\include\" -I\"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\atlmfc\\include\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\um\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\shared\" -I\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\winrt\" -DWIN32 -D_WINDOWS -D_DEBUG -DCMAKE_INTDIR=\"Debug\" main.cpp",<br> "file" : "main.cpp"<br> },<br>]</div><div><br></div><div><br></div><div>Is there something that I am doing wrong? The only changes between the two compilation databases are the directory and file entries. Both should refer to the same absolute path.</div></div></div></div>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
</blockquote></div><br></div>
</blockquote></div>
</div></div></blockquote></div><br></div>
<br></div></div>_______________________________________________<br>
<br></blockquote><div><br><br><br><br></div><div>In Windows , forward slashes in source files are usable :<br><br></div><div>include '/a/b/....' ( relative paths can be used such as ../../../ etc. ) <br><br></div><div>( I am using this form , at least since ten years because I am compiling the same program sources in Windows and Unix without any change , in Fortran , Pascal , and C )<br></div><div><br></div><div>but , in Console , only back slashes are accepted :<br><br></div><div>dir \a\b\... /S<br></div><div>ren \a\b\d\g.c h.c<br><br></div><div>because , forward slashes are used for command line options .<br><br></div><div>I did not try forward slashes in quoted form : You may try it ( I do not have any Windows at present ) :<br><br></div><div>dir "/a/b/..." /S<br><br><br><br></div><div>Thank you very much .<span><font color="#888888"><br><br><br><br></font></span></div><span><font color="#888888"><div>Mehmet Erol Sanliturk<br><br><br></div></font></span></div><br></div></div>
</blockquote></div><br></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>