[PATCH] D46887: Fix llvm::sys::path::remove_dots() to return "." instead of an empty path.

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 16 00:57:46 PDT 2018


labath added a comment.

In https://reviews.llvm.org/D46887#1100111, @ruiu wrote:

> I believe this function was written based on Rob Pike's Clean() function for Go, and the Go's function also returns "." (instead of "") for the current directory. So this change makes sense to me.
>
> https://golang.org/pkg/path/#example_Clean
>
> Maybe you should return "." for "". as well. An empty string as a path component makes sense, as "/foo/bar", "/foo//bar" and "/foo/./bar" are all interpreted as the same path. Go's Clean() returns "." for "" too.


I was surprised by this behavior, so I checked what python does in this case. And indeed, `os.path.normpath("")` will also return `"."`. So, it seems there is an established behavior pattern for this input among functions of this type, and it would be best to follow that (if that doesn't cause too much havoc among existing users).


https://reviews.llvm.org/D46887





More information about the llvm-commits mailing list