On Feb 12, 2014, at 2:32 PM, Rafael Espíndola <[email protected]>
wrote:
>>> Why is the reference count necessary? Given its nature I would expect the
>>> FS to outlive the file manger, in which case the FileManager could have
>>> just a pointer to the FileSystem.
>>
>>
>> The FS is likely to get shared among a number of FileManagers in different
>> compiler instances within a thread. Yes, we could try to establish and
>> maintain relationships among these, but it’s simpler and costs us
>> effectively nothing to make this ref-counted.
>
> It costs simplicity in understanding the code. If there is a complex
> logic as to when a FS needs to be created, I can understand that a
> reference count might be semantically the simplest option.
Look at CompilerInstance. It has a number of IntrusiveRefCntPtr’s that exist
because we consistently ran into problems with other clients needing to hold
onto these core, cooperating objects for longer than the given
CompilerInstance. ASTUnit is one of the major culprits here, but it’s not the
only one.
> But is it not the case that
> * A clang process will always use a single FS.
> * The decision as to which to use can happen just after parsing the
> command line arguments?
We may spawn a number of Clang invocations within the same thread to build
modules from headers, and they all need to share the same FS.
- Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits