diff options
author | Nico Weber <thakis@chromium.org> | 2020-05-04 21:15:29 -0400 |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2020-05-05 13:54:55 -0400 |
commit | 8fc7a907b93a8e9eef96e872f8f926db3ebfe9b6 (patch) | |
tree | eae9ce971b6290158d2ddeccd3b685b07a0c557b /llvm/lib/Support/Path.cpp | |
parent | 93d1108801ddfe3d5e68296cdc62e44b3382e31e (diff) | |
download | llvm-8fc7a907b93a8e9eef96e872f8f926db3ebfe9b6.zip llvm-8fc7a907b93a8e9eef96e872f8f926db3ebfe9b6.tar.gz llvm-8fc7a907b93a8e9eef96e872f8f926db3ebfe9b6.tar.bz2 |
Let normalize() for posix style convert backslash to slash unconditionally.
Currently, normalize() for posix replaces backslashes to slashes, except
that two backslashes in sequence are kept as-is.
clang calls normalize() to convert \ to / is microsoft compat mode. This
generally works well, but a path like "c:\\foo\\bar.h" with two
backslashes doesn't work due to the exception in normalize().
These paths happen naturally on Windows hosts with e.g.
`#include __FILE__`, and them not working on other hosts makes it
more difficult to write tests for this case.
The special case has been around without justification since this code
was added in r203611 (since then moved around in r215241 r215243). No
integration tests fail if I remove it.
Try removing the special case.
Differential Revision: https://reviews.llvm.org/D79265
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 0a4d581..7756290 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -540,15 +540,9 @@ void native(SmallVectorImpl<char> &Path, Style style) { Path = PathHome; } } else { - for (auto PI = Path.begin(), PE = Path.end(); PI < PE; ++PI) { - if (*PI == '\\') { - auto PN = PI + 1; - if (PN < PE && *PN == '\\') - ++PI; // increment once, the for loop will move over the escaped slash - else - *PI = '/'; - } - } + for (auto PI = Path.begin(), PE = Path.end(); PI < PE; ++PI) + if (*PI == '\\') + *PI = '/'; } } |