[PATCH] D61005: [LibTooling] Fix unneeded use of unique_ptr where shared_ptr is expected.
Yitzhak Mandelbaum via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 23 06:04:22 PDT 2019
ymandel created this revision.
ymandel added a reviewer: sbenza.
Herald added a project: clang.
This fixes a few places in the Stencil implementation where a unique_ptr is created at a callsite that expects shared_ptr. Since the former implicitly converts to the latter, the code compiles and runs correctly as is. But, there's no reason to involve unique_ptr -- the current code was leftover from a previous version in which unique_ptr was the expected type.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D61005
Files:
clang/lib/Tooling/Refactoring/Stencil.cpp
Index: clang/lib/Tooling/Refactoring/Stencil.cpp
===================================================================
--- clang/lib/Tooling/Refactoring/Stencil.cpp
+++ clang/lib/Tooling/Refactoring/Stencil.cpp
@@ -16,6 +16,7 @@
#include "clang/Tooling/Refactoring/SourceCode.h"
#include "llvm/Support/Errc.h"
#include <atomic>
+#include <memory>
#include <string>
using namespace clang;
@@ -183,17 +184,17 @@
}
StencilPart stencil::text(StringRef Text) {
- return StencilPart(llvm::make_unique<RawText>(Text));
+ return StencilPart(std::make_shared<RawText>(Text));
}
StencilPart stencil::node(StringRef Id) {
- return StencilPart(llvm::make_unique<NodeRef>(Id, SemiAssociation::Inferred));
+ return StencilPart(std::make_shared<NodeRef>(Id, SemiAssociation::Inferred));
}
StencilPart stencil::sNode(StringRef Id) {
- return StencilPart(llvm::make_unique<NodeRef>(Id, SemiAssociation::Always));
+ return StencilPart(std::make_shared<NodeRef>(Id, SemiAssociation::Always));
}
StencilPart stencil::dPrint(StringRef Id) {
- return StencilPart(llvm::make_unique<DebugPrintNodeOp>(Id));
+ return StencilPart(std::make_shared<DebugPrintNodeOp>(Id));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61005.196227.patch
Type: text/x-patch
Size: 1177 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190423/2454119c/attachment.bin>
More information about the cfe-commits
mailing list