This is an archive of the discontinued LLVM Phabricator instance.

[vfs] add 'Status::copyWithNewSize'
AbandonedPublic

Authored by arphaman on Nov 12 2018, 3:47 PM.

Details

Reviewers
JDevlieghere
Summary

This patch adds a Status::copyWithNewSize method to vfs::Status. It allows the user to duplicate a status object with a different size.
This is part of the work for upstreaming clang-scan-deps, see https://reviews.llvm.org/D53354 and [cfe-dev] RFC: prototype of clang-scan-deps, faster dependency scanning tool for explicit modules and clangd.

Diff Detail

Repository
rL LLVM

Event Timeline

arphaman created this revision.Nov 12 2018, 3:47 PM

The change itself is fine but I wonder if we really need these helper methods and can't just use the copy constructor?

Sorry for joining in the middle of the conversation without the full context, but what is the use-case for status that were created with the wrong size that needs to be patched up?
It's clear what the function is doing operationally, but it's hard to see why would we want to change the size of the file, while leaving other things (like modification time, etc.) the same?

arphaman abandoned this revision.Nov 13 2018, 11:06 AM

The change itself is fine but I wonder if we really need these helper methods and can't just use the copy constructor?

It's probably not much of value if there will be just one use case. I'll just use the constructor as suggested :)

Sorry for joining in the middle of the conversation without the full context, but what is the use-case for status that were created with the wrong size that needs to be patched up?
It's clear what the function is doing operationally, but it's hard to see why would we want to change the size of the file, while leaving other things (like modification time, etc.) the same?

For this particular use case we would like to create a virtual file system that overrides file contents. So basically we are pretending that the file on disk has a completely different source text, which requires us to update the size in the stat to ensure that Clang doesn't think that the file has changed on disk when it will compare the size of the file's memory buffer and the size it has in the stat value.

For this particular use case we would like to create a virtual file system that overrides file contents. So basically we are pretending that the file on disk has a completely different source text, which requires us to update the size in the stat to ensure that Clang doesn't think that the file has changed on disk when it will compare the size of the file's memory buffer and the size it has in the stat value.

Would be interesting to see why InMemoryFileSystem (possibly in a combination with OverlayFileSystem) does not work for that case, but nevermind, will take a closer look at the patch on my spare time to understand the use-case better.