forked from OSchip/llvm-project
[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. llvm-svn: 330595
This commit is contained in:
parent
6978db7800
commit
6f33fca7ec
|
@ -182,9 +182,9 @@ std::vector<Location> findDefinitions(ParsedAST &AST, Position Pos) {
|
|||
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(ParsedAST &AST, Position Pos) {
|
|||
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> findDocumentHighlights(ParsedAST &AST,
|
|||
|
||||
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> findDocumentHighlights(ParsedAST &AST,
|
|||
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 Pos) {
|
|||
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 Pos) {
|
|||
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]);
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ std::unique_ptr<SymbolSlab> indexAST(ASTContext &Ctx,
|
|||
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(ASTContext &Ctx,
|
|||
|
||||
index::indexTopLevelDecls(Ctx, Decls, Collector, IndexOpts);
|
||||
auto Symbols = llvm::make_unique<SymbolSlab>();
|
||||
*Symbols = Collector->takeSymbols();
|
||||
*Symbols = Collector.takeSymbols();
|
||||
return Symbols;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,17 +46,14 @@ createIndexingAction(std::shared_ptr<IndexDataConsumer> DataConsumer,
|
|||
IndexingOptions Opts,
|
||||
std::unique_ptr<FrontendAction> WrappedAction);
|
||||
|
||||
void indexASTUnit(ASTUnit &Unit,
|
||||
std::shared_ptr<IndexDataConsumer> DataConsumer,
|
||||
void indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer,
|
||||
IndexingOptions Opts);
|
||||
|
||||
void indexTopLevelDecls(ASTContext &Ctx, ArrayRef<const Decl *> Decls,
|
||||
std::shared_ptr<IndexDataConsumer> DataConsumer,
|
||||
IndexingOptions Opts);
|
||||
IndexDataConsumer &DataConsumer, IndexingOptions Opts);
|
||||
|
||||
void indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader,
|
||||
std::shared_ptr<IndexDataConsumer> DataConsumer,
|
||||
IndexingOptions Opts);
|
||||
IndexDataConsumer &DataConsumer, IndexingOptions Opts);
|
||||
|
||||
} // namespace index
|
||||
} // namespace clang
|
||||
|
|
|
@ -173,40 +173,38 @@ static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IndexCtx) {
|
|||
Unit.visitLocalTopLevelDecls(&IndexCtx, topLevelDeclVisitor);
|
||||
}
|
||||
|
||||
void index::indexASTUnit(ASTUnit &Unit,
|
||||
std::shared_ptr<IndexDataConsumer> DataConsumer,
|
||||
void index::indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer,
|
||||
IndexingOptions Opts) {
|
||||
IndexingContext IndexCtx(Opts, *DataConsumer);
|
||||
IndexingContext IndexCtx(Opts, DataConsumer);
|
||||
IndexCtx.setASTContext(Unit.getASTContext());
|
||||
DataConsumer->initialize(Unit.getASTContext());
|
||||
DataConsumer->setPreprocessor(Unit.getPreprocessorPtr());
|
||||
DataConsumer.initialize(Unit.getASTContext());
|
||||
DataConsumer.setPreprocessor(Unit.getPreprocessorPtr());
|
||||
indexTranslationUnit(Unit, IndexCtx);
|
||||
DataConsumer->finish();
|
||||
DataConsumer.finish();
|
||||
}
|
||||
|
||||
void index::indexTopLevelDecls(ASTContext &Ctx, ArrayRef<const Decl *> Decls,
|
||||
std::shared_ptr<IndexDataConsumer> DataConsumer,
|
||||
IndexDataConsumer &DataConsumer,
|
||||
IndexingOptions Opts) {
|
||||
IndexingContext IndexCtx(Opts, *DataConsumer);
|
||||
IndexingContext IndexCtx(Opts, DataConsumer);
|
||||
IndexCtx.setASTContext(Ctx);
|
||||
|
||||
DataConsumer->initialize(Ctx);
|
||||
DataConsumer.initialize(Ctx);
|
||||
for (const Decl *D : Decls)
|
||||
IndexCtx.indexTopLevelDecl(D);
|
||||
DataConsumer->finish();
|
||||
DataConsumer.finish();
|
||||
}
|
||||
|
||||
void index::indexModuleFile(serialization::ModuleFile &Mod,
|
||||
ASTReader &Reader,
|
||||
std::shared_ptr<IndexDataConsumer> DataConsumer,
|
||||
void index::indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader,
|
||||
IndexDataConsumer &DataConsumer,
|
||||
IndexingOptions Opts) {
|
||||
ASTContext &Ctx = Reader.getContext();
|
||||
IndexingContext IndexCtx(Opts, *DataConsumer);
|
||||
IndexingContext IndexCtx(Opts, DataConsumer);
|
||||
IndexCtx.setASTContext(Ctx);
|
||||
DataConsumer->initialize(Ctx);
|
||||
DataConsumer.initialize(Ctx);
|
||||
|
||||
for (const Decl *D : Reader.getModuleFileLevelDecls(Mod)) {
|
||||
IndexCtx.indexTopLevelDecl(D);
|
||||
}
|
||||
DataConsumer->finish();
|
||||
DataConsumer.finish();
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ static bool printSourceSymbols(ArrayRef<const char *> Args,
|
|||
if (auto Reader = Unit->getASTReader()) {
|
||||
Reader->getModuleManager().visit([&](serialization::ModuleFile &Mod) -> bool {
|
||||
OS << "==== Module " << Mod.ModuleName << " ====\n";
|
||||
indexModuleFile(Mod, *Reader, DataConsumer, IndexOpts);
|
||||
indexModuleFile(Mod, *Reader, *DataConsumer, IndexOpts);
|
||||
dumpModuleFileInputs(Mod, *Reader, OS);
|
||||
return true; // skip module dependencies.
|
||||
});
|
||||
|
@ -231,7 +231,7 @@ static bool printSourceSymbolsFromModule(StringRef modulePath,
|
|||
return true;
|
||||
}
|
||||
|
||||
auto DataConsumer = std::make_shared<PrintIndexDataConsumer>(outs());
|
||||
PrintIndexDataConsumer DataConsumer(outs());
|
||||
IndexingOptions IndexOpts;
|
||||
indexASTUnit(*AU, DataConsumer, IndexOpts);
|
||||
|
||||
|
|
|
@ -659,8 +659,7 @@ static CXErrorCode clang_indexTranslationUnit_Impl(
|
|||
? index_callbacks_size : sizeof(CB);
|
||||
memcpy(&CB, client_index_callbacks, ClientCBSize);
|
||||
|
||||
auto DataConsumer = std::make_shared<CXIndexDataConsumer>(client_data, CB,
|
||||
index_options, TU);
|
||||
CXIndexDataConsumer DataConsumer(client_data, CB, index_options, TU);
|
||||
|
||||
ASTUnit *Unit = cxtu::getASTUnit(TU);
|
||||
if (!Unit)
|
||||
|
@ -669,21 +668,22 @@ static CXErrorCode clang_indexTranslationUnit_Impl(
|
|||
ASTUnit::ConcurrencyCheck Check(*Unit);
|
||||
|
||||
if (const FileEntry *PCHFile = Unit->getPCHFile())
|
||||
DataConsumer->importedPCH(PCHFile);
|
||||
DataConsumer.importedPCH(PCHFile);
|
||||
|
||||
FileManager &FileMgr = Unit->getFileManager();
|
||||
|
||||
if (Unit->getOriginalSourceFileName().empty())
|
||||
DataConsumer->enteredMainFile(nullptr);
|
||||
DataConsumer.enteredMainFile(nullptr);
|
||||
else
|
||||
DataConsumer->enteredMainFile(FileMgr.getFile(Unit->getOriginalSourceFileName()));
|
||||
DataConsumer.enteredMainFile(
|
||||
FileMgr.getFile(Unit->getOriginalSourceFileName()));
|
||||
|
||||
DataConsumer->setASTContext(Unit->getASTContext());
|
||||
DataConsumer->startedTranslationUnit();
|
||||
DataConsumer.setASTContext(Unit->getASTContext());
|
||||
DataConsumer.startedTranslationUnit();
|
||||
|
||||
indexPreprocessingRecord(*Unit, *DataConsumer);
|
||||
indexPreprocessingRecord(*Unit, DataConsumer);
|
||||
indexASTUnit(*Unit, DataConsumer, getIndexingOptionsFromCXOptions(index_options));
|
||||
DataConsumer->indexDiagnostics();
|
||||
DataConsumer.indexDiagnostics();
|
||||
|
||||
return CXError_Success;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue