[Support] Add a new path style for Windows with forward slashes
authorMartin Storsjö <martin@martin.st>
Mon, 4 Oct 2021 14:17:00 +0000 (17:17 +0300)
committerMartin Storsjö <martin@martin.st>
Fri, 5 Nov 2021 08:41:51 +0000 (10:41 +0200)
commita8b54834a186f5570b49b614e31b961a9cf1cbfe
treecf9f9891831cdbffdc969e5c657c0a4a69a614b2
parentf95bd18b5faa6a5af4b5786312c373c5b2dce687
[Support] Add a new path style for Windows with forward slashes

This behaves just like the regular Windows style, with both separator
forms accepted, but with get_separator() returning forward slashes.

Add a more descriptive name for the existing style, keeping the old
name around as an alias initially.

Add a new function `make_preferred()` (like the C++17
`std::filesystem::path` function with the same name), which converts
windows paths to the preferred separator form (while this one works on
any platform and takes a `path::Style` argument).

Contrary to `native()` (just like `make_preferred()` in `std::filesystem`),
this doesn't do anything at all on Posix, it doesn't try to reinterpret
backslashes into forward slashes there.

Differential Revision: https://reviews.llvm.org/D111879
llvm/include/llvm/Support/Path.h
llvm/lib/Support/Path.cpp
llvm/unittests/Support/Path.cpp