You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Clang] only convert dependency filename to native form when MS-compatible
Currently, llvm::sys::path::native is called unconditionally when
generating dependency filenames. This is correct on Windows, where
backslashes are valid path separators, but can be incorrect on
non-Windows platforms when the Clang invocation is not MS-compatible
(-fno-ms-compatibility), because in that case backslashes in the
filename are converted by llvm::sys::path::native to forward slashes,
while they should be treated as ordinary characters.
This fixes the following inconsistency on non-Windows platforms (notice
how the dependency output always converts the backslash to a forward
slash, assuming it's a path separator, while the actual include
directive treats it as an ordinary character when -fno-ms-compatibility
is set):
$ tree
.
└── foo
├── a
│ └── b.h
└── a\b.h
3 directories, 2 files
$ cat foo/a/b.h
#warning a/b.h
$ cat foo/a\\b.h
#warning a\\b.h
$ echo '#include "foo/a\\b.h"' | clang -c -xc - -fms-compatibility -o /dev/null
In file included from <stdin>:1:
./foo/a/b.h:1:2: warning: a/b.h [-W#warnings]
1 | #warning a/b.h
| ^
1 warning generated.
$ echo '#include "foo/a\\b.h"' | clang -xc - -fms-compatibility -M -MG
-.o: foo/a/b.h
$ echo '#include "foo/a\\b.h"' | clang -c -xc - -fno-ms-compatibility -o /dev/null
In file included from <stdin>:1:
./foo/a\b.h:1:2: warning: a\\b.h [-W#warnings]
1 | #warning a\\b.h
| ^
1 warning generated.
$ echo '#include "foo/a\\b.h"' | clang -xc - -fno-ms-compatibility -M -MG
-.o: foo/a/b.h
Signed-off-by: Ruoyu Zhong <[email protected]>
0 commit comments