[PATCH] D116593: Fix `performance-unnecessary-value-param` for template specialization

Felix Berger via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 4 06:44:57 PST 2022


flx added a comment.

Thanks for improving this check!



================
Comment at: clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp:177-178
     const auto &CurrentParam = *FunctionDecl->getParamDecl(Index);
+    if (IsExplicitTemplateSpecialization && Function != FunctionDecl)
+      continue;
     Diag << utils::fixit::changeVarDeclToReference(CurrentParam,
----------------
Could you add a comment here why we're skipping the fix here?


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param.cpp:388
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'E' is copied
+  // CHECK-FIXES: T templateSpecializationFunction(const ExpensiveToCopyType& E) {
+  return T();
----------------
Should we apply the fixes or just issue the warning? For virtual methods we suppress the fix since we can't necessarily update all overrides of the method. Are template specializations always guaranteed to be in the same translation unit which  would make this safe?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116593/new/

https://reviews.llvm.org/D116593



More information about the cfe-commits mailing list