This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fill RealPathName for virtual files.
ClosedPublic

Authored by kadircet on Nov 29 2018, 7:21 AM.

Details

Summary

Absolute path information for virtual files were missing even if we
have already stat'd the files. This patch puts that information for virtual
files that can succesffully be stat'd.

Diff Detail

Repository
rC Clang

Event Timeline

kadircet created this revision.Nov 29 2018, 7:21 AM
kadircet updated this revision to Diff 175898.Nov 29 2018, 10:11 AM
  • Update tests
ilya-biryukov added inline comments.Nov 30 2018, 2:30 AM
include/clang/Basic/FileManager.h
181

The FIXME inside the function suggests we might change the name or semantics of RealPathName, so maybe simply refer to the field by name and avoid mentioning the semantics of the function.

unittests/Basic/FileManagerTest.cpp
237

This test seems to rely on the old behavior. Is there a way to test the file wasn't open other than looking at RealPathName?

238

Should we fill-in the RealPathName in that case as well?
I'm not sure what the semantics should be. WDYT?

253

We should find a way to test file was not "opened" (I think it actually does stat the file now, right?)

323

After a check EXPECT_EQ(file1, file2), this is clearly true.
Maybe add a smaller test with a single call to getVirtualFile() and an assertion that the real path is set?
Alternatively, add an assertion to this test right after the first call to getVirtualFile().

kadircet updated this revision to Diff 176078.Nov 30 2018, 3:37 AM
kadircet marked 5 inline comments as done.

Address comments

kadircet added inline comments.Nov 30 2018, 4:28 AM
unittests/Basic/FileManagerTest.cpp
237

There is also the vfs::file stored inside the FileEntry but unfortunately there are no getters exposing this one. But I believe this behavior is still correct for the getFile case, since RealPathName will only be filled when we open the file.

238

I don't think so, since we need the vfs::file to query the real path, I believe it is still ok to leave them empty for real files that hasn't been opened yet.

IIUC, stating and opening are very similar in nature(from the perspective of FileManager), the only difference is there is no deferred stating for virtual files therefore it is like a normal file that will always be opened.

253

AFAIK, any file accessed through getVirtualFile is immediately opened, then later on accessing a file with the same name through getFile with openfile=false won't have any affect, since this file will be alive and marked as opened in the cache.

So I believe opening and stating is dual of each other. Therefore checking for one should be equivalent to check for other.

kadircet marked 2 inline comments as done.Nov 30 2018, 4:29 AM
ilya-biryukov accepted this revision.Nov 30 2018, 7:42 AM

LGTM and a few nits

include/clang/Basic/FileManager.h
108

s/arther/rather
Let's leave out the RealPathName part, it seemed to be there for historical reasons.

182

We never use the returned value. Maybe drop it?

unittests/Basic/FileManagerTest.cpp
237

Using vfs::File LG, thanks!

253

I'm not sure about the semantics either, it seems we need to stat anyway, maybe open referes to reading the file contents in this case?
Anyhow, we're not actually changing semantics of the parts that were tested here, so there's no reason to go deeper into this.

This revision is now accepted and ready to land.Nov 30 2018, 7:42 AM
kadircet updated this revision to Diff 176146.Nov 30 2018, 9:12 AM
kadircet marked 5 inline comments as done.
  • Address comments
This revision was automatically updated to reflect the committed changes.