This is an archive of the discontinued LLVM Phabricator instance.

[VFS] More consistent support for Windows
ClosedPublic

Authored by amccarth on Dec 5 2019, 2:37 PM.

Details

Summary

Removed some #ifdefs specific to Windows handling of VFS paths. This eliminates most of the differences between the Windows and non-Windows code paths.

Making this work required some changes to account for the fact that VFS file paths can be Posix style or Windows style, so you cannot just assume that they use the host's native path style. In one case, this means implementing our own version of make_absolute, since the filesystem code in Support doesn't have styles in the sense that the path code does.

Diff Detail

Event Timeline

amccarth created this revision.Dec 5 2019, 2:37 PM
amccarth planned changes to this revision.Dec 5 2019, 2:57 PM

Hold off on this one. It needs an explicit test for canonicalization.

rnk added a comment.Dec 5 2019, 3:15 PM

I would add, take a look at the existing unit tests (llvm/unittests/Support/VirtualFileSystemTests.cpp) and audit for _WIN32 ifdefs that we can remove after this change.

amccarth updated this revision to Diff 240240.Jan 24 2020, 10:01 AM
amccarth retitled this revision from [VFS] Use path canonicalization on all paths to [VFS] More consistent support for Windows.
amccarth edited the summary of this revision. (Show Details)

cc: +thakis, who expressed interest in seeing a fix for the text exempted on Windows.

rnk added a comment.Jan 31 2020, 2:01 PM

I was worried there would be more duplication. :) As far as rebuilding the wheel square goes, this seems totally reasonable. I had a question and a nit, though.

llvm/lib/Support/VirtualFileSystem.cpp
1112–1114

It looks like you assign posix style if the working directory has windows path style. Is that what you meant to do?

1118

Result.endswith(sys::path::get_separator(style)) saves a boolean condition

amccarth marked 3 inline comments as done.Feb 3 2020, 1:50 PM
amccarth added inline comments.
llvm/lib/Support/VirtualFileSystem.cpp
1112–1114

Oops! Nice catch.

Although some of the tests exercise this path, none of them caught the problem because the effect here is very minor (direction of a slash). I've turned the logic around, which makes the more common case (posix) dependent upon the condition.

1118

I hadn't realized ends_with was added to std::string. But it's a C++20 enhancement, which I think is too new for us right now. I'll use StringRef::endswith.

amccarth updated this revision to Diff 242190.Feb 3 2020, 2:26 PM
amccarth marked an inline comment as done.

Addressed rnk's comments: fixed path style detection bug, and used StringRef::endswith.

rnk accepted this revision.Feb 3 2020, 2:37 PM

lgtm, thanks!

This revision is now accepted and ready to land.Feb 3 2020, 2:37 PM
amccarth closed this revision.Feb 19 2020, 8:21 AM

This landed in da45bd232165eab5d6ec4f1f4f18db8644289142

It wasn't automatically closed because I misspelled "Differential Revision."