This is an archive of the discontinued LLVM Phabricator instance.

[FileSystem] Remove GetByteSize() from FileSpec
ClosedPublic

Authored by JDevlieghere on Oct 26 2018, 5:58 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

JDevlieghere created this revision.Oct 26 2018, 5:58 PM
davide accepted this revision.Oct 26 2018, 6:08 PM
davide added a subscriber: davide.

LGTM

This revision is now accepted and ready to land.Oct 26 2018, 6:08 PM
zturner accepted this revision.Oct 26 2018, 7:10 PM

I always wondered if we actually even need methods like this in FileSystem given that they already exist in llvm::sys::fs. Is it possible to just call the llvm methods directly, or is it still helpful to call the ones in FileSystem so we can more transparently interoperate with the VFS layer somehow?

I always wondered if we actually even need methods like this in FileSystem given that they already exist in llvm::sys::fs. Is it possible to just call the llvm methods directly, or is it still helpful to call the ones in FileSystem so we can more transparently interoperate with the VFS layer somehow?

This particular function uses the VFS so it has to go through the FileSystem class. Personally I feel we should do the same for functions that don't, because then it's clear and simple (i.e. everything uses FileSystem) and we eliminate potential bugs where someone uses the llvm::sys::fs while it should've actually gone through the VFS.

shafik added a subscriber: shafik.Oct 29 2018, 10:58 AM

Are we refactoring in the right place? Why not just refactor FileSpec::GetByteSize() why is FileSpec the wrong place?

source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
718 ↗(On Diff #171383)

1024u just for consistency, I don't expect this is practically a problem.

Are we refactoring in the right place? Why not just refactor FileSpec::GetByteSize() why is FileSpec the wrong place?

There was another review thread where we discussed this just the other day. Basically, It took a herculean effort to get FileSpec into the Utility library, which helped greatly with layering and we don't want to undo this. In order to for GetByteSize to be able to use the VFS, it has to be able to use FileSystem, so either FileSpec has to move out of Utility, FileSystem has to move into Utility, or GetByteSize has to move out of FileSpec. FileSystem moving into Utility might actually be a worthwhile goal long term, but even putting that aside, I think FileSpec should just be a thing for manipulating paths. For example, it has the notion of manipulating paths which might not even make sense on the given host platform (e.g. it has a member variable which represents the path *syntax). You might be on a Windows host debugging a remove Linux target, for example, and your host needs to have some way to manipulate paths on the remote which use a non-host syntax. That's what FileSpec is supposed to be. It just deals with strings.

This revision was automatically updated to reflect the committed changes.