]> granicus.if.org Git - clang/commitdiff
[LibTooling] Fix unneeded use of unique_ptr where shared_ptr is expected.
authorYitzhak Mandelbaum <yitzhakm@google.com>
Mon, 29 Apr 2019 16:57:40 +0000 (16:57 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Mon, 29 Apr 2019 16:57:40 +0000 (16:57 +0000)
Summary: 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.

Reviewers: sbenza

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D61005

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359468 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Tooling/Refactoring/Stencil.cpp

index adc26ca653f290e0e8ed50c3a283b78acfba051a..8fe589b0985c4cdbd221b0a39dc4e6047dd72add 100644 (file)
@@ -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 @@ Stencil::eval(const MatchFinder::MatchResult &Match) const {
 }
 
 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));
 }