[llvm] r208007 - [Support/MemoryBuffer] Introduce a boolean parameter (false by default) 'IsVolatile' for the open file functions.

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon May 5 17:29:33 PDT 2014


On May 5, 2014, at 5:13 PM, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:

>> The problem is not the data itself, the problem is that mmap may leave the buffer without a null terminator, because the file size changed by the time mmap brings in the last page.
>> Initializing the memory with read/pread has no such issue, the null terminator is guaranteed.
> 
> This should be in a comment. Maybe it might be a good idea to change
> the flag name to VolatileSize to make it clear what is being guarded
> against?

Ok.

>  Do you have to handle the file shirking while it is being
> read? I don't think the existing code handles that.

It does put a null terminator but looking into it more, I think it needs to zero initialize the rest of the buffer as well.

> 
>>> 
>>> What is the intended use case for this?
>> 
>> libclang passes isVolatile = true for user files, because it has to deal with user files constantly getting edited/updated while trying parse them.
> 
> And probably this too as an example.

Ok.

Thanks for the review!

> 
> Thanks,
> Rafael





More information about the llvm-commits mailing list