[PATCH] D107873: [WIP][clang-tidy] adds a const-qualified parameter check

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 10 21:55:26 PDT 2021


Eugene.Zelenko added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/performance/ConstParameterValueOrRef.cpp:57
+namespace {
+bool isSharedPtr(const QualType &T) {
+  if (auto R = T->getAsCXXRecordDecl())
----------------
Please use `static`, not anonymous namespace for functions.


================
Comment at: clang-tools-extra/clang-tidy/performance/ConstParameterValueOrRef.cpp:58
+bool isSharedPtr(const QualType &T) {
+  if (auto R = T->getAsCXXRecordDecl())
+    return R->getQualifiedNameAsString() == "std::shared_ptr" ||
----------------
Please don't use auto unless type is spelled in same statement or iterator.


================
Comment at: clang-tools-extra/clang-tidy/performance/ConstParameterValueOrRef.h:1
+//===----------------------------------------------------------------------===//
+//
----------------
See other headers as example for C++ definition for code editors.


================
Comment at: clang-tools-extra/clang-tidy/performance/ConstParameterValueOrRef.h:18
+namespace performance {
+// Checks ``const``-qualified parameters to determine if they should be passed
+// by value or by reference-to-``const`` for function definitions. Ignores
----------------
Please separate with newline.


================
Comment at: clang-tools-extra/clang-tidy/performance/ConstParameterValueOrRef.h:43
+
+struct MaxSize {
+  int Size;
----------------
Seems to be unused.


================
Comment at: clang-tools-extra/clang-tidy/performance/ConstParameterValueOrRef.h:46
+};
+} // namespace performance
+} // namespace tidy
----------------
Please separate with newline.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/performance-const-parameter-value-or-ref.rst:16
+This check works well with ``readability-avoid-const-params-in-decls``.
+
+
----------------
Please remove newline.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/performance-const-parameter-value-or-ref.rst:67
+
+**Accepted values**: ``'ConstValue'``, ``'RefToConst'``, ``Neither``
+
----------------
Please use single back-tick for option values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107873



More information about the cfe-commits mailing list