[clang-tools-extra] r372979 - Return results by value from ClangTidyCheckFactories::createChecks

Dmitri Gribenko via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 26 06:55:01 PDT 2019


Author: gribozavr
Date: Thu Sep 26 06:55:01 2019
New Revision: 372979

URL: http://llvm.org/viewvc/llvm-project?rev=372979&view=rev
Log:
Return results by value from ClangTidyCheckFactories::createChecks

Modified:
    clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
    clang-tools-extra/trunk/clang-tidy/ClangTidyModule.cpp
    clang-tools-extra/trunk/clang-tidy/ClangTidyModule.h
    clang-tools-extra/trunk/clangd/ParsedAST.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=372979&r1=372978&r2=372979&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Sep 26 06:55:01 2019
@@ -384,8 +384,8 @@ ClangTidyASTConsumerFactory::CreateASTCo
   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 @@ std::vector<std::string> ClangTidyASTCon
 
 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;

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyModule.cpp?rev=372979&r1=372978&r2=372979&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyModule.cpp Thu Sep 26 06:55:01 2019
@@ -20,13 +20,14 @@ void ClangTidyCheckFactories::registerCh
   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() {

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyModule.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyModule.h?rev=372979&r1=372978&r2=372979&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyModule.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyModule.h Thu Sep 26 06:55:01 2019
@@ -62,12 +62,9 @@ public:
                          });
   }
 
-  /// 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(); }

Modified: clang-tools-extra/trunk/clangd/ParsedAST.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ParsedAST.cpp?rev=372979&r1=372978&r2=372979&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ParsedAST.cpp (original)
+++ clang-tools-extra/trunk/clangd/ParsedAST.cpp Thu Sep 26 06:55:01 2019
@@ -261,7 +261,7 @@ ParsedAST::build(std::unique_ptr<clang::
     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) {




More information about the cfe-commits mailing list