<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 13, 2014 at 12:49 AM, 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="im"><br>
On Feb 12, 2014, at 3:45 PM, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
<br>
>> I have no idea what you mean by “clang process”. You don’t actually mean the whole process itself, because FS isn’t thread-safe and therefore isn’t some kind of global singleton. Plus, different invocations of the compiler may have different FS, so making this a global singleton is completely wrong . Any thread-specific “singleton” would be wrong for the same reasons.<br>

>><br>
>> I guess we could toss the responsibility for managing the FS instance up to “the client”, but which clients are those? Some clients will want to pre-populate and widely share a FS, while others just want CompilerInvocation to create the FS if the command-line arguments passed through to it require the FS. We want to support the former without complicating the latter. IntrusiveRefCntPtr makes that easy to do with completely acceptable overhead.<br>

><br>
> OK, if that is the use case, then I agree with IntrusiveRefCntPtr, but<br>
> that means I misunderstood how the FS is to be used.<br>
><br>
> My understanding was that the FS would always be shared, so that it<br>
> could be constructed once as close to main as possible. Would you mind<br>
> explaining when we would want two different FS alive in the same<br>
> process (or thread)?<br>
<br>
</div>The FS can be created by passing a not-yet-implemented “-vfs <file>” argument to Clang, which will allocate and populate a virtual file system based on the input file. If I were writing a Clang compiler server, I wouldn’t want to share the virtual file systems of distinct Clang invocations.<br>
</blockquote><div><br></div><div>Just +1'ing this comment, as it's a really important use case for us :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im"><br>
> Now I realize that maybe I just missed that this is to be exposed via<br>
> libclang and we can assume nothing about how the clients want to use<br>
> FS?<br>
<br>
<br>
</div>VFS file creation routines will be exposed by libclang. That’s one of the clients… an IDE that has edited files in memory that it doesn’t want to flush to disk before invoking Clang.<br>
<br>
        - Doug<br>
<br>
</blockquote></div><br></div></div>