]> granicus.if.org Git - clang/commitdiff
Move some IntrusiveRefCntPtrs instead of copying.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 21 Jul 2016 15:06:51 +0000 (15:06 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 21 Jul 2016 15:06:51 +0000 (15:06 +0000)
No functionality change intended.

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

include/clang/Basic/Diagnostic.h
lib/ASTMatchers/ASTMatchersInternal.cpp
lib/Basic/Diagnostic.cpp

index 085faeae4834c66f6b4e6498b30eef7a1b56b0d3..49470d22fa4ead18615ab45fe02895ddffafbab2 100644 (file)
@@ -344,11 +344,10 @@ private:
   std::string FlagValue;
 
 public:
-  explicit DiagnosticsEngine(
-                      const IntrusiveRefCntPtr<DiagnosticIDs> &Diags,
-                      DiagnosticOptions *DiagOpts,
-                      DiagnosticConsumer *client = nullptr,
-                      bool ShouldOwnClient = true);
+  explicit DiagnosticsEngine(IntrusiveRefCntPtr<DiagnosticIDs> Diags,
+                             DiagnosticOptions *DiagOpts,
+                             DiagnosticConsumer *client = nullptr,
+                             bool ShouldOwnClient = true);
   ~DiagnosticsEngine();
 
   const IntrusiveRefCntPtr<DiagnosticIDs> &getDiagnosticIDs() const {
index 107052ef1dedf1f742f1fac3abcac013a07dd574..f0bfbf9e32d87306e1a75e78590d1af40859d728 100644 (file)
@@ -72,10 +72,10 @@ private:
 };
 
 class IdDynMatcher : public DynMatcherInterface {
- public:
+public:
   IdDynMatcher(StringRef ID,
-               const IntrusiveRefCntPtr<DynMatcherInterface> &InnerMatcher)
-      : ID(ID), InnerMatcher(InnerMatcher) {}
+               IntrusiveRefCntPtr<DynMatcherInterface> 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<DynMatcherInterface> InnerMatcher;
 };
@@ -210,8 +210,9 @@ bool DynTypedMatcher::matchesNoKindCheck(
 llvm::Optional<DynTypedMatcher> 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 {
index f10d156743b252dfe5b9d353b474cff7cbedbc46..0853ec65d87958a86ef87bba7ea2e33dec9a561a 100644 (file)
@@ -55,10 +55,12 @@ static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT,
   Output.append(Str.begin(), Str.end());
 }
 
-DiagnosticsEngine::DiagnosticsEngine(
-    const IntrusiveRefCntPtr<DiagnosticIDs> &diags, DiagnosticOptions *DiagOpts,
-    DiagnosticConsumer *client, bool ShouldOwnClient)
-    : Diags(diags), DiagOpts(DiagOpts), Client(nullptr), SourceMgr(nullptr) {
+DiagnosticsEngine::DiagnosticsEngine(IntrusiveRefCntPtr<DiagnosticIDs> diags,
+                                     DiagnosticOptions *DiagOpts,
+                                     DiagnosticConsumer *client,
+                                     bool ShouldOwnClient)
+    : Diags(std::move(diags)), DiagOpts(DiagOpts), Client(nullptr),
+      SourceMgr(nullptr) {
   setClient(client, ShouldOwnClient);
   ArgToStringFn = DummyArgToStringFn;
   ArgToStringCookie = nullptr;