resistor created this revision.
resistor added reviewers: chandlerc, bkramer, klimek.
resistor added a subscriber: cfe-commits.
resistor set the repository for this revision to rL LLVM.
Herald added a subscriber: klimek.
Managing it with IntrusiveRefCntPtr caused the virtual destructor not to be
called properly.
Repository:
rL LLVM
http://reviews.llvm.org/D16041
Files:
include/clang/Basic/FileManager.h
include/clang/Basic/VirtualFileSystem.h
include/clang/Driver/Driver.h
include/clang/Frontend/CompilerInstance.h
include/clang/Frontend/CompilerInvocation.h
include/clang/Tooling/Tooling.h
lib/Basic/FileManager.cpp
lib/Basic/VirtualFileSystem.cpp
lib/Driver/Driver.cpp
lib/Format/Format.cpp
lib/Frontend/ASTUnit.cpp
lib/Frontend/CompilerInstance.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/FrontendAction.cpp
lib/Index/SimpleFormatContext.h
lib/StaticAnalyzer/Frontend/ModelInjector.cpp
lib/Tooling/Core/Replacement.cpp
lib/Tooling/Tooling.cpp
tools/clang-format/ClangFormat.cpp
unittests/Basic/VirtualFileSystemTest.cpp
unittests/Driver/ToolChainTest.cpp
unittests/Lex/PPCallbacksTest.cpp
unittests/Tooling/RewriterTestContext.h
unittests/Tooling/ToolingTest.cpp
Index: unittests/Tooling/ToolingTest.cpp
===================================================================
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -149,9 +149,9 @@
}
TEST(ToolInvocation, TestMapVirtualFile) {
- llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFileSystem(
+ std::shared_ptr<vfs::OverlayFileSystem> OverlayFileSystem(
new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
@@ -175,9 +175,9 @@
// mapped module.map is found on the include path. In the future, expand this
// test to run a full modules enabled compilation, so we make sure we can
// rerun modules compilations with a virtual file system.
- llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFileSystem(
+ std::shared_ptr<vfs::OverlayFileSystem> OverlayFileSystem(
new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
Index: unittests/Tooling/RewriterTestContext.h
===================================================================
--- unittests/Tooling/RewriterTestContext.h
+++ unittests/Tooling/RewriterTestContext.h
@@ -114,8 +114,8 @@
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
DiagnosticsEngine Diagnostics;
TextDiagnosticPrinter DiagnosticPrinter;
- IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem;
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFileSystem;
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem;
+ std::shared_ptr<vfs::OverlayFileSystem> OverlayFileSystem;
FileManager Files;
SourceManager Sources;
LangOptions Options;
Index: unittests/Lex/PPCallbacksTest.cpp
===================================================================
--- unittests/Lex/PPCallbacksTest.cpp
+++ unittests/Lex/PPCallbacksTest.cpp
@@ -119,7 +119,7 @@
Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
}
- IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem;
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem;
FileManager FileMgr;
IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
Index: unittests/Driver/ToolChainTest.cpp
===================================================================
--- unittests/Driver/ToolChainTest.cpp
+++ unittests/Driver/ToolChainTest.cpp
@@ -31,7 +31,7 @@
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
- IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
Driver TheDriver("/bin/clang", "arm-linux-gnueabihf", Diags,
InMemoryFileSystem);
@@ -84,7 +84,7 @@
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
- IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
Driver TheDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
InMemoryFileSystem);
Index: unittests/Basic/VirtualFileSystemTest.cpp
===================================================================
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -134,7 +134,7 @@
} // end anonymous namespace
TEST(VirtualFileSystemTest, StatusQueries) {
- IntrusiveRefCntPtr<DummyFileSystem> D(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> D(new DummyFileSystem());
ErrorOr<vfs::Status> Status((std::error_code()));
D->addRegularFile("/foo");
@@ -174,11 +174,11 @@
}
TEST(VirtualFileSystemTest, BaseOnlyOverlay) {
- IntrusiveRefCntPtr<DummyFileSystem> D(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> D(new DummyFileSystem());
ErrorOr<vfs::Status> Status((std::error_code()));
EXPECT_FALSE(Status = D->status("/foo"));
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(new vfs::OverlayFileSystem(D));
+ std::shared_ptr<vfs::OverlayFileSystem> O(new vfs::OverlayFileSystem(D));
EXPECT_FALSE(Status = O->status("/foo"));
D->addRegularFile("/foo");
@@ -192,10 +192,10 @@
}
TEST(VirtualFileSystemTest, OverlayFiles) {
- IntrusiveRefCntPtr<DummyFileSystem> Base(new DummyFileSystem());
- IntrusiveRefCntPtr<DummyFileSystem> Middle(new DummyFileSystem());
- IntrusiveRefCntPtr<DummyFileSystem> Top(new DummyFileSystem());
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
+ std::shared_ptr<DummyFileSystem> Base(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Middle(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Top(new DummyFileSystem());
+ std::shared_ptr<vfs::OverlayFileSystem> O(
new vfs::OverlayFileSystem(Base));
O->pushOverlay(Middle);
O->pushOverlay(Top);
@@ -231,9 +231,9 @@
}
TEST(VirtualFileSystemTest, OverlayDirsNonMerged) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
- IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Upper(new DummyFileSystem());
+ std::shared_ptr<vfs::OverlayFileSystem> O(
new vfs::OverlayFileSystem(Lower));
O->pushOverlay(Upper);
@@ -256,9 +256,9 @@
TEST(VirtualFileSystemTest, MergedDirPermissions) {
// merged directories get the permissions of the upper dir
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
- IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Upper(new DummyFileSystem());
+ std::shared_ptr<vfs::OverlayFileSystem> O(
new vfs::OverlayFileSystem(Lower));
O->pushOverlay(Upper);
@@ -305,7 +305,7 @@
TEST(VirtualFileSystemTest, BasicRealFSIteration) {
ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true);
- IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getRealFileSystem();
+ std::shared_ptr<vfs::FileSystem> FS = vfs::getRealFileSystem();
std::error_code EC;
vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC);
@@ -332,7 +332,7 @@
TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) {
ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true);
- IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getRealFileSystem();
+ std::shared_ptr<vfs::FileSystem> FS = vfs::getRealFileSystem();
std::error_code EC;
auto I = vfs::recursive_directory_iterator(*FS, Twine(TestDirectory), EC);
@@ -384,9 +384,9 @@
}
TEST(VirtualFileSystemTest, OverlayIteration) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
- IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Upper(new DummyFileSystem());
+ std::shared_ptr<vfs::OverlayFileSystem> O(
new vfs::OverlayFileSystem(Lower));
O->pushOverlay(Upper);
@@ -408,10 +408,10 @@
}
TEST(VirtualFileSystemTest, OverlayRecursiveIteration) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
- IntrusiveRefCntPtr<DummyFileSystem> Middle(new DummyFileSystem());
- IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Middle(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Upper(new DummyFileSystem());
+ std::shared_ptr<vfs::OverlayFileSystem> O(
new vfs::OverlayFileSystem(Lower));
O->pushOverlay(Middle);
O->pushOverlay(Upper);
@@ -450,10 +450,10 @@
}
TEST(VirtualFileSystemTest, ThreeLevelIteration) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
- IntrusiveRefCntPtr<DummyFileSystem> Middle(new DummyFileSystem());
- IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Middle(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Upper(new DummyFileSystem());
+ std::shared_ptr<vfs::OverlayFileSystem> O(
new vfs::OverlayFileSystem(Lower));
O->pushOverlay(Middle);
O->pushOverlay(Upper);
@@ -470,10 +470,10 @@
}
TEST(VirtualFileSystemTest, HiddenInIteration) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
- IntrusiveRefCntPtr<DummyFileSystem> Middle(new DummyFileSystem());
- IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Middle(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Upper(new DummyFileSystem());
+ std::shared_ptr<vfs::OverlayFileSystem> O(
new vfs::OverlayFileSystem(Lower));
O->pushOverlay(Middle);
O->pushOverlay(Upper);
@@ -659,25 +659,26 @@
++Test->NumDiagnostics;
}
- IntrusiveRefCntPtr<vfs::FileSystem>
+ std::shared_ptr<vfs::FileSystem>
getFromYAMLRawString(StringRef Content,
- IntrusiveRefCntPtr<vfs::FileSystem> ExternalFS) {
+ std::shared_ptr<vfs::FileSystem> ExternalFS) {
std::unique_ptr<MemoryBuffer> Buffer = MemoryBuffer::getMemBuffer(Content);
return getVFSFromYAML(std::move(Buffer), CountingDiagHandler, this,
ExternalFS);
}
- IntrusiveRefCntPtr<vfs::FileSystem> getFromYAMLString(
+ std::shared_ptr<vfs::FileSystem> getFromYAMLString(
StringRef Content,
- IntrusiveRefCntPtr<vfs::FileSystem> ExternalFS = new DummyFileSystem()) {
+ std::shared_ptr<vfs::FileSystem> ExternalFS =
+ std::make_shared<DummyFileSystem>()) {
std::string VersionPlusContent("{\n 'version':0,\n");
VersionPlusContent += Content.slice(Content.find('{') + 1, StringRef::npos);
return getFromYAMLRawString(VersionPlusContent, ExternalFS);
}
};
TEST_F(VFSFromYAMLTest, BasicVFSFromYAML) {
- IntrusiveRefCntPtr<vfs::FileSystem> FS;
+ std::shared_ptr<vfs::FileSystem> FS;
FS = getFromYAMLString("");
EXPECT_EQ(nullptr, FS.get());
FS = getFromYAMLString("[]");
@@ -688,9 +689,9 @@
}
TEST_F(VFSFromYAMLTest, MappedFiles) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
Lower->addRegularFile("//root/foo/bar/a");
- IntrusiveRefCntPtr<vfs::FileSystem> FS =
+ std::shared_ptr<vfs::FileSystem> FS =
getFromYAMLString("{ 'roots': [\n"
"{\n"
" 'type': 'directory',\n"
@@ -712,7 +713,7 @@
Lower);
ASSERT_TRUE(FS.get() != nullptr);
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
+ std::shared_ptr<vfs::OverlayFileSystem> O(
new vfs::OverlayFileSystem(Lower));
O->pushOverlay(FS);
@@ -748,9 +749,9 @@
}
TEST_F(VFSFromYAMLTest, CaseInsensitive) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
Lower->addRegularFile("//root/foo/bar/a");
- IntrusiveRefCntPtr<vfs::FileSystem> FS =
+ std::shared_ptr<vfs::FileSystem> FS =
getFromYAMLString("{ 'case-sensitive': 'false',\n"
" 'roots': [\n"
"{\n"
@@ -766,7 +767,7 @@
Lower);
ASSERT_TRUE(FS.get() != nullptr);
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
+ std::shared_ptr<vfs::OverlayFileSystem> O(
new vfs::OverlayFileSystem(Lower));
O->pushOverlay(FS);
@@ -784,9 +785,9 @@
}
TEST_F(VFSFromYAMLTest, CaseSensitive) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
Lower->addRegularFile("//root/foo/bar/a");
- IntrusiveRefCntPtr<vfs::FileSystem> FS =
+ std::shared_ptr<vfs::FileSystem> FS =
getFromYAMLString("{ 'case-sensitive': 'true',\n"
" 'roots': [\n"
"{\n"
@@ -802,7 +803,7 @@
Lower);
ASSERT_TRUE(FS.get() != nullptr);
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
+ std::shared_ptr<vfs::OverlayFileSystem> O(
new vfs::OverlayFileSystem(Lower));
O->pushOverlay(FS);
@@ -816,10 +817,10 @@
}
TEST_F(VFSFromYAMLTest, IllegalVFSFile) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
// invalid YAML at top-level
- IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString("{]", Lower);
+ std::shared_ptr<vfs::FileSystem> FS = getFromYAMLString("{]", Lower);
EXPECT_EQ(nullptr, FS.get());
// invalid YAML in roots
FS = getFromYAMLString("{ 'roots':[}", Lower);
@@ -907,10 +908,10 @@
}
TEST_F(VFSFromYAMLTest, UseExternalName) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
Lower->addRegularFile("//root/external/file");
- IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString(
+ std::shared_ptr<vfs::FileSystem> FS = getFromYAMLString(
"{ 'roots': [\n"
" { 'type': 'file', 'name': '//root/A',\n"
" 'external-contents': '//root/external/file'\n"
@@ -958,11 +959,11 @@
}
TEST_F(VFSFromYAMLTest, MultiComponentPath) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
Lower->addRegularFile("//root/other");
// file in roots
- IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString(
+ std::shared_ptr<vfs::FileSystem> FS = getFromYAMLString(
"{ 'roots': [\n"
" { 'type': 'file', 'name': '//root/path/to/file',\n"
" 'external-contents': '//root/other' }]\n"
@@ -1001,11 +1002,11 @@
}
TEST_F(VFSFromYAMLTest, TrailingSlashes) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
Lower->addRegularFile("//root/other");
// file in roots
- IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString(
+ std::shared_ptr<vfs::FileSystem> FS = getFromYAMLString(
"{ 'roots': [\n"
" { 'type': 'directory', 'name': '//root/path/to////',\n"
" 'contents': [ { 'type': 'file', 'name': 'file',\n"
@@ -1019,14 +1020,14 @@
}
TEST_F(VFSFromYAMLTest, DirectoryIteration) {
- IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
+ std::shared_ptr<DummyFileSystem> Lower(new DummyFileSystem());
Lower->addDirectory("//root/");
Lower->addDirectory("//root/foo");
Lower->addDirectory("//root/foo/bar");
Lower->addRegularFile("//root/foo/bar/a");
Lower->addRegularFile("//root/foo/bar/b");
Lower->addRegularFile("//root/file3");
- IntrusiveRefCntPtr<vfs::FileSystem> FS =
+ std::shared_ptr<vfs::FileSystem> FS =
getFromYAMLString("{ 'use-external-names': false,\n"
" 'roots': [\n"
"{\n"
@@ -1049,7 +1050,7 @@
Lower);
ASSERT_TRUE(FS.get() != nullptr);
- IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
+ std::shared_ptr<vfs::OverlayFileSystem> O(
new vfs::OverlayFileSystem(Lower));
O->pushOverlay(FS);
Index: tools/clang-format/ClangFormat.cpp
===================================================================
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -129,7 +129,7 @@
static bool fillRanges(MemoryBuffer *Code,
std::vector<tooling::Range> &Ranges) {
- IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
DiagnosticsEngine Diagnostics(
@@ -278,7 +278,7 @@
outputReplacementsXML(Replaces);
outs() << "</replacements>\n";
} else {
- IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
DiagnosticsEngine Diagnostics(
Index: lib/Tooling/Tooling.cpp
===================================================================
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -48,7 +48,7 @@
/// \brief Builds a clang driver initialized for running clang tools.
static clang::driver::Driver *newDriver(
clang::DiagnosticsEngine *Diagnostics, const char *BinaryName,
- IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
+ std::shared_ptr<vfs::FileSystem> VFS) {
clang::driver::Driver *CompilerDriver = new clang::driver::Driver(
BinaryName, llvm::sys::getDefaultTargetTriple(), *Diagnostics, VFS);
CompilerDriver->setTitle("clang_based_tool");
@@ -125,9 +125,9 @@
SmallString<16> FileNameStorage;
StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
- llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFileSystem(
+ std::shared_ptr<vfs::OverlayFileSystem> OverlayFileSystem(
new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
@@ -482,9 +482,9 @@
std::vector<std::unique_ptr<ASTUnit>> ASTs;
ASTBuilderAction Action(ASTs);
- llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFileSystem(
+ std::shared_ptr<vfs::OverlayFileSystem> OverlayFileSystem(
new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
Index: lib/Tooling/Core/Replacement.cpp
===================================================================
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -255,7 +255,7 @@
}
std::string applyAllReplacements(StringRef Code, const Replacements &Replaces) {
- IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
DiagnosticsEngine Diagnostics(
Index: lib/StaticAnalyzer/Frontend/ModelInjector.cpp
===================================================================
--- lib/StaticAnalyzer/Frontend/ModelInjector.cpp
+++ lib/StaticAnalyzer/Frontend/ModelInjector.cpp
@@ -84,7 +84,7 @@
Instance.getDiagnostics().setSourceManager(&SM);
- Instance.setVirtualFileSystem(&CI.getVirtualFileSystem());
+ Instance.setVirtualFileSystem(CI.getVirtualFileSystem());
// The instance wants to take ownership, however DisableFree frontend option
// is set to true to avoid double free issues
Index: lib/Index/SimpleFormatContext.h
===================================================================
--- lib/Index/SimpleFormatContext.h
+++ lib/Index/SimpleFormatContext.h
@@ -63,7 +63,7 @@
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
- IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem;
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem;
FileManager Files;
SourceManager Sources;
Rewriter Rewrite;
Index: lib/Frontend/FrontendAction.cpp
===================================================================
--- lib/Frontend/FrontendAction.cpp
+++ lib/Frontend/FrontendAction.cpp
@@ -223,7 +223,7 @@
}
if (!CI.hasVirtualFileSystem()) {
- if (IntrusiveRefCntPtr<vfs::FileSystem> VFS =
+ if (std::shared_ptr<vfs::FileSystem> VFS =
createVFSFromCompilerInvocation(CI.getInvocation(),
CI.getDiagnostics()))
CI.setVirtualFileSystem(VFS);
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2289,28 +2289,28 @@
GraveYard[Idx] = Ptr;
}
-IntrusiveRefCntPtr<vfs::FileSystem>
+std::shared_ptr<vfs::FileSystem>
createVFSFromCompilerInvocation(const CompilerInvocation &CI,
DiagnosticsEngine &Diags) {
if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty())
return vfs::getRealFileSystem();
- IntrusiveRefCntPtr<vfs::OverlayFileSystem>
+ std::shared_ptr<vfs::OverlayFileSystem>
Overlay(new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
// earlier vfs files are on the bottom
for (const std::string &File : CI.getHeaderSearchOpts().VFSOverlayFiles) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
llvm::MemoryBuffer::getFile(File);
if (!Buffer) {
Diags.Report(diag::err_missing_vfs_overlay_file) << File;
- return IntrusiveRefCntPtr<vfs::FileSystem>();
+ return std::shared_ptr<vfs::FileSystem>();
}
- IntrusiveRefCntPtr<vfs::FileSystem> FS =
+ std::shared_ptr<vfs::FileSystem> FS =
vfs::getVFSFromYAML(std::move(Buffer.get()), /*DiagHandler*/ nullptr);
if (!FS.get()) {
Diags.Report(diag::err_invalid_vfs_overlay) << File;
- return IntrusiveRefCntPtr<vfs::FileSystem>();
+ return std::shared_ptr<vfs::FileSystem>();
}
Overlay->pushOverlay(FS);
}
Index: lib/Frontend/CompilerInstance.cpp
===================================================================
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -953,7 +953,7 @@
ImportingInstance.getDiagnosticClient()),
/*ShouldOwnClient=*/true);
- Instance.setVirtualFileSystem(&ImportingInstance.getVirtualFileSystem());
+ Instance.setVirtualFileSystem(ImportingInstance.getVirtualFileSystem());
// Note that this module is part of the module build stack, so that we
// can detect cycles in the module graph.
Index: lib/Frontend/ASTUnit.cpp
===================================================================
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -670,7 +670,7 @@
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->CaptureDiagnostics = CaptureDiagnostics;
AST->Diagnostics = Diags;
- IntrusiveRefCntPtr<vfs::FileSystem> VFS = vfs::getRealFileSystem();
+ std::shared_ptr<vfs::FileSystem> VFS = vfs::getRealFileSystem();
AST->FileMgr = new FileManager(FileSystemOpts, VFS);
AST->UserFilesAreVolatile = UserFilesAreVolatile;
AST->SourceMgr = new SourceManager(AST->getDiagnostics(),
@@ -1550,7 +1550,7 @@
TopLevelDeclsInPreamble.clear();
PreambleDiagnostics.clear();
- IntrusiveRefCntPtr<vfs::FileSystem> VFS =
+ std::shared_ptr<vfs::FileSystem> VFS =
createVFSFromCompilerInvocation(Clang->getInvocation(), getDiagnostics());
if (!VFS)
return nullptr;
@@ -1708,7 +1708,7 @@
AST->Diagnostics = Diags;
AST->Invocation = CI;
AST->FileSystemOpts = CI->getFileSystemOpts();
- IntrusiveRefCntPtr<vfs::FileSystem> VFS =
+ std::shared_ptr<vfs::FileSystem> VFS =
createVFSFromCompilerInvocation(*CI, *Diags);
if (!VFS)
return nullptr;
@@ -1979,7 +1979,7 @@
ConfigureDiags(Diags, *AST, CaptureDiagnostics);
AST->Diagnostics = Diags;
AST->FileSystemOpts = CI->getFileSystemOpts();
- IntrusiveRefCntPtr<vfs::FileSystem> VFS =
+ std::shared_ptr<vfs::FileSystem> VFS =
createVFSFromCompilerInvocation(*CI, *Diags);
if (!VFS)
return nullptr;
Index: lib/Format/Format.cpp
===================================================================
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1897,7 +1897,7 @@
if (Style.DisableFormat)
return tooling::Replacements();
- IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
DiagnosticsEngine Diagnostics(
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -48,7 +48,7 @@
Driver::Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
DiagnosticsEngine &Diags,
- IntrusiveRefCntPtr<vfs::FileSystem> VFS)
+ std::shared_ptr<vfs::FileSystem> VFS)
: Opts(createDriverOptTable()), Diags(Diags), VFS(VFS), Mode(GCCMode),
SaveTemps(SaveTempsNone), LTOMode(LTOK_None),
ClangExecutable(ClangExecutable),
Index: lib/Basic/VirtualFileSystem.cpp
===================================================================
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -225,8 +225,8 @@
return std::error_code();
}
-IntrusiveRefCntPtr<FileSystem> vfs::getRealFileSystem() {
- static IntrusiveRefCntPtr<FileSystem> FS = new RealFileSystem();
+std::shared_ptr<FileSystem> vfs::getRealFileSystem() {
+ static std::shared_ptr<FileSystem> FS(new RealFileSystem());
return FS;
}
@@ -270,11 +270,11 @@
//===-----------------------------------------------------------------------===/
// OverlayFileSystem implementation
//===-----------------------------------------------------------------------===/
-OverlayFileSystem::OverlayFileSystem(IntrusiveRefCntPtr<FileSystem> BaseFS) {
+OverlayFileSystem::OverlayFileSystem(std::shared_ptr<FileSystem> BaseFS) {
FSList.push_back(BaseFS);
}
-void OverlayFileSystem::pushOverlay(IntrusiveRefCntPtr<FileSystem> FS) {
+void OverlayFileSystem::pushOverlay(std::shared_ptr<FileSystem> FS) {
FSList.push_back(FS);
// Synchronize added file systems by duplicating the working directory from
// the first one in the list.
@@ -814,7 +814,7 @@
/// The root(s) of the virtual file system.
std::vector<std::unique_ptr<Entry>> Roots;
/// \brief The file system to use for external references.
- IntrusiveRefCntPtr<FileSystem> ExternalFS;
+ std::shared_ptr<FileSystem> ExternalFS;
/// @name Configuration
/// @{
@@ -832,7 +832,7 @@
friend class RedirectingFileSystemParser;
private:
- RedirectingFileSystem(IntrusiveRefCntPtr<FileSystem> ExternalFS)
+ RedirectingFileSystem(std::shared_ptr<FileSystem> ExternalFS)
: ExternalFS(ExternalFS), CaseSensitive(true), UseExternalNames(true) {}
/// \brief Looks up \p Path in \c Roots.
@@ -852,7 +852,7 @@
static RedirectingFileSystem *
create(std::unique_ptr<MemoryBuffer> Buffer,
SourceMgr::DiagHandlerTy DiagHandler, void *DiagContext,
- IntrusiveRefCntPtr<FileSystem> ExternalFS);
+ std::shared_ptr<FileSystem> ExternalFS);
ErrorOr<Status> status(const Twine &Path) override;
ErrorOr<std::unique_ptr<File>> openFileForRead(const Twine &Path) override;
@@ -1207,7 +1207,7 @@
RedirectingFileSystem *RedirectingFileSystem::create(
std::unique_ptr<MemoryBuffer> Buffer, SourceMgr::DiagHandlerTy DiagHandler,
- void *DiagContext, IntrusiveRefCntPtr<FileSystem> ExternalFS) {
+ void *DiagContext, std::shared_ptr<FileSystem> ExternalFS) {
SourceMgr SM;
yaml::Stream Stream(Buffer->getMemBufferRef(), SM);
@@ -1360,12 +1360,14 @@
llvm::make_unique<FileWithFixedStatus>(std::move(*Result), S));
}
-IntrusiveRefCntPtr<FileSystem>
+std::shared_ptr<FileSystem>
vfs::getVFSFromYAML(std::unique_ptr<MemoryBuffer> Buffer,
SourceMgr::DiagHandlerTy DiagHandler, void *DiagContext,
- IntrusiveRefCntPtr<FileSystem> ExternalFS) {
- return RedirectingFileSystem::create(std::move(Buffer), DiagHandler,
- DiagContext, ExternalFS);
+ std::shared_ptr<FileSystem> ExternalFS) {
+ std::shared_ptr<FileSystem> FS(
+ RedirectingFileSystem::create(std::move(Buffer), DiagHandler,
+ DiagContext, ExternalFS));
+ return FS;
}
UniqueID vfs::getNextVirtualUniqueID() {
Index: lib/Basic/FileManager.cpp
===================================================================
--- lib/Basic/FileManager.cpp
+++ lib/Basic/FileManager.cpp
@@ -47,7 +47,7 @@
//===----------------------------------------------------------------------===//
FileManager::FileManager(const FileSystemOptions &FSO,
- IntrusiveRefCntPtr<vfs::FileSystem> FS)
+ std::shared_ptr<vfs::FileSystem> FS)
: FS(FS), FileSystemOpts(FSO),
SeenDirEntries(64), SeenFileEntries(64), NextFileUID(0) {
NumDirLookups = NumFileLookups = 0;
Index: include/clang/Tooling/Tooling.h
===================================================================
--- include/clang/Tooling/Tooling.h
+++ include/clang/Tooling/Tooling.h
@@ -332,8 +332,8 @@
std::vector<std::string> SourcePaths;
std::shared_ptr<PCHContainerOperations> PCHContainerOps;
- llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFileSystem;
- llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem;
+ std::shared_ptr<vfs::OverlayFileSystem> OverlayFileSystem;
+ std::shared_ptr<vfs::InMemoryFileSystem> InMemoryFileSystem;
llvm::IntrusiveRefCntPtr<FileManager> Files;
// Contains a list of pairs (<file name>, <file content>).
std::vector< std::pair<StringRef, StringRef> > MappedFileContents;
Index: include/clang/Frontend/CompilerInvocation.h
===================================================================
--- include/clang/Frontend/CompilerInvocation.h
+++ include/clang/Frontend/CompilerInvocation.h
@@ -210,7 +210,7 @@
class FileSystem;
}
-IntrusiveRefCntPtr<vfs::FileSystem>
+std::shared_ptr<vfs::FileSystem>
createVFSFromCompilerInvocation(const CompilerInvocation &CI,
DiagnosticsEngine &Diags);
Index: include/clang/Frontend/CompilerInstance.h
===================================================================
--- include/clang/Frontend/CompilerInstance.h
+++ include/clang/Frontend/CompilerInstance.h
@@ -82,7 +82,7 @@
IntrusiveRefCntPtr<TargetInfo> AuxTarget;
/// The virtual file system.
- IntrusiveRefCntPtr<vfs::FileSystem> VirtualFileSystem;
+ std::shared_ptr<vfs::FileSystem> VirtualFileSystem;
/// The file manager.
IntrusiveRefCntPtr<FileManager> FileMgr;
@@ -369,17 +369,17 @@
bool hasVirtualFileSystem() const { return VirtualFileSystem != nullptr; }
- vfs::FileSystem &getVirtualFileSystem() const {
+ std::shared_ptr<vfs::FileSystem> getVirtualFileSystem() const {
assert(hasVirtualFileSystem() &&
"Compiler instance has no virtual file system");
- return *VirtualFileSystem;
+ return VirtualFileSystem;
}
/// \brief Replace the current virtual file system.
///
/// \note Most clients should use setFileManager, which will implicitly reset
/// the virtual file system to the one contained in the file manager.
- void setVirtualFileSystem(IntrusiveRefCntPtr<vfs::FileSystem> FS) {
+ void setVirtualFileSystem(std::shared_ptr<vfs::FileSystem> FS) {
VirtualFileSystem = FS;
}
Index: include/clang/Driver/Driver.h
===================================================================
--- include/clang/Driver/Driver.h
+++ include/clang/Driver/Driver.h
@@ -67,7 +67,7 @@
DiagnosticsEngine &Diags;
- IntrusiveRefCntPtr<vfs::FileSystem> VFS;
+ std::shared_ptr<vfs::FileSystem> VFS;
enum DriverMode {
GCCMode,
@@ -221,7 +221,7 @@
public:
Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
DiagnosticsEngine &Diags,
- IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
+ std::shared_ptr<vfs::FileSystem> VFS = nullptr);
~Driver();
/// @name Accessors
Index: include/clang/Basic/VirtualFileSystem.h
===================================================================
--- include/clang/Basic/VirtualFileSystem.h
+++ include/clang/Basic/VirtualFileSystem.h
@@ -14,7 +14,6 @@
#define LLVM_CLANG_BASIC_VIRTUALFILESYSTEM_H
#include "clang/Basic/LLVM.h"
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
@@ -179,7 +178,7 @@
};
/// \brief The virtual file system interface.
-class FileSystem : public llvm::ThreadSafeRefCountedBase<FileSystem> {
+class FileSystem {
public:
virtual ~FileSystem();
@@ -225,7 +224,7 @@
/// \brief Gets an \p vfs::FileSystem for the 'real' file system, as seen by
/// the operating system.
-IntrusiveRefCntPtr<FileSystem> getRealFileSystem();
+std::shared_ptr<FileSystem> getRealFileSystem();
/// \brief A file system that allows overlaying one \p AbstractFileSystem on top
/// of another.
@@ -238,15 +237,15 @@
/// that exists in more than one file system, the file in the top-most file
/// system overrides the other(s).
class OverlayFileSystem : public FileSystem {
- typedef SmallVector<IntrusiveRefCntPtr<FileSystem>, 1> FileSystemList;
+ typedef SmallVector<std::shared_ptr<FileSystem>, 1> FileSystemList;
/// \brief The stack of file systems, implemented as a list in order of
/// their addition.
FileSystemList FSList;
public:
- OverlayFileSystem(IntrusiveRefCntPtr<FileSystem> Base);
+ OverlayFileSystem(std::shared_ptr<FileSystem> Base);
/// \brief Pushes a file system on top of the stack.
- void pushOverlay(IntrusiveRefCntPtr<FileSystem> FS);
+ void pushOverlay(std::shared_ptr<FileSystem> FS);
llvm::ErrorOr<Status> status(const Twine &Path) override;
llvm::ErrorOr<std::unique_ptr<File>>
@@ -307,11 +306,11 @@
/// \brief Gets a \p FileSystem for a virtual file system described in YAML
/// format.
-IntrusiveRefCntPtr<FileSystem>
+std::shared_ptr<FileSystem>
getVFSFromYAML(std::unique_ptr<llvm::MemoryBuffer> Buffer,
llvm::SourceMgr::DiagHandlerTy DiagHandler,
void *DiagContext = nullptr,
- IntrusiveRefCntPtr<FileSystem> ExternalFS = getRealFileSystem());
+ std::shared_ptr<FileSystem> ExternalFS = getRealFileSystem());
struct YAMLVFSEntry {
template <typename T1, typename T2> YAMLVFSEntry(T1 &&VPath, T2 &&RPath)
Index: include/clang/Basic/FileManager.h
===================================================================
--- include/clang/Basic/FileManager.h
+++ include/clang/Basic/FileManager.h
@@ -19,7 +19,6 @@
#include "clang/Basic/LLVM.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
@@ -113,7 +112,7 @@
/// as a single file.
///
class FileManager : public RefCountedBase<FileManager> {
- IntrusiveRefCntPtr<vfs::FileSystem> FS;
+ std::shared_ptr<vfs::FileSystem> FS;
FileSystemOptions FileSystemOpts;
/// \brief Cache for existing real directories.
@@ -172,7 +171,7 @@
public:
FileManager(const FileSystemOptions &FileSystemOpts,
- IntrusiveRefCntPtr<vfs::FileSystem> FS = nullptr);
+ std::shared_ptr<vfs::FileSystem> FS = nullptr);
~FileManager();
/// \brief Installs the provided FileSystemStatCache object within
@@ -221,7 +220,7 @@
FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; }
const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; }
- IntrusiveRefCntPtr<vfs::FileSystem> getVirtualFileSystem() const {
+ std::shared_ptr<vfs::FileSystem> getVirtualFileSystem() const {
return FS;
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits