This is an archive of the discontinued LLVM Phabricator instance.

[Support] [Windows] Convert paths to the preferred form
ClosedPublic

Authored by mstorsjo on Oct 15 2021, 4:50 AM.

Details

Summary

This normalizes most paths (except ones input from the user as command
line arguments) into the preferred form, if real_style() evaluates to
Windows_forward.

Diff Detail

Event Timeline

mstorsjo created this revision.Oct 15 2021, 4:50 AM
mstorsjo requested review of this revision.Oct 15 2021, 4:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 15 2021, 4:50 AM
mstorsjo updated this revision to Diff 383263.Oct 29 2021, 2:07 AM

Updated after rebasing and reworking the earlier commits.

mstorsjo updated this revision to Diff 384135.Nov 2 2021, 9:18 AM

Make sure to force paths to backslashes in widenPath if they are passed with the absolute long path prefix \\?\ but with forward slashes, i.e. as //?/.

aaron.ballman added inline comments.
llvm/lib/Support/Windows/Path.inc
79–80

I'm assuming we purposefully don't care about complete nonsense like \/?\ not getting normalized into \\?\?

We should add tests for both //?/ and the nonsense form.

mstorsjo added inline comments.Nov 2 2021, 10:29 AM
llvm/lib/Support/Windows/Path.inc
79–80

Thanks for the suggested edit, yeah that's nicer.

I added a test for //?/ in llvm/unittests/Support/Path.cpp, lines 2296-2305, but I guess we could add a test for the nonsense form to clarify that case too.

aaron.ballman added inline comments.Nov 2 2021, 11:12 AM
llvm/lib/Support/Windows/Path.inc
79–80

I don't insist on the nonsense form, but I figured it would help to demonstrate that we explicitly considered the case and don't care to support it.

mstorsjo updated this revision to Diff 384217.Nov 2 2021, 1:51 PM

Did the suggested code simplification, added a testcase for the degenerate case we don't handle.

aaron.ballman accepted this revision.Nov 3 2021, 4:34 AM

LGTM, thank you!

This revision is now accepted and ready to land.Nov 3 2021, 4:34 AM
This revision was automatically updated to reflect the committed changes.