From: Benjamin Kramer Date: Thu, 21 Jul 2016 15:06:51 +0000 (+0000) Subject: Move some IntrusiveRefCntPtrs instead of copying. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59b5b4729097499ec4a850a73638f3993b2f4ff3;p=clang Move some IntrusiveRefCntPtrs instead of copying. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276292 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 085faeae48..49470d22fa 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -344,11 +344,10 @@ private: std::string FlagValue; public: - explicit DiagnosticsEngine( - const IntrusiveRefCntPtr &Diags, - DiagnosticOptions *DiagOpts, - DiagnosticConsumer *client = nullptr, - bool ShouldOwnClient = true); + explicit DiagnosticsEngine(IntrusiveRefCntPtr Diags, + DiagnosticOptions *DiagOpts, + DiagnosticConsumer *client = nullptr, + bool ShouldOwnClient = true); ~DiagnosticsEngine(); const IntrusiveRefCntPtr &getDiagnosticIDs() const { diff --git a/lib/ASTMatchers/ASTMatchersInternal.cpp b/lib/ASTMatchers/ASTMatchersInternal.cpp index 107052ef1d..f0bfbf9e32 100644 --- a/lib/ASTMatchers/ASTMatchersInternal.cpp +++ b/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -72,10 +72,10 @@ private: }; class IdDynMatcher : public DynMatcherInterface { - public: +public: IdDynMatcher(StringRef ID, - const IntrusiveRefCntPtr &InnerMatcher) - : ID(ID), InnerMatcher(InnerMatcher) {} + IntrusiveRefCntPtr InnerMatcher) + : ID(ID), InnerMatcher(std::move(InnerMatcher)) {} bool dynMatches(const ast_type_traits::DynTypedNode &DynNode, ASTMatchFinder *Finder, @@ -85,7 +85,7 @@ class IdDynMatcher : public DynMatcherInterface { return Result; } - private: +private: const std::string ID; const IntrusiveRefCntPtr InnerMatcher; }; @@ -210,8 +210,9 @@ bool DynTypedMatcher::matchesNoKindCheck( llvm::Optional DynTypedMatcher::tryBind(StringRef ID) const { if (!AllowBind) return llvm::None; auto Result = *this; - Result.Implementation = new IdDynMatcher(ID, Result.Implementation); - return Result; + Result.Implementation = + new IdDynMatcher(ID, std::move(Result.Implementation)); + return std::move(Result); } bool DynTypedMatcher::canConvertTo(ast_type_traits::ASTNodeKind To) const { diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index f10d156743..0853ec65d8 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -55,10 +55,12 @@ static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT, Output.append(Str.begin(), Str.end()); } -DiagnosticsEngine::DiagnosticsEngine( - const IntrusiveRefCntPtr &diags, DiagnosticOptions *DiagOpts, - DiagnosticConsumer *client, bool ShouldOwnClient) - : Diags(diags), DiagOpts(DiagOpts), Client(nullptr), SourceMgr(nullptr) { +DiagnosticsEngine::DiagnosticsEngine(IntrusiveRefCntPtr diags, + DiagnosticOptions *DiagOpts, + DiagnosticConsumer *client, + bool ShouldOwnClient) + : Diags(std::move(diags)), DiagOpts(DiagOpts), Client(nullptr), + SourceMgr(nullptr) { setClient(client, ShouldOwnClient); ArgToStringFn = DummyArgToStringFn; ArgToStringCookie = nullptr;