This is an archive of the discontinued LLVM Phabricator instance.

Process tilde in llvm::sys::path::native.
ClosedPublic

Authored by sepavloff on Dec 7 2016, 8:51 AM.

Details

Summary

Windows does not treat ~ as a reference to home directory, so the call
to llvm::sys::path::native on, say, ~/somedir produces ~\somedir,
which has different meaning than the original path. With this change
tilde is expanded on Windows to user profile directory. Such behavior
keeps original meaning of the path and is consistent with the algorithm
of llvm::sys::path::home_directory.

Diff Detail

Repository
rL LLVM

Event Timeline

sepavloff updated this revision to Diff 80604.Dec 7 2016, 8:51 AM
sepavloff retitled this revision from to Process tilde in llvm::sys::path::native..
sepavloff updated this object.
sepavloff added a subscriber: llvm-commits.
rnk edited edge metadata.Feb 27 2017, 10:31 AM

Seems like reasonable functionality. I just have a few comments on the unittest. If SmallString doesn't do operator==, they're mostly irrelevant.

unittests/Support/Path.cpp
951–953 ↗(On Diff #80604)

Does this simplify to EXPECT_EQ(Path7, PathHome + "\\aaa")? If so we don't need the const char * local.

958 ↗(On Diff #80604)

Does EXPECT_EQ work?

sepavloff updated this revision to Diff 89973.Feb 27 2017, 9:14 PM

Use EXPECT_EQ instead of EXPECT_TRUE in unit test.

sepavloff added inline comments.Feb 27 2017, 9:23 PM
unittests/Support/Path.cpp
951–953 ↗(On Diff #80604)

SmallString does not have operator +. It has operator += but it does not help here.

958 ↗(On Diff #80604)

Yes, it works, as SmallString has operator == inherited from SmallVectorImpl.
It also works in comparisons with string literals, due to presence of:

  • operator==(StringRef, StringRef)
  • SmallString::operator StringRef()
  • StringRef(const char *)

Corresponding checks were updated accordingly.

rnk accepted this revision.Feb 28 2017, 10:28 AM

lgtm

This revision is now accepted and ready to land.Feb 28 2017, 10:28 AM
This revision was automatically updated to reflect the committed changes.