Page MenuHomePhabricator

Support: Use sys::path::is_style_{posix,windows}() in a few places
ClosedPublic

Authored by dexonsmith on Oct 21 2021, 6:38 PM.

Details

Summary

Use the new sys::path::is_style_posix() and is_style_windows() in a few
places that need to detect the system's native path style.

In llvm/lib/Support/Path.cpp, this patch removes most uses of the
private real_style(), where is_style_posix() and is_style_windows()
are just a little tidier.

Elsewhere, this removes _WIN32 macro checks. Added a FIXME to a
FileManagerTest that seemed fishy, but maintained the existing
behaviour.

Happy to split this up as much as makes sense. Mainly posting to show
examples for https://reviews.llvm.org/D112288.

Diff Detail

Event Timeline

dexonsmith created this revision.Oct 21 2021, 6:38 PM
dexonsmith requested review of this revision.Oct 21 2021, 6:38 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 21 2021, 6:38 PM
This revision is now accepted and ready to land.Oct 28 2021, 10:02 AM
dexonsmith retitled this revision from Support: Use sys::path::system_style() in a few places to Support: Use sys::path::is_style_{posix,windows}() in a few places.
dexonsmith edited the summary of this revision. (Show Details)
dexonsmith added reviewers: mstorsjo, rnk.

Rebased on top of https://reviews.llvm.org/D110369, which switched from system_style() to is_style_{posix,windows,native}(), and updated the description.

Also cleaned up uses of real_style() in llvm/lib/Support/Path.cpp that were unrelated to slash preferences.

Undo a no-op change in the Path unit tests that I didn't intend to put here.

dexonsmith requested review of this revision.Oct 28 2021, 5:16 PM

Fix some backwards checks in FileManagerTest.cpp. (check-clang check-llvm passes now.)

mstorsjo accepted this revision.Oct 29 2021, 3:28 AM

LGTM, too. D112786 does a couple more things that do pretty much the same - I don't mind if you want to fold them into this, or keep it as-is, with the bits that are closer to separator handling split out for clarity.

This revision is now accepted and ready to land.Oct 29 2021, 3:28 AM
dexonsmith edited the summary of this revision. (Show Details)

Squashed in the changes from https://reviews.llvm.org/D112786.

This revision was landed with ongoing or failed builds.Oct 29 2021, 12:09 PM
This revision was automatically updated to reflect the committed changes.

Looks like this breaks tests on windows: http://45.33.8.238/win/47971/step_7.txt

Please take a look and revert for now if it takes a while to fix.

Looks like this breaks tests on windows: http://45.33.8.238/win/47971/step_7.txt

Please take a look and revert for now if it takes a while to fix.

Should be fixed in 9091df5fad52ab6a281d7f4d6a508696e6f9fbae.

clang/lib/Basic/FileManager.cpp
129–133

This introduced a use-after-scope for DirNameStr. Fixed in 9091df5fad52ab6a281d7f4d6a508696e6f9fbae.