This is an archive of the discontinued LLVM Phabricator instance.

[LLVM] sys::path::replace_path_prefix fix and simplifications
ClosedPublic

Authored by saudi on Apr 1 2020, 8:37 AM.

Details

Summary

When working on D76869, I discovered some failing scenarios for sys::path::replace_path_prefix.
However, this function is already a bit complex and the fix would make the logic harder to read.
Also, its parameters strict and style are always used with the default value.

This patch removes the 2 parameters, reducing the code greatly and made it easier to fix the failing cases.

Overall, I was planning to split my work in 3 steps:

  1. This fix
  2. finish D76869 (which this fix will make smaller/simpler)
  3. Modifiy replace_prefix_map under windows, to replace startswith with a case and separator insensitive version (for example, C:\\OneFolder\\ would match c:/onefolder/file.cpp)

Diff Detail

Event Timeline

saudi created this revision.Apr 1 2020, 8:37 AM
MaskRay accepted this revision.Apr 1 2020, 12:59 PM

Thanks!

llvm/include/llvm/Support/Path.h
173–175

So, this change restores the original 3-parameter form of replace_path_prefix. LG

This revision is now accepted and ready to land.Apr 1 2020, 12:59 PM
This revision was automatically updated to reflect the committed changes.
saudi updated this revision to Diff 262131.EditedMay 5 2020, 9:20 AM
saudi added a subscriber: amccarth.

Added Style parameter to replace_path_prefix, as suggested.
This allowed to make the replace_path_prefix unit-test platform independent, removing a #ifdef _WIN32 that I added in a previous version of the patch.

The tests ninja check-all passed on windows.
@amccarth : Does it cover all the VFS tests you suggested that I double-check?

EDIT: Nevermind this update and comment, it was intended to another patch