FileManager constructs a VFS in its constructor if it isn't passed one,
and there's no way to reset it. Make that contract clear by returning a
reference from its accessor.
Details
Diff Detail
Event Timeline
Hi Duncan, thanks for working on better interfaces in clang!
I am just wondering - is it safe to have the lifetime of a single object on heap managed by two different IntrusiveRefCntPtr instances?
clang/lib/Frontend/ASTUnit.cpp | ||
---|---|---|
1693 | Is this safe? | |
1800 | Is this safe? | |
2236–2237 | Is this safe? | |
clang/lib/Frontend/CompilerInstance.cpp | ||
299 | Is this safe? | |
clang/lib/Tooling/Tooling.cpp | ||
304 | The Driver constructor takes IntrusiveRefCntPtr< llvm::vfs::FileSystem > as an argument. Is this safe? https://clang.llvm.org/doxygen/classclang_1_1driver_1_1Driver.html#a1930cae44e647c1983d11d6a61ce14ed |
Yes, it's safe. The reference count is "intrusive", meaning it's stored in the object itself (via inheritance from RefCountedBase). As a result, all the instances of IntrusiveRefCntPtr that reference at the same object will implicitly share their count.
Is this safe?