[clang-tools-extra] r330595 - [index] Fix methods that take a shared_ptr to just take a reference.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 23 07:30:21 PDT 2018


Author: d0k
Date: Mon Apr 23 07:30:21 2018
New Revision: 330595

URL: http://llvm.org/viewvc/llvm-project?rev=330595&view=rev
Log:
[index] Fix methods that take a shared_ptr to just take a reference.

There is no ownership here, passing a shared_ptr just adds confusion. No
functionality change intended.

Modified:
    clang-tools-extra/trunk/clangd/XRefs.cpp
    clang-tools-extra/trunk/clangd/index/FileIndex.cpp

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=330595&r1=330594&r2=330595&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Mon Apr 23 07:30:21 2018
@@ -182,9 +182,9 @@ std::vector<Location> findDefinitions(Pa
   if (!Result.empty())
     return Result;
 
-  auto DeclMacrosFinder = std::make_shared<DeclarationAndMacrosFinder>(
-      llvm::errs(), SourceLocationBeg, AST.getASTContext(),
-      AST.getPreprocessor());
+  DeclarationAndMacrosFinder DeclMacrosFinder(llvm::errs(), SourceLocationBeg,
+                                              AST.getASTContext(),
+                                              AST.getPreprocessor());
   index::IndexingOptions IndexOpts;
   IndexOpts.SystemSymbolFilter =
       index::IndexingOptions::SystemSymbolFilterKind::All;
@@ -193,8 +193,8 @@ std::vector<Location> findDefinitions(Pa
   indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(),
                      DeclMacrosFinder, IndexOpts);
 
-  std::vector<const Decl *> Decls = DeclMacrosFinder->takeDecls();
-  std::vector<MacroDecl> MacroInfos = DeclMacrosFinder->takeMacroInfos();
+  std::vector<const Decl *> Decls = DeclMacrosFinder.takeDecls();
+  std::vector<MacroDecl> MacroInfos = DeclMacrosFinder.takeMacroInfos();
 
   for (auto D : Decls) {
     auto Loc = findNameLoc(D);
@@ -286,9 +286,9 @@ std::vector<DocumentHighlight> findDocum
 
   SourceLocation SourceLocationBeg = getBeginningOfIdentifier(AST, Pos, FE);
 
-  auto DeclMacrosFinder = std::make_shared<DeclarationAndMacrosFinder>(
-      llvm::errs(), SourceLocationBeg, AST.getASTContext(),
-      AST.getPreprocessor());
+  DeclarationAndMacrosFinder DeclMacrosFinder(llvm::errs(), SourceLocationBeg,
+                                              AST.getASTContext(),
+                                              AST.getPreprocessor());
   index::IndexingOptions IndexOpts;
   IndexOpts.SystemSymbolFilter =
       index::IndexingOptions::SystemSymbolFilterKind::All;
@@ -298,15 +298,15 @@ std::vector<DocumentHighlight> findDocum
   indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(),
                      DeclMacrosFinder, IndexOpts);
 
-  std::vector<const Decl *> SelectedDecls = DeclMacrosFinder->takeDecls();
+  std::vector<const Decl *> SelectedDecls = DeclMacrosFinder.takeDecls();
 
-  auto DocHighlightsFinder = std::make_shared<DocumentHighlightsFinder>(
+  DocumentHighlightsFinder DocHighlightsFinder(
       llvm::errs(), AST.getASTContext(), AST.getPreprocessor(), SelectedDecls);
 
   indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(),
                      DocHighlightsFinder, IndexOpts);
 
-  return DocHighlightsFinder->takeHighlights();
+  return DocHighlightsFinder.takeHighlights();
 }
 
 static PrintingPolicy PrintingPolicyForDecls(PrintingPolicy Base) {
@@ -418,9 +418,9 @@ Hover getHover(ParsedAST &AST, Position
     return Hover();
 
   SourceLocation SourceLocationBeg = getBeginningOfIdentifier(AST, Pos, FE);
-  auto DeclMacrosFinder = std::make_shared<DeclarationAndMacrosFinder>(
-      llvm::errs(), SourceLocationBeg, AST.getASTContext(),
-      AST.getPreprocessor());
+  DeclarationAndMacrosFinder DeclMacrosFinder(llvm::errs(), SourceLocationBeg,
+                                              AST.getASTContext(),
+                                              AST.getPreprocessor());
 
   index::IndexingOptions IndexOpts;
   IndexOpts.SystemSymbolFilter =
@@ -430,11 +430,11 @@ Hover getHover(ParsedAST &AST, Position
   indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(),
                      DeclMacrosFinder, IndexOpts);
 
-  std::vector<MacroDecl> Macros = DeclMacrosFinder->takeMacroInfos();
+  std::vector<MacroDecl> Macros = DeclMacrosFinder.takeMacroInfos();
   if (!Macros.empty())
     return getHoverContents(Macros[0].Name);
 
-  std::vector<const Decl *> Decls = DeclMacrosFinder->takeDecls();
+  std::vector<const Decl *> Decls = DeclMacrosFinder.takeDecls();
   if (!Decls.empty())
     return getHoverContents(Decls[0]);
 

Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=330595&r1=330594&r2=330595&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Mon Apr 23 07:30:21 2018
@@ -28,8 +28,8 @@ std::unique_ptr<SymbolSlab> indexAST(AST
   CollectorOpts.CollectIncludePath = false;
   CollectorOpts.CountReferences = false;
 
-  auto Collector = std::make_shared<SymbolCollector>(std::move(CollectorOpts));
-  Collector->setPreprocessor(std::move(PP));
+  SymbolCollector Collector(std::move(CollectorOpts));
+  Collector.setPreprocessor(std::move(PP));
   index::IndexingOptions IndexOpts;
   // We only need declarations, because we don't count references.
   IndexOpts.SystemSymbolFilter =
@@ -38,7 +38,7 @@ std::unique_ptr<SymbolSlab> indexAST(AST
 
   index::indexTopLevelDecls(Ctx, Decls, Collector, IndexOpts);
   auto Symbols = llvm::make_unique<SymbolSlab>();
-  *Symbols = Collector->takeSymbols();
+  *Symbols = Collector.takeSymbols();
   return Symbols;
 }
 




More information about the cfe-commits mailing list