This is an archive of the discontinued LLVM Phabricator instance.

Remove FileSpec::ReadFileContents
ClosedPublic

Authored by zturner on Mar 5 2017, 9:19 AM.

Details

Summary

The idea is that DataBufferLLVM already covers this use case, so there is no point duplicating the code. The only tricky thing is that I found one case where we attempt to modify the bytes we read in (in ObjectFilePECOFF). It seems kind of hackish, but it worked because ReadFileContents would only ever load a copy of the data into memory. But LLVM uses mmap whenever possible and maps as readonly, so this was causing failures when we tried to modify the bytes.

To address this I've added a flag called Private which forces us to not use mmap. In an ideal world, we would still try to use mmap, but map the bytes as private / writable. This is a patch for another day.

Also for another day is to rename DataBufferLLVM to DataBufferFile.

Diff Detail

Repository
rL LLVM

Event Timeline

zturner created this revision.Mar 5 2017, 9:19 AM
labath accepted this revision.Mar 6 2017, 8:13 AM

Looks great. One thing I'd consider is adding a function which returns the data buffer as a StringRef (AsStringRef() ?) instead of the GetChars function, but I don't feel strongly about it.

This revision is now accepted and ready to land.Mar 6 2017, 8:13 AM
This revision was automatically updated to reflect the committed changes.