Windows path separators in `compile_commands.json` not parsed correctly
z2oh opened this issue · comments
Windows path separators in compile_commands.json
are not parsed correctly in splitShellEscapedCommand
. Following the comment there to clang's unescapeCommandLine()
, it seems clang has implemented Windows specific parsing.
There's a separate bug in Swift CMake that generates incorrect path separators on Windows, but after that is fixed I expect the entries in the compilation database to look like:
{
"directory": "C:\\path\\to\\build",
"command": "C:\\path\\to\\swiftc.exe <snip>,
"file": "C:\\path\\to\\build\\filename.swift",
"output": "path\\to\\filename.swift.obj"
}
These are single-escaped JSON backslashes, which are unescaped twice (once by JSON parsing, once in the function linked above), resulting paths like C:pathtobuildfilename.swift
being passed to sourcekitd
. If I manually change these paths in compile_commands.json
to double-escaped backslashes (\\\\
) or forward slashes, the paths are interpreted as expected.
Tracked in Apple’s issue tracker as rdar://120809063