[PATCH] D54401: [analyzer] Prefer returns values to out-params in CheckerRegistry.cpp

Henry Wong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 12 05:47:46 PST 2018


MTC added a comment.

I'm totally fine with this patch personally. However I am not familiar with this part, so can't give substantial help :).



================
Comment at: lib/StaticAnalyzer/Core/CheckerRegistry.cpp:51
 
-/// Collects the checkers for the supplied \p opt option into \p collected.
-static void collectCheckers(const CheckerRegistry::CheckerInfoList &checkers,
-                            const llvm::StringMap<size_t> &packageSizes,
-                            CheckerOptInfo &opt, CheckerInfoSet &collected) {
-  // Use a binary search to find the possible start of the package.
-  CheckerRegistry::CheckerInfo packageInfo(nullptr, opt.getName(), "");
-  auto end = checkers.cend();
-  auto i = std::lower_bound(checkers.cbegin(), end, packageInfo, checkerNameLT);
-
-  // If we didn't even find a possible package, give up.
-  if (i == end)
-    return;
-
-  // If what we found doesn't actually start the package, give up.
-  if (!isInPackage(*i, opt.getName()))
-    return;
-
-  // There is at least one checker in the package; claim the option.
-  opt.claim();
-
-  // See how large the package is.
-  // If the package doesn't exist, assume the option refers to a single checker.
-  size_t size = 1;
-  llvm::StringMap<size_t>::const_iterator packageSize =
-    packageSizes.find(opt.getName());
-  if (packageSize != packageSizes.end())
-    size = packageSize->getValue();
-
-  // Step through all the checkers in the package.
-  for (auto checkEnd = i+size; i != checkEnd; ++i)
-    if (opt.isEnabled())
-      collected.insert(&*i);
-    else
-      collected.remove(&*i);
+static CheckerInfoSet getEnabledCheckers(
+    const CheckerRegistry::CheckerInfoList &checkers,
----------------
I just curious about the reason why you move the `CheckerInfoSet` from the parameter passing by reference to the return value, keep the number of parameter at a lower value? Or make the code at the caller cite cleaner?


https://reviews.llvm.org/D54401





More information about the cfe-commits mailing list