[PATCH] D92888: ADT: Allow IntrusiveRefCntPtr construction from std::unique_ptr, NFC
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 8 17:33:45 PST 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5207f19d103d: ADT: Allow IntrusiveRefCntPtr construction from std::unique_ptr, NFC (authored by dexonsmith).
Changed prior to commit:
https://reviews.llvm.org/D92888?vs=310358&id=310390#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92888/new/
https://reviews.llvm.org/D92888
Files:
clang-tools-extra/clangd/support/ThreadsafeFS.cpp
clang/lib/Tooling/AllTUsExecution.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp
Index: llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp
===================================================================
--- llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp
+++ llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp
@@ -42,6 +42,17 @@
EXPECT_EQ(0, NumInstances);
}
+TYPED_TEST(IntrusiveRefCntPtrTest, InteropsWithUniquePtr) {
+ EXPECT_EQ(0, NumInstances);
+ {
+ auto S1 = std::make_unique<TypeParam>();
+ IntrusiveRefCntPtr<TypeParam> R1 = std::move(S1);
+ EXPECT_EQ(1, NumInstances);
+ EXPECT_EQ(S1, nullptr);
+ }
+ EXPECT_EQ(0, NumInstances);
+}
+
struct InterceptRefCounted : public RefCountedBase<InterceptRefCounted> {
InterceptRefCounted(bool *Released, bool *Retained)
: Released(Released), Retained(Retained) {}
Index: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
===================================================================
--- llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
+++ llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
@@ -58,6 +58,7 @@
#include <atomic>
#include <cassert>
#include <cstddef>
+#include <memory>
namespace llvm {
@@ -175,6 +176,11 @@
S.Obj = nullptr;
}
+ template <class X>
+ IntrusiveRefCntPtr(std::unique_ptr<X> S) : Obj(S.release()) {
+ retain();
+ }
+
template <class X>
IntrusiveRefCntPtr(const IntrusiveRefCntPtr<X> &S) : Obj(S.get()) {
retain();
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -154,7 +154,7 @@
: Format(Service.getFormat()) {
DiagOpts = new DiagnosticOptions();
PCHContainerOps = std::make_shared<PCHContainerOperations>();
- RealFS = llvm::vfs::createPhysicalFileSystem().release();
+ RealFS = llvm::vfs::createPhysicalFileSystem();
if (Service.canSkipExcludedPPRanges())
PPSkipMappings =
std::make_unique<ExcludedPreprocessorDirectiveSkipMapping>();
Index: clang/lib/Tooling/AllTUsExecution.cpp
===================================================================
--- clang/lib/Tooling/AllTUsExecution.cpp
+++ clang/lib/Tooling/AllTUsExecution.cpp
@@ -124,7 +124,7 @@
// Each thread gets an indepent copy of a VFS to allow different
// concurrent working directories.
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
- llvm::vfs::createPhysicalFileSystem().release();
+ llvm::vfs::createPhysicalFileSystem();
ClangTool Tool(Compilations, {Path},
std::make_shared<PCHContainerOperations>(), FS);
Tool.appendArgumentsAdjuster(Action.second);
Index: clang-tools-extra/clangd/support/ThreadsafeFS.cpp
===================================================================
--- clang-tools-extra/clangd/support/ThreadsafeFS.cpp
+++ clang-tools-extra/clangd/support/ThreadsafeFS.cpp
@@ -87,8 +87,7 @@
// Avoid using memory-mapped files.
// FIXME: Try to use a similar approach in Sema instead of relying on
// propagation of the 'isVolatile' flag through all layers.
- return new VolatileFileSystem(
- llvm::vfs::createPhysicalFileSystem().release());
+ return new VolatileFileSystem(llvm::vfs::createPhysicalFileSystem());
}
} // namespace clangd
} // namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92888.310390.patch
Type: text/x-patch
Size: 3397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201209/fca06829/attachment-0001.bin>
More information about the cfe-commits
mailing list