mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-25 15:01:07 +00:00
Fix pr31836 on Windows too, and correctly handle repeated separators.
The approach in D30000 assumes that the '/' returned by path::begin() is the first element for absolute paths, but that's not true on Windows. Also, on Windows backslashes in include lines often end up escaped so that there are two of them. Having backslashes in include lines is undefined behavior in most cases and implementation-defined behavior in C++20, but since clang treats it as normal repeated path separators, the diagnostic should too. Unbreaks -Wnonportable-include-path for absolute paths on Windows, and unbreaks it on non-Windows in the case of absolute paths with repeated directory separators. This affects e.g. the `#include __FILE__` technique if the file passed to clang has the wrong case for the drive letter. Before: C:\src\llvm-project>bin\clang-cl.exe c:\src\llvm-project\test.cc c:\\src\\llvm-project\\test.cc(4,10): warning: non-portable path to file '"c\\srccllvm-projectctest.cc.'; specified path differs in case from file name on disk [-Wnonportable-include-path] ^ Now: C:\src\llvm-project> out\gn\bin\clang-cl c:\src\llvm-project\test.cc c:\\src\\llvm-project\\test.cc(4,10): warning: non-portable path to file '"C:\\src\\llvm-project\\test.cc"'; specified path differs in case from file name on disk [-Wnonportable-include-path] ^ Differential Revision: https://reviews.llvm.org/D79223
This commit is contained in:
parent
19f2437843
commit
5d044b8420
@ -47,7 +47,7 @@ enum class Style { windows, posix, native };
|
||||
/// foo/ => foo,.
|
||||
/// /foo/bar => /,foo,bar
|
||||
/// ../ => ..,.
|
||||
/// C:\foo\bar => C:,/,foo,bar
|
||||
/// C:\foo\bar => C:,\,foo,bar
|
||||
/// @endcode
|
||||
class const_iterator
|
||||
: public iterator_facade_base<const_iterator, std::input_iterator_tag,
|
||||
|
@ -1176,6 +1176,7 @@ TEST_F(FileSystemTest, FileMapping) {
|
||||
}
|
||||
|
||||
TEST(Support, NormalizePath) {
|
||||
// Input, Expected Win, Expected Posix
|
||||
using TestTuple = std::tuple<const char *, const char *, const char *>;
|
||||
std::vector<TestTuple> Tests;
|
||||
Tests.emplace_back("a", "a", "a");
|
||||
|
Loading…
x
Reference in New Issue
Block a user