<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Feb 12, 2014 at 11:22 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><br>
On Feb 12, 2014, at 2:21 PM, Rafael Ávila de Espíndola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
<br>
><br>
><br>
> ================<br>
> Comment at: include/clang/Basic/FileManager.h:122<br>
> @@ -121,2 +121,3 @@<br>
> class FileManager : public RefCountedBase<FileManager> {<br>
> +  IntrusiveRefCntPtr<AbstractFileSystem> FS;<br>
>   FileSystemOptions FileSystemOpts;<br>
> ----------------<br>
> 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.<br>
<br>
<br>
</div>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.<br>
</blockquote><div><br></div><div>Just to follow up:</div><div>I found one more argument against making this ref-counted:</div><div>The constructor of FileManager that uses the default "real" file system is now actively thread hostile (you cannot create a FileManager per thread without locking). I think that's rather unexpected.</div>
<div><br></div><div>Cheers,</div><div>/Manuel</div><div><br></div></div></div></div>