Return results by value from ClangTidyCheckFactories::createChecks
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@372979 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/clang-tidy/ClangTidy.cpp b/clang-tidy/ClangTidy.cpp
index 4c4745f..21984ae 100644
--- a/clang-tidy/ClangTidy.cpp
+++ b/clang-tidy/ClangTidy.cpp
@@ -384,8 +384,8 @@
if (WorkingDir)
Context.setCurrentBuildDirectory(WorkingDir.get());
- std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
- CheckFactories->createChecks(&Context, Checks);
+ std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
+ CheckFactories->createChecks(&Context);
ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
@@ -459,8 +459,8 @@
ClangTidyOptions::OptionMap ClangTidyASTConsumerFactory::getCheckOptions() {
ClangTidyOptions::OptionMap Options;
- std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
- CheckFactories->createChecks(&Context, Checks);
+ std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
+ CheckFactories->createChecks(&Context);
for (const auto &Check : Checks)
Check->storeOptions(Options);
return Options;
diff --git a/clang-tidy/ClangTidyModule.cpp b/clang-tidy/ClangTidyModule.cpp
index 7d6de87..ff83e7e 100644
--- a/clang-tidy/ClangTidyModule.cpp
+++ b/clang-tidy/ClangTidyModule.cpp
@@ -20,13 +20,14 @@
Factories[Name] = std::move(Factory);
}
-void ClangTidyCheckFactories::createChecks(
- ClangTidyContext *Context,
- std::vector<std::unique_ptr<ClangTidyCheck>> &Checks) {
+std::vector<std::unique_ptr<ClangTidyCheck>>
+ClangTidyCheckFactories::createChecks(ClangTidyContext *Context) {
+ std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
for (const auto &Factory : Factories) {
if (Context->isCheckEnabled(Factory.first))
Checks.emplace_back(Factory.second(Factory.first, Context));
}
+ return Checks;
}
ClangTidyOptions ClangTidyModule::getModuleOptions() {
diff --git a/clang-tidy/ClangTidyModule.h b/clang-tidy/ClangTidyModule.h
index b92971f..5c484f1 100644
--- a/clang-tidy/ClangTidyModule.h
+++ b/clang-tidy/ClangTidyModule.h
@@ -62,12 +62,9 @@
});
}
- /// Create instances of all checks matching \p CheckRegexString and
- /// store them in \p Checks.
- ///
- /// The caller takes ownership of the return \c ClangTidyChecks.
- void createChecks(ClangTidyContext *Context,
- std::vector<std::unique_ptr<ClangTidyCheck>> &Checks);
+ /// Create instances of checks that are enabled.
+ std::vector<std::unique_ptr<ClangTidyCheck>>
+ createChecks(ClangTidyContext *Context);
typedef std::map<std::string, CheckFactory> FactoryMap;
FactoryMap::const_iterator begin() const { return Factories.begin(); }
diff --git a/clangd/ParsedAST.cpp b/clangd/ParsedAST.cpp
index 370af1d..752fabe 100644
--- a/clangd/ParsedAST.cpp
+++ b/clangd/ParsedAST.cpp
@@ -261,7 +261,7 @@
CTContext->setDiagnosticsEngine(&Clang->getDiagnostics());
CTContext->setASTContext(&Clang->getASTContext());
CTContext->setCurrentFile(Filename);
- CTFactories.createChecks(CTContext.getPointer(), CTChecks);
+ CTChecks = CTFactories.createChecks(CTContext.getPointer());
ASTDiags.setLevelAdjuster([&CTContext](DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic &Info) {
if (CTContext) {