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:
cfe/trunk/include/clang/Index/IndexingAction.h
cfe/trunk/lib/Index/IndexingAction.cpp
cfe/trunk/tools/c-index-test/core_main.cpp
cfe/trunk/tools/libclang/Indexing.cpp
Modified: cfe/trunk/include/clang/Index/IndexingAction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexingAction.h?rev=330595&r1=330594&r2=330595&view=diff
==============================================================================
--- cfe/trunk/include/clang/Index/IndexingAction.h (original)
+++ cfe/trunk/include/clang/Index/IndexingAction.h Mon Apr 23 07:30:21 2018
@@ -46,17 +46,14 @@ createIndexingAction(std::shared_ptr<Ind
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
Modified: cfe/trunk/lib/Index/IndexingAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingAction.cpp?rev=330595&r1=330594&r2=330595&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexingAction.cpp (original)
+++ cfe/trunk/lib/Index/IndexingAction.cpp Mon Apr 23 07:30:21 2018
@@ -173,40 +173,38 @@ static void indexTranslationUnit(ASTUnit
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();
}
Modified: cfe/trunk/tools/c-index-test/core_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/core_main.cpp?rev=330595&r1=330594&r2=330595&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/core_main.cpp (original)
+++ cfe/trunk/tools/c-index-test/core_main.cpp Mon Apr 23 07:30:21 2018
@@ -195,7 +195,7 @@ static bool printSourceSymbols(ArrayRef<
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
return true;
}
- auto DataConsumer = std::make_shared<PrintIndexDataConsumer>(outs());
+ PrintIndexDataConsumer DataConsumer(outs());
IndexingOptions IndexOpts;
indexASTUnit(*AU, DataConsumer, IndexOpts);
Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=330595&r1=330594&r2=330595&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Mon Apr 23 07:30:21 2018
@@ -659,8 +659,7 @@ static CXErrorCode clang_indexTranslatio
? 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_indexTranslatio
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;
}
More information about the cfe-commits
mailing list