This patch removes the GetByteSize method from FileSpec and updates its uses with calls to the FileSystem.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
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.
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. |
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.