[clang-tools-extra] da8eda1 - [clangd] Get rid of redundant make_uniques

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 2 07:52:55 PDT 2020


Author: Kadir Cetinkaya
Date: 2020-04-02T16:52:13+02:00
New Revision: da8eda1ab1ae97115f9ed170216ed89b69662578

URL: https://github.com/llvm/llvm-project/commit/da8eda1ab1ae97115f9ed170216ed89b69662578
DIFF: https://github.com/llvm/llvm-project/commit/da8eda1ab1ae97115f9ed170216ed89b69662578.diff

LOG: [clangd] Get rid of redundant make_uniques

Added: 
    

Modified: 
    clang-tools-extra/clangd/ParsedAST.cpp
    clang-tools-extra/clangd/TUScheduler.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp
index 2c7cb5d2b85d..f6205879aa29 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -551,8 +551,7 @@ buildAST(PathRef FileName, std::unique_ptr<CompilerInvocation> Invocation,
   }
 
   return ParsedAST::build(
-      Inputs.Version, std::make_unique<CompilerInvocation>(*Invocation),
-      CompilerInvocationDiags, Preamble,
+      Inputs.Version, std::move(Invocation), CompilerInvocationDiags, Preamble,
       llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, FileName),
       std::move(VFS), Inputs.Index, Inputs.Opts);
 }

diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp
index e5a001997ecc..a2df2c3ff62f 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -569,12 +569,10 @@ void ASTWorker::runWithAST(
       vlog("ASTWorker rebuilding evicted AST to run {0}: {1} version {2}", Name,
            FileName, CurrentInputs->Version);
       llvm::Optional<ParsedAST> NewAST =
-          Invocation
-              ? buildAST(FileName,
-                         std::make_unique<CompilerInvocation>(*Invocation),
-                         CompilerInvocationDiagConsumer.take(), *CurrentInputs,
-                         getPossiblyStalePreamble())
-              : None;
+          Invocation ? buildAST(FileName, std::move(Invocation),
+                                CompilerInvocationDiagConsumer.take(),
+                                *CurrentInputs, getPossiblyStalePreamble())
+                     : None;
       AST = NewAST ? std::make_unique<ParsedAST>(std::move(*NewAST)) : nullptr;
     }
     // Make sure we put the AST back into the LRU cache.


        


More information about the cfe-commits mailing list