[PATCH] D19842: In openFileForRead, attempt to fetch the actual name of the file on disk -- including case -- so that clang can later warn about non-portable #include and #import directives.

Bruno Cardoso Lopes via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 13:19:11 PDT 2016


bruno added a comment.

In http://reviews.llvm.org/D19842#427579, @eric_niebler wrote:

> The only way I know to make `realpath` 100% correct 100% of the time is to `readdir` starting from the drive root, enumerating all the subdirectories to find one that matches the next path component, and recursing all the way up. I think I'm safe in saying that making roughly a bajillion API calls that hit the disk over and over is going to be a lot slower than making just one and hoping for the best. :-)
>
> If you can think of a better way to make this correct 100% of the time on all the platforms LLVM supports, I'm all ears.


clang has been using `realpath` in the FileManager for a long time and it seems to be working fine, I'm not following why it isn't 100% correct. In the VFS, as far as the needs go, it has been used to detect symlink in the components and work as expected. If we have an API in the lines of llvm::sys::fs::canonical(StringRef Filename, SmallVectorImpl<char > &path, int FD = -1), where we could optionally do the fast lookup in case FD > 0 (or any platform independent semantic) it's a matter of specifying the API contract what's the expected behaviour.


http://reviews.llvm.org/D19842





More information about the llvm-commits mailing list